1 |
# Copyright 1999-2006 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/mozextension.eclass,v 1.1 2006/01/08 14:19:53 anarchy Exp $ |
4 |
# |
5 |
# mozextention.eclass: installing firefox extensions and language packs |
6 |
|
7 |
inherit eutils |
8 |
|
9 |
DEPEND="app-arch/unzip" |
10 |
|
11 |
xpi_unpack() { |
12 |
local xpi xpiname srcdir |
13 |
|
14 |
# Not gonna use ${A} as we are looking for a specific option being passed to function |
15 |
# You must specify which xpi to use |
16 |
[[ -z "$*" ]] && die "Nothing passed to the $FUNCNAME command. please pass which xpi to unpack" |
17 |
|
18 |
for xpi in "$@"; do |
19 |
einfo "Unpacking ${xpi} to ${PWD}" |
20 |
xpiname=${xpi%.*} |
21 |
|
22 |
if [[ "${xpi:0:2}" != "./" ]] ; then |
23 |
srcdir="${DISTDIR}/" |
24 |
fi |
25 |
|
26 |
[[ -s "${srcdir}${xpi}" ]] || die "${xpi} does not exist" |
27 |
|
28 |
case "${xpi##*.}" in |
29 |
ZIP|zip|jar|xpi) |
30 |
mkdir "${WORKDIR}/${xpiname}" && \ |
31 |
cd "${WORKDIR}/${xpiname}" && \ |
32 |
unzip -qo "${srcdir}${xpi}" || die "failed to unpack ${xpi}" |
33 |
;; |
34 |
*) |
35 |
einfo "unpack ${xpi}: file format not recognized. Ignoring." |
36 |
;; |
37 |
esac |
38 |
done |
39 |
} |
40 |
|
41 |
|
42 |
xpi_install() { |
43 |
local emid |
44 |
|
45 |
# You must tell xpi_install which xpi to use |
46 |
[[ ${#} -ne 1 ]] && die "$FUNCNAME takes exactly one argument, please specify an xpi to unpack" |
47 |
|
48 |
x="${1}" |
49 |
cd ${x} |
50 |
# determine id for extension |
51 |
emid=$(sed -n -e '/<\?em:id>\?/!d; s/.*\([\"{].*[}\"]\).*/\1/; s/\"//g; p; q' ${x}/install.rdf) || die "failed to determine extension id" |
52 |
insinto "${MOZILLA_FIVE_HOME}"/extensions/${emid} |
53 |
doins -r "${x}"/* || die "failed to copy extension" |
54 |
} |