blob: 53f27ed782c321eb90c3a3997bf9dd9fbf307c58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
#
# @ECLASS: mozextension.eclass
# @MAINTAINER:
# Mozilla team <mozilla@gentoo.org>
# @BLURB: Install extensions for use in Mozilla products.
if [[ ! ${_MOZEXTENSION} ]]; then
# @ECLASS-VARIABLE: MOZEXTENSION_TARGET
# @DESCRIPTION:
# This variable allows the installation path for xpi_install
# to be overridden from the default app-global extensions path.
# Default is empty, which installs to predetermined hard-coded
# paths specified in the eclass.
: ${MOZEXTENSION_TARGET:=""}
DEPEND="app-arch/unzip"
mozversion_extension_location() {
case ${PN} in
firefox|firefox-bin|palemoon)
if [[ $(get_version_component_range 1) -ge 21 ]] ; then
return 0
fi
;;
esac
return 1
}
xpi_unpack() {
local xpi xpiname srcdir
# Not gonna use ${A} as we are looking for a specific option being passed to function
# You must specify which xpi to use
[[ -z "$*" ]] && die "Nothing passed to the $FUNCNAME command. please pass which xpi to unpack"
for xpi in "$@"; do
einfo "Unpacking ${xpi} to ${PWD}"
xpiname=$(basename ${xpi%.*})
if [[ "${xpi:0:2}" != "./" ]] && [[ "${xpi:0:1}" != "/" ]] ; then
srcdir="${DISTDIR}/"
fi
[[ -s "${srcdir}${xpi}" ]] || die "${xpi} does not exist"
case "${xpi##*.}" in
ZIP|zip|jar|xpi)
mkdir "${WORKDIR}/${xpiname}" && \
unzip -qo "${srcdir}${xpi}" -d "${WORKDIR}/${xpiname}" || die "failed to unpack ${xpi}"
;;
*)
einfo "unpack ${xpi}: file format not recognized. Ignoring."
;;
esac
done
}
xpi_install() {
local emid
# You must tell xpi_install which xpi to use
[[ ${#} -ne 1 ]] && die "$FUNCNAME takes exactly one argument, please specify an xpi to unpack"
x="${1}"
#cd ${x}
# determine id for extension
if [[ -f "${x}"/install.rdf ]]; then
emid="$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${x}"/install.rdf)"
[[ -z "${emid}" ]] && die "failed to determine extension id from install.rdf"
elif [[ -f "${x}"/manifest.json ]]; then
emid="$( sed -n 's/.*"id": "\(.*\)".*/\1/p' "${x}"/manifest.json )"
[[ -z "${emid}" ]] && die "failed to determine extension id from manifest.json"
else
die "failed to determine extension id"
fi
if [[ -n ${MOZEXTENSION_TARGET} ]]; then
insinto "${MOZILLA_FIVE_HOME}"/${MOZEXTENSION_TARGET%/}/${emid}
elif $(mozversion_extension_location) ; then
insinto "${MOZILLA_FIVE_HOME}"/browser/extensions/${emid}
else
insinto "${MOZILLA_FIVE_HOME}"/extensions/${emid}
fi
doins -r "${x}"/* || die "failed to copy extension"
}
xpi_copy() {
local emid
# You must tell xpi_install which xpi to use
[[ ${#} -ne 1 ]] && die "$FUNCNAME takes exactly one argument, please specify an xpi to unpack"
x="${1}"
#cd ${x}
# determine id for extension
if [[ -f "${x}"/install.rdf ]]; then
emid="$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${x}"/install.rdf)"
[[ -z "${emid}" ]] && die "failed to determine extension id from install.rdf"
elif [[ -f "${x}"/manifest.json ]]; then
emid="$(sed -n 's/.*"id": "\([^"]*\)".*/\1/p' "${x}"/manifest.json)"
[[ -z "${emid}" ]] && die "failed to determine extension id from manifest.json"
else
die "failed to determine extension id"
fi
if [[ -n ${MOZEXTENSION_TARGET} ]]; then
insinto "${MOZILLA_FIVE_HOME}"/${MOZEXTENSION_TARGET%/}
elif $(mozversion_extension_location) ; then
insinto "${MOZILLA_FIVE_HOME}"/browser/extensions
else
insinto "${MOZILLA_FIVE_HOME}"/extensions
fi
newins "${DISTDIR%/}"/${x##*/}.xpi ${emid}.xpi
}
_MOZEXTENSION=1
fi
|