Hi, Please review the attached future.eclass. Long story short, the idea is to provide some of the EAPI 6 feel to EAPI 5 ebuilds.
Quoting the beginning of the DESCRIPTION: # This eclass contains backports of functions that were accepted # by the Council for the EAPI following the EAPI used by ebuild, # and can be implemented in pure shell script. # # The goals of the eclass are to: # 1. provide wider testing of Portage implementations of the next EAPI # functions, # 2. allows developer to use some of the features of the next EAPI # before it is approved production-ready and implemented in Portage # for long enough, # 3. improve EAPI migration time through allowing some of the ebuild # updates earlier, # 4. reduce the necessity of inheriting large, complex and frequently # changing eclasses whenever possible. and the feature list: # Currently implemented EAPI 6 features for EAPI 5: # 1. get_libdir() #463586, simpler than in multilib.eclass; # 2. einstalldocs() #459862, does not use dohtml as eutils.eclass does; # 3. eapply() #463768; # 4. eapply_user() #475288; # 5. new default src_prepare() & src_install() exported; # 6. einstall() is banned #524112 [may be non-portable]; # 7. dohtml() is deprecated #520546 [may be non-portable]. -- Best regards, Michał Górny
# Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: future.eclass # @MAINTAINER: # [email protected] # @BLURB: backports of functions accepted for the next EAPI # @DESCRIPTION: # This eclass contains backports of functions that were accepted # by the Council for the EAPI following the EAPI used by ebuild, # and can be implemented in pure shell script. # # The goals of the eclass are to: # 1. provide wider testing of Portage implementations of the next EAPI # functions, # 2. allows developer to use some of the features of the next EAPI # before it is approved production-ready and implemented in Portage # for long enough, # 3. improve EAPI migration time through allowing some of the ebuild # updates earlier, # 4. reduce the necessity of inheriting large, complex and frequently # changing eclasses whenever possible. # # Please note that the eclass is meant to support the newest EAPI only. # At the time, this means that EAPI=5 ebuilds will get some EAPI=6 # features through it but EAPI=4 ebuilds are supposed to use EAPI=5 # directly. # # If a function declared in the next EAPI collides with eclass-defined # function (e.g. get_libdir() in EAPI 6 and multilib.eclass), # the future.eclass version is used whenever it is inherited later. # Otherwise, the implementation can be accessed using 'future_' prefix. # It is generally recommended to inherit future after those other # eclasses, or not inherit those eclasses at all. # # Note to future maintainers: please don't add support for new EAPIs # before the contents of a subsequent EAPI are approved by the Council # and implemented in Portage. # # Currently implemented EAPI 6 features for EAPI 5: # 1. get_libdir() #463586, simpler than in multilib.eclass; # 2. einstalldocs() #459862, does not use dohtml as eutils.eclass does; # 3. eapply() #463768; # 4. eapply_user() #475288; # 5. new default src_prepare() & src_install() exported; # 6. einstall() is banned #524112 [may be non-portable]; # 7. dohtml() is deprecated #520546 [may be non-portable]. if [[ -z ${_FUTURE_ECLASS} ]]; then case "${EAPI:-0}" in 5) ;; *) die "EAPI ${EAPI:-0} is not supported by future.eclass.";; esac fi # (run outside the guard for expectable behavior w/ indirect inherits) # multilib.eclass collisions get_libdir() { future_get_libdir "${@}"; } # eutils.eclass collisions einstalldocs() { future_einstalldocs "${@}"; } EXPORT_FUNCTIONS src_prepare src_install if [[ -z ${_FUTURE_ECLASS} ]]; then # 1. NEW FUNCTIONS # @FUNCTION: get_libdir # @RETURN: the libdir for the selected ABI # @DESCRIPTION: # Return the proper libdir for the selected ABI, fallback to 'lib'. # # The implementation is based on the implementation used in econf PMS # function. However, this one returns 'lib' whenever the econf # implementation would not pass --libdir. # # Note: if multilib.eclass is inherited after future.eclass, # the implementation can be accessed as future_get_libdir. future_get_libdir() { local libdir_var="LIBDIR_${ABI}" local libdir="lib" [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var} echo "${libdir}" } # @FUNCTION: einstalldocs # @DESCRIPTION: # Install documentation using DOCS and HTML_DOCS. # # If DOCS is declared and non-empty, all files and directories listed # in it are installed. The files must exist, otherwise the function # will fail. # # If DOCS is not declared, the files matching patterns given # in the default EAPI implementation of src_install will be installed. # If this is undesired, DOCS can be set to empty value to prevent any # documentation from being installed. # # If HTML_DOCS is declared and non-empty, all files and/or directories # listed in it are installed in the 'html' subdirectory (using dodoc). # # Both DOCS and HTML_DOCS can either be an array or a whitespace- # separated list. Whenever directories are allowed, '<directory>/.' may # be specified in order to install all files within the directory # without creating a sub-directory in docdir. # # Passing additional options to dodoc is not supported. If you need # such a thing, you need to call those helpers explicitly. # # Note: if eutils.eclass is inherited after future.eclass, # the implementation can be accessed as future_einstalldocs. future_einstalldocs() { debug-print-function ${FUNCNAME} "${@}" ( docinto . if ! declare -p DOCS &>/dev/null ; then local d for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \ THANKS BUGS FAQ CREDITS CHANGELOG ; do [[ -s ${d} ]] && dodoc "${d}" done elif [[ $(declare -p DOCS) == "declare -a"* ]] ; then [[ ${DOCS[@]} ]] && dodoc -r "${DOCS[@]}" else [[ ${DOCS} ]] && dodoc -r ${DOCS} fi ) ( docinto html if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]] ; then [[ ${HTML_DOCS[@]} ]] && dodoc -r "${HTML_DOCS[@]}" else [[ ${HTML_DOCS} ]] && dodoc -r ${HTML_DOCS} fi ) return 0 } # @FUNCTION: eapply # @USAGE: [<patch-options>... [--]] <file|dir>... # @DESCRIPTION: # Apply the specified patches to the files in the current directory. # Files listed are applied independently of the name. If directories # are listed, all *.diff & *.patch directly inside the directory are # applied. It is an error to specify a directory with no matching files. # # If necessary, additional 'patch' command options can be passed before # the path list. Each option parameter must start with '-' (i.e. long # options that require a value need to passes as e.g. --foo=bar), # and '--' can be used to terminate the option list. # # The command defaults to applying patches with -p1. If another # stripping value is necessary, it should be passed as patch option. eapply() { _eapply_patch() { local f=${1} local prefix=${2} started_applying=1 ebegin "${prefix:-Applying }${f##*/}" # -p1 as a sane default # -f to avoid interactivity # -s to silence progress output patch -p1 -f -s "${patch_options[@]}" < "${f}" if ! eend ${?}; then die "patch -p1 ${patch_options[*]} failed with ${f}" fi } local f patch_options=() failed started_applying options_terminated for f; do if [[ ${f} == -* && -z ${options_terminated} ]]; then if [[ -n ${started_applying} ]]; then die "eapply: options need to be specified before files" fi if [[ ${f} == -- ]]; then options_terminated=1 else patch_options+=( ${f} ) fi elif [[ -d ${f} ]]; then _eapply_get_files() { local LC_ALL=POSIX local prev_shopt=$(shopt -p nullglob) shopt -s nullglob files=( "${f}"/*.{patch,diff} ) ${prev_shopt} } local files _eapply_get_files [[ -z ${files[@]} ]] && die "No *.{patch,diff} files in directory ${f}" einfo "Applying patches from ${f} ..." local f2 for f2 in "${files[@]}"; do _eapply_patch "${f2}" ' ' done else _eapply_patch "${f}" fi done return 0 } # @FUNCTION: eapply_user # @DESCRIPTION: # Apply the user patches from standard Portage locations. The patches # are applied using eapply functions with standard patch options. eapply_user() { local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches local d applied # possibilities: # 1. ${CATEGORY}/${P}-${PR} (note: -r0 desired to avoid applying # ${P} twice) # 2. ${CATEGORY}/${P} # 3. ${CATEGORY}/${PN} # all of the above may be optionally followed by a slot for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT%/*}}; do if [[ -d ${d} ]]; then eapply "${d}" applied=1 fi done [[ -n ${applied} ]] && ewarn "User patches applied." } # 2. UPDATED DEFAULT PHASE FUNCTIONS # @FUNCTION: future_src_prepare # @DESCRIPTION: # src_prepare() implementation matching the default for EAPI 6. # Applies patches from PATCHES array or whitespace-separated list, # and user patches afterwards. future_src_prepare() { if [[ $(declare -p PATCHES) == "declare -a"* ]]; then eapply "${PATCHES[@]}" elif [[ -n ${PATCHES} ]]; then eapply ${PATCHES} fi eapply_user } # @FUNCTION: future_src_install # @DESCRIPTION: # src_install() implementation matching the default for EAPI 6. # Runs emake DESTDIR=${D} install as usual, and uses future_einstalldocs # to install the documentation afterwards. future_src_install() { if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then emake DESTDIR="${D}" install fi future_einstalldocs } # 3. BANNED COMMANDS # @FUNCTION: einstall # @DESCRIPTION: # Force termination due to einstall being banned. einstall() { die "einstall is banned in EAPI 6+ (and therefore with future.eclass)" } # 4. DEPRECATED COMMANDS # @FUNCTION: __future_copy_functions # @INTERNAL # @DESCRIPTION: # Create local __future_old_<function> aliases for original EAPI # functions. __future_copy_functions() { local f func for f in dohtml; do case "$(type -t "${f}")" in function) func=$(declare -f "${f}") eval "__future_old_${f}${func#${f}}" ;; file) func=$(type -P "${f}") eval "__future_old_${f}() { \"${func}\" \"\${@}\"; }" ;; esac done } __future_copy_functions if declare -f __future_old_dohtml &>/dev/null; then dohtml() { if [[ -z ${__future_dohtml_warned+1} ]]; then __future_dohtml_warned=1 ewarn "dohtml is deprecated in EAPI 6 (and therefore with future.eclass" fi __future_old_dohtml "${@}" } fi _FUTURE_ECLASS=1 fi
signature.asc
Description: PGP signature
