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