You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/eclass/mozextension.eclass

60 lines
1.7 KiB

# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/mozextension.eclass,v 1.7 2011/12/27 17:55:12 fauli Exp $
#
# @ECLASS: mozextension.eclass
# @MAINTAINER:
# Mozilla team <mozilla@gentoo.org>
# @DESCRIPTION:
# Install extensions for use in mozilla products.
inherit eutils
DEPEND="app-arch/unzip"
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
emid="$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${x}"/install.rdf)" \
|| die "failed to determine extension id"
insinto "${MOZILLA_FIVE_HOME}"/extensions/${emid}
doins -r "${x}"/* || die "failed to copy extension"
}