summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Väth <martin@mvath.de>2015-11-29 08:29:52 +0100
committerMartin Väth <martin@mvath.de>2015-11-29 08:29:52 +0100
commit08d759cd0d30319dad072e50db3a50f77be89acf (patch)
tree6de0b848ddfbf7abd05fb47b8bdd1c2edcdab701 /eclass/mv_mozextension-r1.eclass
parentapp-shells/zshrc-mv: Version bump (diff)
downloadmv-08d759cd0d30319dad072e50db3a50f77be89acf.tar.gz
mv-08d759cd0d30319dad072e50db3a50f77be89acf.tar.bz2
mv-08d759cd0d30319dad072e50db3a50f77be89acf.zip
Bump to EAPI=6
Diffstat (limited to 'eclass/mv_mozextension-r1.eclass')
-rw-r--r--eclass/mv_mozextension-r1.eclass248
1 files changed, 248 insertions, 0 deletions
diff --git a/eclass/mv_mozextension-r1.eclass b/eclass/mv_mozextension-r1.eclass
new file mode 100644
index 00000000..ae462400
--- /dev/null
+++ b/eclass/mv_mozextension-r1.eclass
@@ -0,0 +1,248 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: moz.eclass
+# @MAINTAINER:
+# Martin Väth <martin@mvath.de>
+# @BLURB: This eclass provides functions to install mozilla extensions
+# @DESCRIPTION:
+# The eclass is based on mozextension.eclass with many extensions
+# and compatiblity fixes.
+# @EXAMPLE:
+# @CODE
+# inherit moz
+#
+# moz_defaults firefox seamonkey # no arguments mean all browsers
+#
+# @CODE
+# inherit moz
+#
+# MOZ="firefox seamonkey"
+# DEPEND=${MOZ_DEPEND}
+# RDEPEND=$(moz_rdepend ${MOZ})
+# IUSE=$(moz_iuse ${MOZ})
+# REQUIRED_USE=$(moz_required_use ${MOZ})
+#
+# src_unpack() {
+# moz_unpack
+# }
+#
+# src_install() {
+# default
+# moz_install
+# }
+
+case ${EAPI:-0} in
+[0-5])
+ die "EAPI ${EAPI} not supported by ${ECLASS}";;
+esac
+
+# @FUNCTION: moz_defaults
+# @USAGE: [<browser>] [<browser>] [...]
+# @DESCRIPTION:
+# This is just a convenience wrapper for moz_variables [arguments]; moz_phases
+moz_defaults() {
+ moz_variables "${@}"
+ moz_phases
+}
+
+# @FUNCTION: moz_variables
+# @USAGE: [<browser>] [<browser>] [...]
+# @DESCRIPTION:
+# Sets the variables DEPEND, RDEPEND, IUSE, REQUIRED_USE for browsers.
+# browser is firefox or seamonkey and implies source or binary version.
+# If no browser is specified, all are assumed.
+moz_variables() {
+ DEPEND=${MOZ_DEPEND}
+ RDEPEND=$(moz_rdepend "${@}")
+ IUSE=$(moz_iuse "${@}")
+ REQUIRED_USE=$(moz_required_use "${@}")
+}
+
+# @FUNCTION: moz_phases
+# @USAGE: [<browser>] [<browser>] [...]
+# @DESCRIPTION:
+# Defines src_unpack and src_install to call only moz_unpack and moz_install
+moz_phases() {
+src_unpack() {
+moz_unpack
+}
+src_install() {
+default
+moz_install
+}
+}
+
+# @ECLASS-VARIABLE: MOZ_DEPEND
+# @DESCRIPTION:
+# This is an eclass-generated depend expression needed for moz_unpack to work
+MOZ_DEPEND='app-arch/unzip'
+
+# @FUNCTION: moz_rdepend
+# @USAGE: [<browser>] [<browser>] [...]
+# @DESCRIPTION:
+# Outputs RDEPEND expression appropriate for browsers.
+# browser is firefox or seamonkey and implies source or binary version.
+# If no browser is specified, all are assumed.
+moz_rdepend() {
+ local rdep i
+ [ ${#} -ne 0 ] || set -- "firefox seamonkey"
+ rdep=
+ case "${*}" in
+ *firefox*)
+ rdep="firefox? ( www-client/firefox )
+firefox-bin? ( www-client/firefox-bin )";;
+ esac
+ case "${*}" in
+ *seamonkey*)
+ rdep=${rdep}${rdep:+'
+'}"seamonkey? ( www-client/seamonkey )
+seamonkey-bin? ( www-client/seamonkey-bin )";;
+ esac
+ [ -n "${rdep}" ] || die "moz_rdepend must be called with \"firefox\" or \"seamonkey\""
+ echo "|| ( ${rdep} )"
+}
+
+# @FUNCTION: moz_iuse
+# @USAGE: [<browser>] [<browser>] [...]
+# @DESCRIPTION:
+# Outputs IUSE expression appropriate for browsers.
+# browser is firefox or seamonkey and implies source or binary version.
+# If no browser is specified, all are assumed.
+moz_iuse() {
+ local iuse i
+ [ ${#} -ne 0 ] || set -- "firefox seamonkey"
+ iuse=
+ case "${*}" in
+ *firefox*)
+ iuse="firefox firefox-bin";;
+ esac
+ case "${*}" in
+ *seamonkey*)
+ iuse="${iuse}${iuse:+ }seamonkey seamonkey-bin";;
+ esac
+ [ -n "${iuse}" ] || die "moz_iuse must be called with \"firefox\" or \"seamonkey\""
+ echo "${iuse}"
+}
+
+# @FUNCTION: moz_required_use
+# @USAGE: [<browser>] [<browser>] [...]
+# @DESCRIPTION:
+# Outputs REQUIRED_USE expression appropriate for browsers.
+# browser is firefox or seamonkey and implies source or binary version.
+# If no browser is specified, all are assumed.
+moz_required_use() {
+ echo "|| ( $(moz_iuse "$@") )"
+}
+
+# @FUNCTION: moz_unpack
+# @USAGE: <file> <file> [...]
+# @DESCRIPTION:
+# Unpack xpi files. If no file is specified, ${A} is used.
+moz_unpack() {
+ local xpi srcdir xpiname
+
+ [ ${#} -ne 0 ] || set -- ${A}
+ test -d "${S}" || mkdir "${S}" || die "cannot create ${S}"
+ for xpi
+ do einfo "Unpacking ${xpi} to ${S}"
+ xpiname=${xpi%.*}
+ xpiname=${xpiname##*/}
+
+ case ${xpi} in
+ ./*|/*)
+ srcdir=;;
+ *)
+ srcdir="${DISTDIR}/";;
+ esac
+
+ test -f "${srcdir}${xpi}" || die "${xpi} does not exist or is no file"
+
+ case ${xpi##*.} in
+ ZIP|zip|jar|xpi)
+ mkdir -- "${S}/${xpiname}" && \
+ cd -- "${S}/${xpiname}" && \
+ unzip -qo -- "${srcdir}${xpi}" \
+ || die "failed to unpack ${xpi}"
+ chmod -R a+rX,u+w,go-w -- "${S}/${xpiname}";;
+ *)
+ einfo "unpack ${xpi}: file format not recognized. Ignoring.";;
+ esac
+ done
+}
+
+# @FUNCTION: moz_install_to_dir
+# @USAGE: <extension-directory> <dir> <dir> [...]
+# @DESCRIPTION:
+# Installs dirs into a subdirectory (id) of extension-directory,
+# the name of the id being determined from ${dir}/install.rdf
+# Arguments which are not directories are silently ignored.
+# If arguments are specified, they must contain at least one directory.
+# If no argument is specified, all directories from "${S}" are considered.
+moz_install_to_dir() {
+ local sub dest i s have
+ [ ${#} -ne 0 ] || die "${FUNCNAME} needs at least one argument"
+ dest=${1}
+ shift
+ [ ${#} -gt 0 ] || set -- "${S}"/*
+ s='{ /\<\(em:\)*id\>/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }'
+ have=false
+ for i
+ do [ -n "${i}" ] && test -d "${i}" || continue
+ have=:
+ test -r "${i}"/install.rdf && \
+ sub=$(sed -n -e '/install-manifest/,$ '"${s}" "${i}"/install.rdf) \
+ && [ -n "${sub}" ] || die 'failed to determine id of ${i}'
+ sub=${dest%/}/${sub}
+ dodir "${sub}" || die "failed to create ${sub}"
+ cp -RPl -- "${i}"/* "${ED}${sub}" || {
+ insinto "${sub}" && doins -r "${x}"/*
+ } || die "failed to install extension ${i}"
+ done
+ ${have} || die "no directory found in argument list"
+}
+
+# @FUNCTION: moz_install_for_browser
+# @USAGE: <browser> <dir> <dir> [...]
+# @DESCRIPTION:
+# Installs dirs for browser (firefox firefox-bin seamonkey seamonkey-bin)
+# Arguments which are not directories are silently ignored.
+# If arguments are specified, they must contain at least one directory.
+# If no argument is specified, all directories from "${S}" are considered.
+moz_install_for_browser() {
+ local dest firefox seamonkey
+ [ ${#} -ne 0 ] || die "${FUNCNAME} needs at least one argument"
+ firefox="firefox/browser/extensions"
+ seamonkey="seamonkey/extensions"
+ case ${1} in
+ firefox)
+ dest="/usr/$(get_libdir)/${firefox}";;
+ firefox-bin)
+ dest="/opt/${firefox}";;
+ seamonkey)
+ dest="/usr/$(get_libdir)/${seamonkey}";;
+ seamonkey-bin)
+ dest="/opt/${seamonkey}";;
+ *)
+ die "unknown browser specified";;
+ esac
+ shift
+ moz_install_to_dir "${dest}" "${@}"
+}
+
+# @FUNCTION: moz_install
+# @USAGE: <dir> <dir> [...]
+# @DESCRIPTION:
+# Installs dirs into appropriate destinations, depending on USE.
+# Arguments which are not directories are silently ignored.
+# If arguments are specified, they must contain at least one directory.
+# If no argument is specified, all directories from "${S}" are considered.
+moz_install() {
+ local i
+ for i in firefox firefox-bin seamonkey seamonkey-bin
+ do if in_iuse "${i}" && use "${i}"
+ then moz_install_for_browser "${i}" "${@}"
+ fi
+ done
+}