summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass')
-rw-r--r--eclass/bash-completion-r1.eclass25
-rw-r--r--eclass/mv_mozextension-r1.eclass248
-rw-r--r--eclass/mv_mozextension.eclass154
-rw-r--r--eclass/readme.gentoo.eclass58
-rw-r--r--eclass/systemd.eclass43
5 files changed, 374 insertions, 154 deletions
diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-completion-r1.eclass
new file mode 100644
index 00000000..41a50065
--- /dev/null
+++ b/eclass/bash-completion-r1.eclass
@@ -0,0 +1,25 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# Temporary hack until gentoo fixes EAPI 6 support for bash-completion-r1.eclass
+
+inherit toolchain-funcs
+
+_bash-completion-r1_get_bashdir() {
+ if $(tc-getPKG_CONFIG) --exists bash-completion &>/dev/null; then
+ local path="$($(tc-getPKG_CONFIG) --variable=$1 bash-completion)"
+ echo "${path#${EPREFIX}}"
+ else
+ echo $2
+ fi
+}
+
+_bash-completion-r1_get_bashcompdir() {
+ _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions
+}
+
+dobashcomp() (
+ insinto "$(_bash-completion-r1_get_bashcompdir)"
+ doins "${@}"
+)
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
+}
diff --git a/eclass/mv_mozextension.eclass b/eclass/mv_mozextension.eclass
deleted file mode 100644
index 7d3ab08d..00000000
--- a/eclass/mv_mozextension.eclass
+++ /dev/null
@@ -1,154 +0,0 @@
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-# @ECLASS: mv_mozextension.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.
-# 1. It has some compatibility fixes in xpi_install/xpi_unpack.
-# 2. A default src_unpack function is defined; set FILENAME to the archive name.
-# If FILENAME is unset or empty, the last part of the last SRC_URI is used.
-# 3. Default functions for installation for all mozilla type browsers.
-
-# @ECLASS-VARIABLE: MV_MOZ_MOZILLAS
-# @DESCRIPTION:
-# If this variables is set to the empty value, no default install functions
-# are defined. Otherwise, the value of this variable should be
-# "firefox seamonkey" (default)
-# or a subset of these.
-# The eclass will then install the extension for all these mozillas,
-# set corresponding dependencies and print corresponding messages.
-: ${MV_MOZ_MOZILLAS=firefox seamonkey}
-
-inherit eutils multilib
-
-case ${EAPI:-0} in
-[01234])
- die "EAPI ${EAPI} no longer supported by ${ECLASS}";;
-esac
-
-MV_MOZ_IUSE=
-RDEPEND='|| ('
-case ${MV_MOZ_MOZILLAS} in
-*fire*)
- MV_MOZ_IUSE="${MV_MOZ_IUSE}${MV_MOZ_IUSE:+ }firefox firefox-bin"
- RDEPEND="${RDEPEND}
- firefox? ( >=www-client/firefox-21 )
- firefox-bin? ( >=www-client/firefox-bin-21 )"
-esac
-case ${MV_MOZ_MOZILLAS} in
-*sea*)
- MV_MOZ_IUSE="${MV_MOZ_IUSE}${MV_MOZ_IUSE:+ }seamonkey seamonkey-bin"
- RDEPEND="${RDEPEND}
- seamonkey? ( www-client/seamonkey )
- seamonkey-bin? ( www-client/seamonkey-bin )"
-esac
-RDEPEND="${RDEPEND} )"
-IUSE=${MV_MOZ_IUSE}
-REQUIRED_USE="|| ( ${MV_MOZ_IUSE} )"
-
-DEPEND='app-arch/unzip'
-
-mv_mozextension_src_unpack() {
- local i
- if [ -z "${FILENAME}" ]
- then for i in ${SRC_URI}
- do FILENAME=${i##*/}
- done
- fi
- xpi_unpack "${FILENAME}"
-}
-
-mv_mozextension_src_prepare() {
- epatch_user
-}
-
-EXPORT_FUNCTIONS src_unpack src_prepare
-
-mv_mozextension_src_install() {
- local b e
- b="${EPREFIX}/usr/$(get_libdir)"
- e="${EPREFIX}/opt"
- mv_mozextension_install firefox "${b}/firefox/browser/extensions"
- mv_mozextension_install firefox-bin "${e}/firefox/browser/extensions"
- mv_mozextension_install seamonkey "${b}/seamonkey/extensions"
- mv_mozextension_install seamonkey-bin "${e}/seamonkey/extensions"
-}
-
-[ -z "${MV_MOZ_MOZILLAS}" ] || EXPORT_FUNCTIONS src_install
-
-xpi_unpack() {
- local xpi srcdir u
-
- # Not gonna use ${A} as we are looking for a specific option being passed to function
- # You must specify which xpi to use
- [ ${#} -eq 0 ] && die \
- "Nothing passed to the ${FUNCNAME} command. Please pass which xpi to unpack"
-
- test -d "${S}" || mkdir "${S}" || die
- for xpi
- do einfo "Unpacking ${xpi} to ${S}"
- xpiname=${xpi%.*}
- xpiname=${xpiname##*/}
-
- case ${xpi} in
- ./*|/*)
- srcdir=;;
- *)
- srcdir="${DISTDIR}/";;
- esac
-
- test -s "${srcdir}${xpi}" || die "${xpi} does not exist"
-
- 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
-}
-
-xpi_install() {
- local d x
-
- # You must tell xpi_install which dir to use
- [ ${#} -eq 1 ] || die "${FUNCNAME} takes exactly one argument. Please specify the directory"
-
- x=${1}
- # determine id for extension
- d='{ /\<\(em:\)*id\>/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }'
- d=$(sed -n -e '/install-manifest/,$ '"${d}" "${x}"/install.rdf) \
- && [ -n "${d}" ] || die 'failed to determine extension id'
- : ${MOZILLA_EXTENSIONS_DIRECTORY:="${MOZILLA_FIVE_HOME}/extensions"}
- d="${MOZILLA_EXTENSIONS_DIRECTORY}/${d}"
- test -d "${D}${d}" || dodir "${d}" || die "failed to create ${d}"
- cp -RPl -- "${x}"/* "${D}${d}" || {
- ewarn 'Failed to hardlink extension. Falling back to USE=copy-extensions'
- insinto "${d}" && doins -r "${x}"/*
- } || die 'failed to copy extension'
-}
-
-# This function is called by mv_mozextension_src_install
-# and should be overridden if the paths do not match:
-# It just should call xpi_install with the correct argument(s)
-xpi_install_dirs() {
- local d
- for d in "${S}"/*
- do [ -n "${d}" ] && test -d "${d}" && xpi_install "${d}"
- done
-}
-
-mv_mozextension_install() {
- local MOZILLA_EXTENSIONS_DIRECTORY
- has "${1}" ${MV_MOZ_IUSE} && use "${1}" || return 0
- MOZILLA_EXTENSIONS_DIRECTORY=${2}
- xpi_install_dirs
-}
diff --git a/eclass/readme.gentoo.eclass b/eclass/readme.gentoo.eclass
new file mode 100644
index 00000000..ceafe010
--- /dev/null
+++ b/eclass/readme.gentoo.eclass
@@ -0,0 +1,58 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# Temporary hack until gentoo fixes EAPI 6 support for readme.gentoo.eclass
+
+if [[ -z ${_README_GENTOO_ECLASS} ]]; then
+_README_GENTOO_ECLASS=1
+
+case "${EAPI:-0}" in
+ [0-3])
+ die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}";;
+ [45])
+EXPORT_FUNCTIONS src_install pkg_postinst
+readme.gentoo_src_install() {
+ default
+ readme.gentoo_create_doc
+}
+readme.gentoo_pkg_postinst() {
+ readme.gentoo_print_elog
+};;
+esac
+
+: ${README_GENTOO_SUFFIX:=""}
+
+readme.gentoo_create_doc() {
+ if [ -n "${DOC_CONTENTS}" ]
+ then if [ -n "${DISABLE_AUTOFORMATTING}" ]
+ then echo "${DOC_CONTENTS}" > "${T}"/README.gentoo
+ else (
+ set -f
+ echo -e ${DOC_CONTENTS} | fold -s -w 70 \
+ | sed 's/[[:space:]]*$//' > "${T}"/README.gentoo
+ )
+ fi
+ elif [ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]
+ then cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo || die
+ elif [ -f "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" ]
+ then cp "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" "${T}"/README.gentoo || die
+ else die "You are not specifying README.gentoo contents!"
+ fi
+ dodoc "${T}"/README.gentoo
+ README_GENTOO_DOC_VALUE=$(< "${T}/README.gentoo")
+}
+
+readme.gentoo_print_elog() {
+ if [ -z "${README_GENTOO_DOC_VALUE}" ]
+ then die "readme.gentoo_print_elog invoked without matching readme.gentoo_create_doc call!"
+ elif ! [ -n "${REPLACING_VERSIONS}" ] || [ -n "${FORCE_PRINT_ELOG}" ]
+ then echo -e "${README_GENTOO_DOC_VALUE}" | while read -r ELINE; do elog "${ELINE}"; done
+ elog ""
+ elog "(Note: Above message is only printed the first time package is"
+ elog "installed. Please look at ${EPREFIX}/usr/share/doc/${PF}/README.gentoo*"
+ elog "for future reference)"
+ fi
+}
+
+fi
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
new file mode 100644
index 00000000..36806a08
--- /dev/null
+++ b/eclass/systemd.eclass
@@ -0,0 +1,43 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# Temporary hack until gentoo fixes EAPI 6 support for systemd.eclass
+
+inherit toolchain-funcs
+
+DEPEND="virtual/pkgconfig"
+
+_systemd_get_unitdir() {
+ if $(tc-getPKG_CONFIG) --exists systemd; then
+ echo "$($(tc-getPKG_CONFIG) --variable=systemdsystemunitdir systemd)"
+ else
+ echo /usr/lib/systemd/system
+ fi
+}
+
+systemd_get_unitdir() {
+ has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
+ echo "${EPREFIX}$(_systemd_get_unitdir)"
+}
+
+systemd_dounit() (
+ insinto "$(_systemd_get_unitdir)"
+ doins "${@}"
+)
+
+systemd_dotmpfilesd() {
+ for f; do
+ [[ ${f} == *.conf ]] \
+ || die 'tmpfiles.d files need to have .conf suffix.'
+ done
+ (
+ insinto /usr/lib/tmpfiles.d/
+ doins "${@}"
+ )
+}
+
+systemd_with_unitdir() {
+ local optname=${1:-systemdsystemunitdir}
+ echo --with-${optname}="$(systemd_get_unitdir)"
+}