1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: mozextension.eclass
7 # Mozilla team <mozilla@gentoo.org>
8 # @BLURB: Install extensions for use in mozilla products.
10 if [[ ! ${_MOZEXTENSION} ]]; then
12 # @ECLASS-VARIABLE: MOZEXTENSION_TARGET
14 # This variable allows the installation path for xpi_install
15 # to be overridden from the default app-global extensions path.
16 # Default is empty, which installs to predetermined hard-coded
17 # paths specified in the eclass.
18 : ${MOZEXTENSION_TARGET:=""}
22 DEPEND="app-arch/unzip"
24 mozversion_extension_location() {
27 if [[ $(get_version_component_range 1) -ge 21 ]] ; then
37 local xpi xpiname srcdir
39 # Not gonna use ${A} as we are looking for a specific option being passed to function
40 # You must specify which xpi to use
41 [[ -z "$*" ]] && die "Nothing passed to the $FUNCNAME command. please pass which xpi to unpack"
44 einfo "Unpacking ${xpi} to ${PWD}"
45 xpiname=$(basename ${xpi%.*})
47 if [[ "${xpi:0:2}" != "./" ]] && [[ "${xpi:0:1}" != "/" ]] ; then
51 [[ -s "${srcdir}${xpi}" ]] || die "${xpi} does not exist"
55 mkdir "${WORKDIR}/${xpiname}" && \
56 unzip -qo "${srcdir}${xpi}" -d "${WORKDIR}/${xpiname}" || die "failed to unpack ${xpi}"
59 einfo "unpack ${xpi}: file format not recognized. Ignoring."
69 # You must tell xpi_install which xpi to use
70 [[ ${#} -ne 1 ]] && die "$FUNCNAME takes exactly one argument, please specify an xpi to unpack"
74 # determine id for extension
75 emid="$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${x}"/install.rdf)" \
76 || die "failed to determine extension id"
77 if [[ -n ${MOZEXTENSION_TARGET} ]]; then
78 insinto "${MOZILLA_FIVE_HOME}"/${MOZEXTENSION_TARGET%/}/${emid}
79 elif $(mozversion_extension_location) ; then
80 insinto "${MOZILLA_FIVE_HOME}"/browser/extensions/${emid}
82 insinto "${MOZILLA_FIVE_HOME}"/extensions/${emid}
84 doins -r "${x}"/* || die "failed to copy extension"