From d934827bf44b7cfcf6711964418148fa60877668 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 25 Nov 2020 22:39:15 +0000 Subject: gentoo resync : 25.11.2020 --- eclass/Manifest.gz | Bin 36264 -> 36956 bytes eclass/autotools-multilib.eclass | 1 + eclass/autotools-utils.eclass | 3 +- eclass/base.eclass | 3 +- eclass/cargo.eclass | 30 ++- eclass/darcs.eclass | 3 +- eclass/depend.apache.eclass | 6 +- eclass/dune.eclass | 8 +- eclass/eapi8-dosym.eclass | 108 ++++++++ eclass/epatch.eclass | 3 +- eclass/fdo-mime.eclass | 6 +- eclass/games.eclass | 3 +- eclass/kde.org.eclass | 6 +- eclass/kernel-2.eclass | 44 ++-- eclass/kernel-build.eclass | 32 +++ eclass/leechcraft.eclass | 60 ----- eclass/llvm.org.eclass | 138 +++++----- eclass/ltprune.eclass | 1 + eclass/lua-single.eclass | 540 +++++++++++++++++++++++++++++++++++++++ eclass/lua-utils.eclass | 462 +++++++++++++++++++++++++++++++++ eclass/lua.eclass | 355 +------------------------ eclass/mono.eclass | 3 +- eclass/mozcoreconf-v5.eclass | 3 +- eclass/mozcoreconf-v6.eclass | 3 +- eclass/multilib.eclass | 5 +- eclass/nvidia-driver.eclass | 4 +- eclass/opam.eclass | 22 +- eclass/pam.eclass | 6 +- eclass/qt5-build.eclass | 16 +- eclass/ros-catkin.eclass | 4 +- eclass/ruby-utils.eclass | 4 +- eclass/selinux-policy-2.eclass | 59 ++--- eclass/tests/eapi8-dosym.sh | 78 ++++++ eclass/toolchain.eclass | 19 +- eclass/user.eclass | 14 + eclass/verify-sig.eclass | 271 ++++++++++++++++++++ eclass/versionator.eclass | 3 +- eclass/virtualx.eclass | 2 +- eclass/xorg-3.eclass | 30 +-- 39 files changed, 1736 insertions(+), 622 deletions(-) create mode 100644 eclass/eapi8-dosym.eclass delete mode 100644 eclass/leechcraft.eclass create mode 100644 eclass/lua-single.eclass create mode 100644 eclass/lua-utils.eclass create mode 100755 eclass/tests/eapi8-dosym.sh create mode 100644 eclass/verify-sig.eclass (limited to 'eclass') diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz index 512e0e5c825d..12b73dbf0964 100644 Binary files a/eclass/Manifest.gz and b/eclass/Manifest.gz differ diff --git a/eclass/autotools-multilib.eclass b/eclass/autotools-multilib.eclass index a357760017f4..58bf285e0e91 100644 --- a/eclass/autotools-multilib.eclass +++ b/eclass/autotools-multilib.eclass @@ -8,6 +8,7 @@ # Author: Michał Górny # @SUPPORTED_EAPIS: 4 5 # @BLURB: autotools-utils wrapper for multilib builds +# @DEPRECATED: multilib-minimal # @DESCRIPTION: # The autotools-multilib.eclass provides a glue between # autotools-utils.eclass(5) and multilib-minimal.eclass(5), aiming diff --git a/eclass/autotools-utils.eclass b/eclass/autotools-utils.eclass index 06c79fd652a6..3fcaa79f80ab 100644 --- a/eclass/autotools-utils.eclass +++ b/eclass/autotools-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2018 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: autotools-utils.eclass @@ -7,6 +7,7 @@ # Michał Górny # @SUPPORTED_EAPIS: 4 5 # @BLURB: common ebuild functions for autotools-based packages +# @DEPRECATED: out-of-source # @DESCRIPTION: # autotools-utils.eclass is autotools.eclass(5) and base.eclass(5) wrapper # providing all inherited features along with econf arguments as Bash array, diff --git a/eclass/base.eclass b/eclass/base.eclass index 76eee973dee5..0f9a2e576b78 100644 --- a/eclass/base.eclass +++ b/eclass/base.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2017 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # DEPRECATED @@ -24,6 +24,7 @@ # Original author: Dan Armak # @SUPPORTED_EAPIS: 0 1 2 3 4 5 # @BLURB: The base eclass defines some default functions and variables. +# @DEPRECATED: none # @DESCRIPTION: # The base eclass defines some default functions and variables. diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index e6fec844d274..1042f31e7e65 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -15,20 +15,42 @@ _CARGO_ECLASS=1 # we need this for 'cargo vendor' subcommand and net.offline config knob RUST_DEPEND=">=virtual/rust-1.37.0" -case ${EAPI} in - 7) BDEPEND="${RUST_DEPEND}";; - *) die "EAPI=${EAPI:-0} is not supported" ;; +case "${EAPI:-0}" in + 0|1|2|3|4|5|6) + die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" + ;; + 7) + ;; + *) + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" + ;; esac inherit multiprocessing toolchain-funcs -EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install src_test +if [[ ! ${CARGO_OPTIONAL} ]]; then + BDEPEND="${RUST_DEPEND}" + EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install src_test +fi IUSE="${IUSE} debug" ECARGO_HOME="${WORKDIR}/cargo_home" ECARGO_VENDOR="${ECARGO_HOME}/gentoo" +# @ECLASS-VARIABLE: CARGO_OPTIONAL +# @DEFAULT_UNSET +# @PRE_INHERIT +# @DESCRIPTION: +# If set to a non-null value, before inherit cargo part of the ebuild will +# be considered optional. No dependencies will be added and no phase +# functions will be exported. +# +# If you enable CARGO_OPTIONAL, you have to set BDEPEND on virtual/rust +# for your package and call at least cargo_gen_config manually before using +# other src_ functions of this eclass. +# note that cargo_gen_config is automatically called by cargo_src_unpack. + # @VARIABLE: myfeatures # @DEFAULT_UNSET # @DESCRIPTION: diff --git a/eclass/darcs.eclass b/eclass/darcs.eclass index 1c1a051f8c1c..12e7289cc7d0 100644 --- a/eclass/darcs.eclass +++ b/eclass/darcs.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2019 Gentoo Authors +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: darcs.eclass @@ -11,6 +11,7 @@ # Andres Loeh (darcs.eclass author) # Alexander Vershilov (various contributions) # @BLURB: This eclass provides functions for fetch and unpack darcs repositories +# @DEPRECATED: none # @DESCRIPTION: # This eclass provides the generic darcs fetching functions. # diff --git a/eclass/depend.apache.eclass b/eclass/depend.apache.eclass index 79bfdcc493f7..5aa552542680 100644 --- a/eclass/depend.apache.eclass +++ b/eclass/depend.apache.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: depend.apache.eclass # @MAINTAINER: # apache-devs@gentoo.org -# @SUPPORTED_EAPIS: 0 2 3 4 5 6 +# @SUPPORTED_EAPIS: 0 2 3 4 5 6 7 # @BLURB: Functions to allow ebuilds to depend on apache # @DESCRIPTION: # This eclass handles depending on apache in a sane way and provides information @@ -44,7 +44,7 @@ case ${EAPI:-0} in 0|2|3|4|5) inherit multilib ;; - 6) + 6|7) ;; *) die "EAPI=${EAPI} is not supported by depend.apache.eclass" diff --git a/eclass/dune.eclass b/eclass/dune.eclass index 9ab6ec204c21..334fbfbf7910 100644 --- a/eclass/dune.eclass +++ b/eclass/dune.eclass @@ -4,6 +4,7 @@ # @ECLASS: dune.eclass # @MAINTAINER: # rkitover@gmail.com +# Mark Wright # @AUTHOR: # Rafael Kitover # @SUPPORTED_EAPIS: 5 6 7 @@ -25,8 +26,10 @@ esac EXPORT_FUNCTIONS src_compile src_test src_install RDEPEND=">=dev-lang/ocaml-4:=[ocamlopt?]" -DEPEND="${RDEPEND} - dev-ml/dune" +case ${EAPI:-0} in + 0|1|2|3|4|5|6) DEPEND="${RDEPEND} dev-ml/dune";; + *) BDEPEND="dev-ml/dune dev-lang/ocaml"; DEPEND="${RDEPEND}" ;; +esac dune_src_compile() { dune build @install || die @@ -47,6 +50,7 @@ dune-install() { dune install \ --prefix="${ED%/}/usr" \ --libdir="${D%/}$(ocamlc -where)" \ + --mandir="${ED%/}/usr/share/man" \ "${pkg}" || die done } diff --git a/eclass/eapi8-dosym.eclass b/eclass/eapi8-dosym.eclass new file mode 100644 index 000000000000..52f0ffe3e62b --- /dev/null +++ b/eclass/eapi8-dosym.eclass @@ -0,0 +1,108 @@ +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: eapi8-dosym.eclass +# @MAINTAINER: +# PMS team +# @AUTHOR: +# Ulrich Müller +# @SUPPORTED_EAPIS: 5 6 7 +# @BLURB: Testing implementation of EAPI 8 dosym -r option +# @DESCRIPTION: +# A stand-alone implementation of the dosym command aimed for EAPI 8. +# Intended to be used for wider testing of the proposed option and to +# allow ebuilds to switch to the new model early, with minimal change +# needed for actual EAPI 8. +# +# https://bugs.gentoo.org/708360 + +case ${EAPI} in + 5|6|7) ;; + *) die "${ECLASS}: EAPI=${EAPI:-0} not supported" ;; +esac + +# @FUNCTION: _dosym8_canonicalize +# @USAGE: +# @INTERNAL +# @DESCRIPTION: +# Transparent bash-only replacement for GNU "realpath -m -s". +# Resolve references to "/./", "/../" and remove extra "/" characters +# from , without touching any actual file. +_dosym8_canonicalize() { + local path slash i prev out IFS=/ + + path=( $1 ) + [[ $1 == /* ]] && slash=/ + + while true; do + # Find first instance of non-".." path component followed by "..", + # or as a special case, "/.." at the beginning of the path. + # Also drop empty and "." path components as we go along. + prev= + for i in ${!path[@]}; do + if [[ -z ${path[i]} || ${path[i]} == . ]]; then + unset "path[i]" + elif [[ ${path[i]} != .. ]]; then + prev=${i} + elif [[ ${prev} || ${slash} ]]; then + # Found, remove path components and reiterate + [[ ${prev} ]] && unset "path[prev]" + unset "path[i]" + continue 2 + fi + done + # No (further) instance found, so we're done + break + done + + out="${slash}${path[*]}" + echo "${out:-.}" +} + +# @FUNCTION: dosym8 +# @USAGE: [-r] +# @DESCRIPTION: +# Create a symbolic link , pointing to . If the +# directory containing the new link does not exist, create it. +# +# If called with option -r, expand relative to the apparent +# path of the directory containing . For example, "dosym8 -r +# /bin/foo /usr/bin/foo" will create a link named "../../bin/foo". +dosym8() { + local option_r + + case $1 in + -r) option_r=t; shift ;; + esac + + [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments" + + local target=$1 link=$2 + + if [[ ${option_r} ]]; then + local linkdir comp + + # Expansion makes sense only for an absolute target path + [[ ${target} == /* ]] \ + || die "${FUNCNAME}: -r specified but no absolute target path" + + target=$(_dosym8_canonicalize "${target}") + linkdir=$(_dosym8_canonicalize "/${link#/}") + linkdir=${linkdir%/*} # poor man's dirname(1) + linkdir=${linkdir:-/} # always keep the initial "/" + + local ifs_save=${IFS-$' \t\n'} IFS=/ + for comp in ${linkdir}; do + if [[ ${target%%/*} == "${comp}" ]]; then + target=${target#"${comp}"} + target=${target#/} + else + target=..${target:+/}${target} + fi + done + IFS=${ifs_save} + target=${target:-.} + fi + + dosym "${target}" "${link}" +} diff --git a/eclass/epatch.eclass b/eclass/epatch.eclass index da9364136777..fbb4f0b5bc0d 100644 --- a/eclass/epatch.eclass +++ b/eclass/epatch.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2018 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: epatch.eclass @@ -6,6 +6,7 @@ # base-system@gentoo.org # @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 # @BLURB: easy patch application functions +# @DEPRECATED: eapply from EAPI 7 # @DESCRIPTION: # An eclass providing epatch and epatch_user functions to easily apply # patches to ebuilds. Mostly superseded by eapply* in EAPI 6. diff --git a/eclass/fdo-mime.eclass b/eclass/fdo-mime.eclass index 8e51d8a69df1..3aa45919b37e 100644 --- a/eclass/fdo-mime.eclass +++ b/eclass/fdo-mime.eclass @@ -1,12 +1,16 @@ -# Copyright 1999-2017 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +# @DEAD +# No consumers left. Removal in 30 days. + # @ECLASS: fdo-mime.eclass # @MAINTAINER: # freedesktop-bugs@gentoo.org # @AUTHOR: # Original author: foser # @BLURB: Utility eclass to update the desktop mime info as laid out in the freedesktop specs & implementations +# @DEPRECATED: xdg-utils # @DESCRIPTION: # This eclass is DEPRECATED. Please use xdg-utils or xdg instead. diff --git a/eclass/games.eclass b/eclass/games.eclass index d651dc7d868a..a2a5ce066a57 100644 --- a/eclass/games.eclass +++ b/eclass/games.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2015 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: games.eclass @@ -6,6 +6,7 @@ # Games team # @SUPPORTED_EAPIS: 0 1 2 3 4 5 # @BLURB: Standardizing the install of games. +# @DEPRECATED: none # @DESCRIPTION: # This eclass makes sure that games are consistently handled in gentoo. # It installs game files by default in FHS-compatible directories diff --git a/eclass/kde.org.eclass b/eclass/kde.org.eclass index d099b128918c..b8fec445755c 100644 --- a/eclass/kde.org.eclass +++ b/eclass/kde.org.eclass @@ -128,11 +128,9 @@ _kde.org_calculate_src_uri() { kjs | \ kjsembed | \ kmediaplayer | \ - kross) - _src_uri+="portingAids/" - ;; + kross | \ kxmlrpcclient) - [[ ${PV} = 5.70.* ]] || _src_uri+="portingAids/" + _src_uri+="portingAids/" ;; esac ;; diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass index b515a3f63fc5..a5e8c31b4ae8 100644 --- a/eclass/kernel-2.eclass +++ b/eclass/kernel-2.eclass @@ -25,6 +25,13 @@ # this is useful for things like wolk. IE: # EXTRAVERSION would be something like : -wolk-4.19-r1 +# @ECLASS-VARIABLE: K_NODRYRUN +# @DEFAULT_UNSET +# @DESCRIPTION: +# if this is set then patch --dry-run will not +# be run. Certain patches will fail with this parameter +# See bug #507656 + # @ECLASS-VARIABLE: K_NOSETEXTRAVERSION # @DEFAULT_UNSET # @DESCRIPTION: @@ -1316,34 +1323,31 @@ unipatch() { if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi #################################################################### - # IMPORTANT: This is temporary code to support Linux git 3.15_rc1! # + # IMPORTANT: This code is to support kernels which cannot be # + # tested with the --dry-run parameter # # # - # The patch contains a removal of a symlink, followed by addition # - # of a file with the same name as the symlink in the same # - # location; this causes the dry-run to fail, filed bug #507656. # + # These patches contain a removal of a symlink, followed by # + # addition of a file with the same name as the symlink in the # + # same location; this causes the dry-run to fail, see bug #507656. # # # # https://bugs.gentoo.org/show_bug.cgi?id=507656 # #################################################################### - if [[ -n ${K_FROM_GIT} ]] ; then - if [[ ${KV_MAJOR} -gt 3 || ( ${KV_MAJOR} -eq 3 && ${KV_PATCH} -gt 15 ) && - ${RELEASETYPE} == -rc ]] ; then - ebegin "Applying ${i/*\//} (-p1)" - if [ $(patch -p1 --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -le 2 ]; then - eend 0 - rm ${STDERR_T} || die - break - else - eend 1 - eerror "Failed to apply patch ${i/*\//}" - eerror "Please attach ${STDERR_T} to any bug you may post." - eshopts_pop - die "Failed to apply ${i/*\//} on patch depth 1." - fi + if [[ -n ${K_NODRYRUN} ]] ; then + ebegin "Applying ${i/*\//} (-p1)" + if [ $(patch -p1 --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -le 2 ]; then + eend 0 + rm ${STDERR_T} || die + else + eend 1 + eerror "Failed to apply patch ${i/*\//}" + eerror "Please attach ${STDERR_T} to any bug you may post." + eshopts_pop + die "Failed to apply ${i/*\//} on patch depth 1." fi fi #################################################################### - while [ ${PATCH_DEPTH} -lt 5 ]; do + while [ ${PATCH_DEPTH} -lt 5 ] && [ -z ${K_NODRYRUN} ]; do echo "Attempting Dry-run:" >> ${STDERR_T} echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T} echo "=======================================================" >> ${STDERR_T} diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass index 048d0c9b016c..99279ba58a99 100644 --- a/eclass/kernel-build.eclass +++ b/eclass/kernel-build.eclass @@ -197,6 +197,38 @@ kernel-build_pkg_postinst() { savedconfig_pkg_postinst } +# @FUNCTION: kernel-build_merge_configs +# @USAGE: [distro.config...] +# @DESCRIPTION: +# Merge the config files specified as arguments (if any) into +# the '.config' file in the current directory, then merge +# any user-supplied configs from ${BROOT}/etc/kernel/config.d/*.config. +# The '.config' file must exist already and contain the base +# configuration. +kernel-build_merge_configs() { + debug-print-function ${FUNCNAME} "${@}" + + [[ -f .config ]] || die "${FUNCNAME}: .config does not exist" + has .config "${@}" && + die "${FUNCNAME}: do not specify .config as parameter" + + local shopt_save=$(shopt -p nullglob) + shopt -s nullglob + local user_configs=( "${BROOT}"/etc/kernel/config.d/*.config ) + shopt -u nullglob + + if [[ ${#user_configs[@]} -gt 0 ]]; then + elog "User config files are being applied:" + local x + for x in "${user_configs[@]}"; do + elog "- ${x}" + done + fi + + ./scripts/kconfig/merge_config.sh -m -r \ + .config "${@}" "${user_configs[@]}" || die +} + _KERNEL_BUILD_ECLASS=1 fi diff --git a/eclass/leechcraft.eclass b/eclass/leechcraft.eclass deleted file mode 100644 index c53f6712d863..000000000000 --- a/eclass/leechcraft.eclass +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 1999-2020 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 -# -# @ECLASS: leechcraft.eclass -# @MAINTAINER: -# 0xd34df00d@gmail.com -# @AUTHOR: -# 0xd34df00d@gmail.com -# NightNord@niifaq.ru -# @SUPPORTED_EAPIS: 6 7 -# @BLURB: Common functions and setup utilities for the LeechCraft app -# @DESCRIPTION: -# The leechcraft eclass contains a common set of functions and steps -# needed to build LeechCraft core or its plugins. -# -# Though this eclass seems to be small at the moment, it seems like a -# good idea to make all plugins inherit from it, since all plugins -# have mostly the same configuring/build process. -# -# Thanks for original eclass to Andrian Nord . -# -# Only EAPI >=6 is supported - -case ${EAPI:-0} in - 6) inherit cmake-utils ;; - 7) inherit cmake ;; - *) die "EAPI not supported, bug ebuild mantainer" ;; -esac - -if [[ ${PV} == 9999 ]]; then - EGIT_REPO_URI="https://github.com/0xd34df00d/leechcraft.git" - - inherit git-r3 -else - SRC_URI="https://dist.leechcraft.org/LeechCraft/${PV}/leechcraft-${PV}.tar.xz" - S="${WORKDIR}/leechcraft-${PV}" -fi - -HOMEPAGE="https://leechcraft.org/" -LICENSE="Boost-1.0" - -DEPEND=" - dev-qt/qtcore:5 - dev-qt/qtgui:5 -" -RDEPEND="${DEPEND}" - -# @ECLASS-VARIABLE: LEECHCRAFT_PLUGIN_CATEGORY -# @DEFAULT_UNSET -# @DESCRIPTION: -# Set this to the category of the plugin, if any. -: ${LEECHCRAFT_PLUGIN_CATEGORY:=} - -if [[ "${LEECHCRAFT_PLUGIN_CATEGORY}" ]]; then - CMAKE_USE_DIR="${S}"/src/plugins/${LEECHCRAFT_PLUGIN_CATEGORY}/${PN#lc-} -elif [[ ${PN} != lc-core ]]; then - CMAKE_USE_DIR="${S}"/src/plugins/${PN#lc-} -else - CMAKE_USE_DIR="${S}"/src -fi diff --git a/eclass/llvm.org.eclass b/eclass/llvm.org.eclass index 3bb0465c3773..c6f4d2a56c11 100644 --- a/eclass/llvm.org.eclass +++ b/eclass/llvm.org.eclass @@ -82,29 +82,15 @@ inherit multiprocessing # @DESCRIPTION: # List of additional components needed for tests. +# @ECLASS-VARIABLE: LLVM_MANPAGES +# @DEFAULT_UNSET +# @DESCRIPTION: +# Set to 'build', include the dependency on dev-python/sphinx to build +# the manpages. If set to 'pregenerated', fetch and install +# pregenerated manpages from the archive. -# == global scope logic == -# @FUNCTION: _llvm.org_get_archives -# @USAGE: -# @INTERNAL -# @DESCRIPTION: -# Set 'archives' array to list of unique archive filenames -# for components passed as parameters. -_llvm.org_get_archives() { - local c - archives=() - - for c; do - local cn=${c%%/*} - case ${cn} in - clang) cn=cfe;; - esac - - local a=${cn}-${PV}.src.tar.xz - has "${a}" "${archives[@]}" || archives+=( "${a}" ) - done -} +# == global scope logic == # @FUNCTION: llvm.org_set_globals # @DESCRIPTION: @@ -126,18 +112,8 @@ llvm.org_set_globals() { [[ ${PV} != ${_LLVM_MASTER_MAJOR}.* ]] && EGIT_BRANCH="release/${PV%%.*}.x" elif [[ ${_LLVM_SOURCE_TYPE} == tar ]]; then - if ver_test -ge 9.0.1_rc1; then - # 9.0.1 RCs as GitHub archive - SRC_URI+=" - https://github.com/llvm/llvm-project/archive/llvmorg-${PV/_/-}.tar.gz" - else - local a archives=() - _llvm.org_get_archives "${LLVM_COMPONENTS[@]}" - for a in "${archives[@]}"; do - SRC_URI+=" - https://releases.llvm.org/${PV}/${a}" - done - fi + SRC_URI+=" + https://github.com/llvm/llvm-project/archive/llvmorg-${PV/_/-}.tar.gz" else die "Invalid _LLVM_SOURCE_TYPE: ${LLVM_SOURCE_TYPE}" fi @@ -147,28 +123,28 @@ llvm.org_set_globals() { if [[ -n ${LLVM_TEST_COMPONENTS+1} ]]; then IUSE+=" test" RESTRICT+=" !test? ( test )" - - if [[ ${_LLVM_SOURCE_TYPE} == tar ]]; then - if ver_test -ge 9.0.1_rc1; then - # everything already fetched - : - else - # split 9.0.0 release and older - SRC_URI+=" - test? (" - - _llvm.org_get_archives "${LLVM_TEST_COMPONENTS[@]}" - for a in "${archives[@]}"; do - SRC_URI+=" - https://releases.llvm.org/${PV}/${a}" - done - - SRC_URI+=" - )" - fi - fi fi + case ${LLVM_MANPAGES:-__unset__} in + __unset__) + # no manpage support + ;; + build) + IUSE+=" doc" + # NB: this is not always the correct dep but it does no harm + BDEPEND+=" dev-python/sphinx" + ;; + pregenerated) + IUSE+=" doc" + SRC_URI+=" + !doc? ( + https://dev.gentoo.org/~mgorny/dist/llvm/llvm-${PV}-manpages.tar.bz2 + )" + ;; + *) + die "Invalid LLVM_MANPAGES=${LLVM_MANPAGES}" + esac + # === useful defaults for cmake-based packages === # least intrusive of all @@ -201,30 +177,20 @@ llvm.org_src_unpack() { if [[ ${_LLVM_SOURCE_TYPE} == git ]]; then git-r3_fetch git-r3_checkout '' . '' "${components[@]}" + default_src_unpack else - if ver_test -ge 9.0.1_rc1; then - local archive=llvmorg-${PV/_/-}.tar.gz - ebegin "Unpacking from ${archive}" - tar -x -z -o --strip-components 1 \ - -f "${DISTDIR}/${archive}" \ - "${components[@]/#/llvm-project-${archive%.tar*}/}" || die - eend ${?} - else - local c archives - # TODO: optimize this - for c in "${components[@]}"; do - local top_dir=${c%%/*} - _llvm.org_get_archives "${c}" - local sub_path=${archives[0]%.tar.xz} - [[ ${c} == */* ]] && sub_path+=/${c#*/} - - ebegin "Unpacking ${sub_path} from ${archives[0]}" - mkdir -p "${top_dir}" || die - tar -C "${top_dir}" -x -J -o --strip-components 1 \ - -f "${DISTDIR}/${archives[0]}" "${sub_path}" || die - eend ${?} - done - fi + local archive=llvmorg-${PV/_/-}.tar.gz + ebegin "Unpacking from ${archive}" + tar -x -z -o --strip-components 1 \ + -f "${DISTDIR}/${archive}" \ + "${components[@]/#/llvm-project-${archive%.tar*}/}" || die + eend ${?} + + # unpack all remaining distfiles + local x + for x in ${A}; do + [[ ${x} != ${archive} ]] && unpack "${x}" + done fi } @@ -265,3 +231,23 @@ llvm.org_src_prepare() { get_lit_flags() { echo "-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}" } + +# @FUNCTION: llvm_are_manpages_built +# @DESCRIPTION: +# Return true (0) if manpages are going to be built from source, +# false (1) if preinstalled manpages will be used. +llvm_are_manpages_built() { + use doc || [[ ${LLVM_MANPAGES} == build ]] +} + +# @FUNCTION: llvm_install_manpages +# @DESCRIPTION: +# Install pregenerated manpages if available. No-op otherwise. +llvm_install_manpages() { + # install pre-generated manpages + if ! llvm_are_manpages_built; then + # (doman does not support custom paths) + insinto "/usr/lib/llvm/${SLOT}/share/man/man1" + doins "${WORKDIR}/llvm-${PV}-manpages/${LLVM_COMPONENTS[0]}"/*.1 + fi +} diff --git a/eclass/ltprune.eclass b/eclass/ltprune.eclass index 7374716e6dd2..e7d8cd2c4f92 100644 --- a/eclass/ltprune.eclass +++ b/eclass/ltprune.eclass @@ -6,6 +6,7 @@ # Michał Górny # @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 # @BLURB: Smart .la file pruning +# @DEPRECATED: none # @DESCRIPTION: # A function to locate and remove unnecessary .la files. # diff --git a/eclass/lua-single.eclass b/eclass/lua-single.eclass new file mode 100644 index 000000000000..11c2790dac29 --- /dev/null +++ b/eclass/lua-single.eclass @@ -0,0 +1,540 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: lua-single.eclass +# @MAINTAINER: +# William Hubbs +# Marek Szuba +# @AUTHOR: +# Marek Szuba +# Based on python-single-r1.eclass by Michał Górny et al. +# @SUPPORTED_EAPIS: 7 +# @BLURB: An eclass for Lua packages not installed for multiple implementations. +# @DESCRIPTION: +# An extension of lua.eclass suite for packages which don't support being +# installed for multiple Lua implementations. This mostly includes software +# embedding Lua. +# +# This eclass sets correct IUSE. It also provides LUA_DEPS +# and LUA_REQUIRED_USE that need to be added to appropriate ebuild +# metadata variables. +# +# The eclass exports LUA_SINGLE_USEDEP that is suitable for depending +# on other packages using the eclass. Dependencies on packages using +# lua.eclass should be created via lua_gen_cond_dep() function, using +# LUA_USEDEP placeholder. +# +# Please note that packages support multiple Lua implementations +# (using lua.eclass) cannot depend on packages not supporting +# them (using this eclass). +# +# Note that since this eclass always inherits lua-utils as well, in ebuilds +# using the former there is no need to explicitly inherit the latter in order +# to use helper functions such as lua_get_CFLAGS. +# +# @EXAMPLE: +# @CODE +# EAPI=7 +# +# LUA_COMPAT=( lua5-{1..3} ) +# +# inherit lua-single +# +# [...] +# +# REQUIRED_USE="${LUA_REQUIRED_USE}" +# DEPEND="${LUA_DEPS}" +# RDEPEND="${DEPEND} +# $(lua_gen_cond_dep ' +# dev-lua/foo[${LUA_USEDEP}] +# ') +# " +# BDEPEND="virtual/pkgconfig" +# +# # Only neeed if the setup phase has to do more than just call lua-single_pkg_setup +# pkg_setup() { +# lua-single_pkg_setup +# [...] +# } +# +# src_install() { +# emake LUA_VERSION="$(lua_get_version)" install +# } +# @CODE + +case ${EAPI:-0} in + 0|1|2|3|4|5|6) + die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}" + ;; + 7) + ;; + *) + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" + ;; +esac + +if [[ ! ${_LUA_SINGLE_R0} ]]; then + +if [[ ${_LUA_R0} ]]; then + die 'lua-single.eclass cannot be used with lua.eclass.' +fi + +inherit lua-utils + +fi + +EXPORT_FUNCTIONS pkg_setup + +# @ECLASS-VARIABLE: LUA_COMPAT +# @REQUIRED +# @PRE_INHERIT +# @DESCRIPTION: +# This variable contains a list of Lua implementations the package +# supports. It must be set before the `inherit' call. It has to be +# an array. +# +# Example: +# @CODE +# LUA_COMPAT=( lua5-1 lua5-2 lua5-3 ) +# @CODE +# +# Please note that you can also use bash brace expansion if you like: +# @CODE +# LUA_COMPAT=( lua5-{1..3} ) +# @CODE + +# @ECLASS-VARIABLE: LUA_COMPAT_OVERRIDE +# @USER_VARIABLE +# @DEFAULT_UNSET +# @DESCRIPTION: +# This variable can be used when working with ebuilds to override +# the in-ebuild LUA_COMPAT. It is a string listing all +# the implementations which package will be built for. It need be +# specified in the calling environment, and not in ebuilds. +# +# It should be noted that in order to preserve metadata immutability, +# LUA_COMPAT_OVERRIDE does not affect IUSE nor dependencies. +# The state of LUA_TARGETS is ignored, and all the implementations +# in LUA_COMPAT_OVERRIDE are built. Dependencies need to be satisfied +# manually. +# +# Example: +# @CODE +# LUA_COMPAT_OVERRIDE='lua5-2' emerge -1v dev-lua/foo +# @CODE + +# @ECLASS-VARIABLE: LUA_REQ_USE +# @DEFAULT_UNSET +# @PRE_INHERIT +# @DESCRIPTION: +# The list of USE flags required to be enabled on the chosen Lua +# implementations, formed as a USE-dependency string. It should be valid +# for all implementations in LUA_COMPAT, so it may be necessary to +# use USE defaults. +# This must be set before calling `inherit'. +# +# Example: +# @CODE +# LUA_REQ_USE="deprecated" +# @CODE +# +# It will cause the Lua dependencies to look like: +# @CODE +# lua_targets_luaX-Y? ( dev-lang/lua:X.Y[deprecated] ) +# @CODE + +# @ECLASS-VARIABLE: LUA_DEPS +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# This is an eclass-generated Lua dependency string for all +# implementations listed in LUA_COMPAT. +# +# Example use: +# @CODE +# RDEPEND="${LUA_DEPS} +# dev-foo/mydep" +# DEPEND="${RDEPEND}" +# @CODE +# +# Example value: +# @CODE +# lua_targets_lua5-1? ( dev-lang/lua:5.1 ) +# lua_targets_lua5-2? ( dev-lang/lua:5.2 ) +# @CODE + +# @ECLASS-VARIABLE: LUA_REQUIRED_USE +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# This is an eclass-generated required-use expression which ensures at +# least one Lua implementation has been enabled. +# +# This expression should be utilized in an ebuild by including it in +# REQUIRED_USE, optionally behind a use flag. +# +# Example use: +# @CODE +# REQUIRED_USE="lua? ( ${LUA_REQUIRED_USE} )" +# @CODE +# +# Example value: +# @CODE +# || ( lua_targets_lua5-1 lua_targets_lua5-2 ) +# @CODE + +# @ECLASS-VARIABLE: LUA_SINGLE_USEDEP +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# This is an eclass-generated USE-dependency string which can be used +# to depend on another lua-single package being built for the same +# Lua implementations. +# +# If you need to depend on a multi-impl (lua.eclass) package, use +# lua_gen_cond_dep with LUA_USEDEP placeholder instead. +# +# Example use: +# @CODE +# RDEPEND="dev-lua/foo[${LUA_SINGLE_USEDEP}]" +# @CODE +# +# Example value: +# @CODE +# lua_single_target_lua5-1(-)? +# @CODE + +# @ECLASS-VARIABLE: LUA_USEDEP +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# This is an eclass-generated USE-dependency string which can be used to +# depend on another Lua package being built for the same Lua +# implementations. +# +# Example use: +# @CODE +# RDEPEND="dev-lua/foo[${LUA_USEDEP}]" +# @CODE +# +# Example value: +# @CODE +# lua_targets_lua5-1(-)?,lua_targets_lua5-2(-)? +# @CODE + +# @FUNCTION: _lua_single_set_globals +# @INTERNAL +# @DESCRIPTION: +# Sets all the global output variables provided by this eclass. +# This function must be called once, in global scope. +_lua_single_set_globals() { + _lua_set_impls + + local flags=( "${_LUA_SUPPORTED_IMPLS[@]/#/lua_single_target_}" ) + + if [[ ${#_LUA_SUPPORTED_IMPLS[@]} -eq 1 ]]; then + # if only one implementation is supported, use IUSE defaults + # to avoid requesting the user to enable it + IUSE="+${flags[0]}" + else + IUSE="${flags[*]}" + fi + + local requse="^^ ( ${flags[*]} )" + local single_flags="${flags[@]/%/(-)?}" + local single_usedep=${single_flags// /,} + + local deps= i LUA_PKG_DEP + for i in "${_LUA_SUPPORTED_IMPLS[@]}"; do + _lua_export "${i}" LUA_PKG_DEP + deps+="lua_single_target_${i}? ( ${LUA_PKG_DEP} ) " + done + + if [[ ${LUA_DEPS+1} ]]; then + if [[ ${LUA_DEPS} != "${deps}" ]]; then + eerror "LUA_DEPS have changed between inherits (LUA_REQ_USE?)!" + eerror "Before: ${LUA_DEPS}" + eerror "Now : ${deps}" + die "LUA_DEPS integrity check failed" + fi + + # these two are formality -- they depend on LUA_COMPAT only + if [[ ${LUA_REQUIRED_USE} != ${requse} ]]; then + eerror "LUA_REQUIRED_USE have changed between inherits!" + eerror "Before: ${LUA_REQUIRED_USE}" + eerror "Now : ${requse}" + die "LUA_REQUIRED_USE integrity check failed" + fi + + if [[ ${LUA_SINGLE_USEDEP} != "${single_usedep}" ]]; then + eerror "LUA_SINGLE_USEDEP have changed between inherits!" + eerror "Before: ${LUA_SINGLE_USEDEP}" + eerror "Now : ${single_usedep}" + die "LUA_SINGLE_USEDEP integrity check failed" + fi + else + LUA_DEPS=${deps} + LUA_REQUIRED_USE=${requse} + LUA_SINGLE_USEDEP=${single_usedep} + LUA_USEDEP='%LUA_USEDEP-NEEDS-TO-BE-USED-IN-LUA_GEN_COND_DEP%' + readonly LUA_DEPS LUA_REQUIRED_USE LUA_SINGLE_USEDEP LUA_USEDEP + fi +} + +_lua_single_set_globals +unset -f _lua_single_set_globals + +if [[ ! ${_LUA_SINGLE_R0} ]]; then + +# @FUNCTION: _lua_gen_usedep +# @USAGE: [...] +# @INTERNAL +# @DESCRIPTION: +# Output a USE dependency string for Lua implementations which +# are both in LUA_COMPAT and match any of the patterns passed +# as parameters to the function. +# +# The patterns can be fnmatch-style patterns (matched via bash == operator +# against LUA_COMPAT values). Remember to escape or quote the fnmatch +# patterns to prevent accidental shell filename expansion. +# +# This is an internal function used to implement lua_gen_cond_dep. +_lua_gen_usedep() { + debug-print-function ${FUNCNAME} "${@}" + + local impl matches=() + + _lua_verify_patterns "${@}" + for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do + if _lua_impl_matches "${impl}" "${@}"; then + matches+=( + "lua_single_target_${impl}(-)?" + ) + fi + done + + [[ ${matches[@]} ]] || die "No supported implementations match lua_gen_usedep patterns: ${@}" + + local out=${matches[@]} + echo "${out// /,}" +} + +# @FUNCTION: _lua_impl_matches +# @USAGE: [...] +# @INTERNAL +# @DESCRIPTION: +# Check whether the specified matches at least one +# of the patterns following it. Return 0 if it does, 1 otherwise. +# Matches if no patterns are provided. +# +# can be in LUA_COMPAT or ELUA form. The patterns can be +# fnmatch-style patterns, e.g. 'lua5*', '.. +_lua_impl_matches() { + [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter" + [[ ${#} -eq 1 ]] && return 0 + + local impl=${1} pattern + shift + + for pattern; do + # unify value style to allow lax matching + if [[ ${impl/./-} == ${pattern/./-} ]]; then + return 0 + fi + done + + return 1 +} + +# @FUNCTION: _lua_verify_patterns +# @USAGE: ... +# @INTERNAL +# @DESCRIPTION: +# Verify whether the patterns passed to the eclass function are correct +# (i.e. can match any valid implementation). Dies on wrong pattern. +_lua_verify_patterns() { + debug-print-function ${FUNCNAME} "${@}" + + local impl pattern + for pattern; do + for impl in "${_LUA_ALL_IMPLS[@]}"; do + [[ ${impl} == ${pattern/./-} ]] && continue 2 + done + + die "Invalid implementation pattern: ${pattern}" + done +} + +# @FUNCTION: lua_gen_cond_dep +# @USAGE: [...] +# @DESCRIPTION: +# Output a list of -ies made conditional to USE flags +# of Lua implementations which are both in LUA_COMPAT and match +# any of the patterns passed as the remaining parameters. +# +# The patterns can be fnmatch-style patterns (matched via bash == operator +# against LUA_COMPAT values). Remember to escape or quote the fnmatch +# patterns to prevent accidental shell filename expansion. +# +# In order to enforce USE constraints on the packages, verbatim +# '${LUA_SINGLE_USEDEP}' and '${LUA_USEDEP}' (quoted!) may +# be placed in the dependency specification. It will get expanded within +# the function into a proper USE dependency string. +# +# Example: +# @CODE +# LUA_COMPAT=( lua5-{1..3} ) +# RDEPEND="$(lua_gen_cond_dep \ +# 'dev-lua/backported_core_module[${LUA_USEDEP}]' lua5-1 lua5-2 )" +# @CODE +# +# It will cause the variable to look like: +# @CODE +# RDEPEND="lua_single_target_lua5-1? ( +# dev-lua/backported_core_module[lua_targets_lua5-1(-)?,...] ) +# lua_single_target_lua5-2? ( +# dev-lua/backported_core_module[lua_targets_lua5-2(-)?,...] )" +# @CODE +lua_gen_cond_dep() { + debug-print-function ${FUNCNAME} "${@}" + + local impl matches=() + + local dep=${1} + shift + + _lua_verify_patterns "${@}" + for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do + if _lua_impl_matches "${impl}" "${@}"; then + # substitute ${LUA_SINGLE_USEDEP} if used + # (since lua_gen_usedep() will not return + # ${LUA_SINGLE_USEDEP}, the code is run at most once) + if [[ ${dep} == *'${LUA_SINGLE_USEDEP}'* ]]; then + local usedep=$(_lua_gen_usedep "${@}") + dep=${dep//\$\{LUA_SINGLE_USEDEP\}/${usedep}} + fi + local multi_usedep="lua_targets_${impl}(-)" + + local subdep=${dep//\$\{LUA_MULTI_USEDEP\}/${multi_usedep}} + matches+=( "lua_single_target_${impl}? ( + ${subdep//\$\{LUA_USEDEP\}/${multi_usedep}} )" ) + fi + done + + echo "${matches[@]}" +} + +# @FUNCTION: lua_gen_impl_dep +# @USAGE: [ [...]] +# @DESCRIPTION: +# Output a dependency on Lua implementations with the specified USE +# dependency string appended, or no USE dependency string if called +# without the argument (or with empty argument). If any implementation +# patterns are passed, the output dependencies will be generated only +# for the implementations matching them. +# +# The patterns can be fnmatch-style patterns (matched via bash == operator +# against LUA_COMPAT values). Remember to escape or quote the fnmatch +# patterns to prevent accidental shell filename expansion. +# +# Use this function when you need to request different USE flags +# on the Lua interpreter depending on package's USE flags. If you +# only need a single set of interpreter USE flags, just set +# LUA_REQ_USE and use ${LUA_DEPS} globally. +# +# Example: +# @CODE +# LUA_COMPAT=( lua5-{1..3} ) +# RDEPEND="foo? ( $(lua_gen_impl_dep 'deprecated(+)' lua5-3 ) )" +# @CODE +# +# It will cause the variable to look like: +# @CODE +# RDEPEND="foo? ( +# lua_single_target_lua5-3? ( dev-lang/lua:5.3[deprecated(+)] ) +# )" +# @CODE +lua_gen_impl_dep() { + debug-print-function ${FUNCNAME} "${@}" + + local impl + local matches=() + + local LUA_REQ_USE=${1} + shift + + _lua_verify_patterns "${@}" + for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do + if _lua_impl_matches "${impl}" "${@}"; then + local LUA_PKG_DEP + _lua_export "${impl}" LUA_PKG_DEP + matches+=( "lua_single_target_${impl}? ( ${LUA_PKG_DEP} )" ) + fi + done + + echo "${matches[@]}" +} + +# @FUNCTION: lua_setup +# @DESCRIPTION: +# Determine what the selected Lua implementation is and set +# the Lua build environment up for it. +lua_setup() { + debug-print-function ${FUNCNAME} "${@}" + + unset ELUA + + # support developer override + if [[ ${LUA_COMPAT_OVERRIDE} ]]; then + local impls=( ${LUA_COMPAT_OVERRIDE} ) + [[ ${#impls[@]} -eq 1 ]] || die "LUA_COMPAT_OVERRIDE must name exactly one implementation for lua-single" + + ewarn "WARNING: LUA_COMPAT_OVERRIDE in effect. The following Lua" + ewarn "implementation will be used:" + ewarn + ewarn " ${LUA_COMPAT_OVERRIDE}" + ewarn + ewarn "Dependencies won't be satisfied, and LUA_SINGLE_TARGET flags will be ignored." + + _lua_export "${impls[0]}" ELUA LUA + _lua_wrapper_setup + einfo "Using ${ELUA} to build" + return + fi + + local impl + for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do + if use "lua_single_target_${impl}"; then + if [[ ${ELUA} ]]; then + eerror "Your LUA_SINGLE_TARGET setting lists more than a single Lua" + eerror "implementation. Please set it to just one value. If you need" + eerror "to override the value for a single package, please use package.env" + eerror "or an equivalent solution (man 5 portage)." + echo + die "More than one implementation in LUA_SINGLE_TARGET." + fi + + _lua_export "${impl}" ELUA LUA + _lua_wrapper_setup + einfo "Using ${ELUA} to build" + fi + done + + if [[ ! ${ELUA} ]]; then + eerror "No Lua implementation selected for the build. Please set" + eerror "the LUA_SINGLE_TARGET variable in your make.conf to one" + eerror "of the following values:" + eerror + eerror "${_LUA_SUPPORTED_IMPLS[@]}" + echo + die "No supported Lua implementation in LUA_SINGLE_TARGET." + fi +} + +# @FUNCTION: lua-single_pkg_setup +# @DESCRIPTION: +# Runs lua_setup. +lua-single_pkg_setup() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${MERGE_TYPE} != binary ]] && lua_setup +} + +_LUA_SINGLE_R0=1 +fi diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass new file mode 100644 index 000000000000..100be14cb08a --- /dev/null +++ b/eclass/lua-utils.eclass @@ -0,0 +1,462 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: lua-utils.eclass +# @MAINTAINER: +# William Hubbs +# Marek Szuba +# @AUTHOR: +# Marek Szuba +# Based on python-utils-r1.eclass by Michał Górny et al. +# @SUPPORTED_EAPIS: 7 +# @BLURB: Utility functions for packages with Lua parts +# @DESCRIPTION: +# A utility eclass providing functions to query Lua implementations, +# install Lua modules and scripts. +# +# This eclass neither sets any metadata variables nor exports any phase +# functions. It can be inherited safely. + +case ${EAPI:-0} in + 0|1|2|3|4|5|6) + die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}" + ;; + 7) + ;; + *) + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" + ;; +esac + +if [[ ! ${_LUA_UTILS_R0} ]]; then + +inherit toolchain-funcs + +# @ECLASS-VARIABLE: _LUA_ALL_IMPLS +# @INTERNAL +# @DESCRIPTION: +# All supported Lua implementations, most preferred last +_LUA_ALL_IMPLS=( + luajit + lua5-1 + lua5-2 + lua5-3 + lua5-4 +) +readonly _LUA_ALL_IMPLS + +# @FUNCTION: _lua_set_impls +# @INTERNAL +# @DESCRIPTION: +# Check LUA_COMPAT for well-formedness and validity, then set +# two global variables: +# +# - _LUA_SUPPORTED_IMPLS containing valid implementations supported +# by the ebuild (LUA_COMPAT minus dead implementations), +# +# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that +# are not supported by the ebuild. +# +# Implementations in both variables are ordered using the pre-defined +# eclass implementation ordering. +# +# This function must only be called once. +_lua_set_impls() { + local i + + if ! declare -p LUA_COMPAT &>/dev/null; then + die 'LUA_COMPAT not declared.' + fi + if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then + die 'LUA_COMPAT must be an array.' + fi + + local supp=() unsupp=() + + for i in "${_LUA_ALL_IMPLS[@]}"; do + if has "${i}" "${LUA_COMPAT[@]}"; then + supp+=( "${i}" ) + else + unsupp+=( "${i}" ) + fi + done + + if [[ ! ${supp[@]} ]]; then + die "No supported implementation in LUA_COMPAT." + fi + + if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then + # set once already, verify integrity + if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then + eerror "Supported impls (LUA_COMPAT) changed between inherits!" + eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}" + eerror "Now : ${supp[*]}" + die "_LUA_SUPPORTED_IMPLS integrity check failed" + fi + if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then + eerror "Unsupported impls changed between inherits!" + eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}" + eerror "Now : ${unsupp[*]}" + die "_LUA_UNSUPPORTED_IMPLS integrity check failed" + fi + else + _LUA_SUPPORTED_IMPLS=( "${supp[@]}" ) + _LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" ) + readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS + fi +} + +# @FUNCTION: _lua_wrapper_setup +# @USAGE: [ []] +# @INTERNAL +# @DESCRIPTION: +# Create proper Lua executables and pkg-config wrappers +# (if available) in the directory named by . Set up PATH +# and PKG_CONFIG_PATH appropriately. defaults to ${T}/${ELUA}. +# +# The wrappers will be created for implementation named by , +# or for one named by ${ELUA} if no passed. +# +# If the named directory contains a lua symlink already, it will +# be assumed to contain proper wrappers already and only environment +# setup will be done. If wrapper update is requested, the directory +# shall be removed first. +_lua_wrapper_setup() { + debug-print-function ${FUNCNAME} "${@}" + + local workdir=${1:-${T}/${ELUA}} + local impl=${2:-${ELUA}} + + [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified." + [[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified." + + if [[ ! -x ${workdir}/bin/lua ]]; then + mkdir -p "${workdir}"/{bin,pkgconfig} || die + + # Clean up, in case we were supposed to do a cheap update + rm -f "${workdir}"/bin/lua{,c} || die + rm -f "${workdir}"/pkgconfig/lua.pc || die + + local ELUA LUA + _lua_export "${impl}" ELUA LUA + + # Lua interpreter + ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die + + # Lua compiler, or a stub for it in case of luajit + if [[ ${ELUA} == luajit ]]; then + # Just in case + ln -s "${EPREFIX}"/bin/true "${workdir}"/bin/luac || die + else + ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die + fi + + # pkg-config + ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \ + "${workdir}"/pkgconfig/lua.pc || die + fi + + # Now, set the environment. + # But note that ${workdir} may be shared with something else, + # and thus already on top of PATH. + if [[ ${PATH##:*} != ${workdir}/bin ]]; then + PATH=${workdir}/bin${PATH:+:${PATH}} + fi + if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then + PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} + fi + export PATH PKG_CONFIG_PATH +} + +# @ECLASS-VARIABLE: ELUA +# @DEFAULT_UNSET +# @DESCRIPTION: +# The executable name of the current Lua interpreter. This variable is set +# automatically in functions called by lua_foreach_impl(). +# +# Example value: +# @CODE +# lua5.1 +# @CODE + +# @ECLASS-VARIABLE: LUA +# @DEFAULT_UNSET +# @DESCRIPTION: +# The absolute path to the current Lua interpreter. This variable is set +# automatically in functions called by lua_foreach_impl(). +# +# Example value: +# @CODE +# /usr/bin/lua5.1 +# @CODE + +# @FUNCTION: _lua_get_library_file +# @USAGE: +# @INTERNAL +# @DESCRIPTION: +# Get the core part (i.e. without the extension) of the library name, +# with path, of the given Lua implementation. +# Used internally by _lua_export(). +_lua_get_library_file() { + local impl="${1}" + local libdir libname + + case ${impl} in + luajit) + libname=lib$($(tc-getPKG_CONFIG) --variable libname ${impl}) || die + ;; + lua*) + libname=lib${impl} + ;; + *) + die "Invalid implementation: ${impl}" + ;; + esac + libdir=$($(tc-getPKG_CONFIG) --variable libdir ${impl}) || die + + debug-print "${FUNCNAME}: libdir = ${libdir}, libname = ${libname}" + echo "${libdir}/${libname}" +} + +# @FUNCTION: _lua_export +# @USAGE: [] ... +# @INTERNAL +# @DESCRIPTION: +# Set and export the Lua implementation-relevant variables passed +# as parameters. +# +# The optional first parameter may specify the requested Lua +# implementation (either as LUA_TARGETS value, e.g. lua5-2, +# or an ELUA one, e.g. lua5.2). If no implementation passed, +# the current one will be obtained from ${ELUA}. +_lua_export() { + debug-print-function ${FUNCNAME} "${@}" + + local impl var + + case "${1}" in + luajit) + impl=${1} + shift + ;; + lua*) + impl=${1/-/.} + shift + ;; + *) + impl=${ELUA} + if [[ -z ${impl} ]]; then + die "_lua_export called without a Lua implementation and ELUA is unset" + fi + ;; + esac + debug-print "${FUNCNAME}: implementation: ${impl}" + + for var; do + case "${var}" in + ELUA) + export ELUA=${impl} + debug-print "${FUNCNAME}: ELUA = ${ELUA}" + ;; + LUA) + export LUA="${EPREFIX}"/usr/bin/${impl} + debug-print "${FUNCNAME}: LUA = ${LUA}" + ;; + LUA_CFLAGS) + local val + + val=$($(tc-getPKG_CONFIG) --cflags ${impl}) || die + + export LUA_CFLAGS=${val} + debug-print "${FUNCNAME}: LUA_CFLAGS = ${LUA_CFLAGS}" + ;; + LUA_CMOD_DIR) + local val + + val=$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD ${impl}) || die + + export LUA_CMOD_DIR=${val} + debug-print "${FUNCNAME}: LUA_CMOD_DIR = ${LUA_CMOD_DIR}" + ;; + LUA_INCLUDE_DIR) + local val + + val=$($(tc-getPKG_CONFIG) --variable includedir ${impl}) || die + + export LUA_INCLUDE_DIR=${val} + debug-print "${FUNCNAME}: LUA_INCLUDE_DIR = ${LUA_INCLUDE_DIR}" + ;; + LUA_LIBS) + local val + + val=$($(tc-getPKG_CONFIG) --libs ${impl}) || die + + export LUA_LIBS=${val} + debug-print "${FUNCNAME}: LUA_LIBS = ${LUA_LIBS}" + ;; + LUA_LMOD_DIR) + local val + + val=$($(tc-getPKG_CONFIG) --variable INSTALL_LMOD ${impl}) || die + + export LUA_LMOD_DIR=${val} + debug-print "${FUNCNAME}: LUA_LMOD_DIR = ${LUA_LMOD_DIR}" + ;; + LUA_PKG_DEP) + local d + case ${impl} in + luajit) + LUA_PKG_DEP="dev-lang/luajit:=" + ;; + lua*) + LUA_PKG_DEP="dev-lang/lua:${impl#lua}" + ;; + *) + die "Invalid implementation: ${impl}" + ;; + esac + + # use-dep + if [[ ${LUA_REQ_USE} ]]; then + LUA_PKG_DEP+=[${LUA_REQ_USE}] + fi + + export LUA_PKG_DEP + debug-print "${FUNCNAME}: LUA_PKG_DEP = ${LUA_PKG_DEP}" + ;; + LUA_SHARED_LIB) + local val=$(_lua_get_library_file ${impl}) + export LUA_SHARED_LIB="${val}".so + debug-print "${FUNCNAME}: LUA_SHARED_LIB = ${LUA_SHARED_LIB}" + ;; + LUA_VERSION) + local val + + val=$($(tc-getPKG_CONFIG) --modversion ${impl}) || die + + export LUA_VERSION=${val} + debug-print "${FUNCNAME}: LUA_VERSION = ${LUA_VERSION}" + ;; + *) + die "_lua_export: unknown variable ${var}" + ;; + esac + done +} + +# @FUNCTION: lua_get_CFLAGS +# @USAGE: [] +# @DESCRIPTION: +# Obtain and print the compiler flags for building against Lua, +# for the given implementation. If no implementation is provided, +# ${ELUA} will be used. +# +# Please note that this function requires Lua and pkg-config installed, +# and therefore proper build-time dependencies need be added to the ebuild. +lua_get_CFLAGS() { + debug-print-function ${FUNCNAME} "${@}" + + _lua_export "${@}" LUA_CFLAGS + echo "${LUA_CFLAGS}" +} + +# @FUNCTION: lua_get_cmod_dir +# @USAGE: [] +# @DESCRIPTION: +# Obtain and print the name of the directory into which compiled Lua +# modules are installed, for the given implementation. If no implementation +# is provided, ${ELUA} will be used. +# +# Please note that this function requires Lua and pkg-config installed, +# and therefore proper build-time dependencies need be added to the ebuild. +lua_get_cmod_dir() { + debug-print-function ${FUNCNAME} "${@}" + + _lua_export "${@}" LUA_CMOD_DIR + echo "${LUA_CMOD_DIR}" +} + +# @FUNCTION: lua_get_include_dir +# @USAGE: [] +# @DESCRIPTION: +# Obtain and print the name of the directory containing header files +# of the given Lua implementation. If no implementation is provided, +# ${ELUA} will be used. +# +# Please note that this function requires Lua and pkg-config installed, +# and therefore proper build-time dependencies need be added to the ebuild. +lua_get_include_dir() { + debug-print-function ${FUNCNAME} "${@}" + + _lua_export "${@}" LUA_INCLUDE_DIR + echo "${LUA_INCLUDE_DIR}" +} + +# @FUNCTION: lua_get_LIBS +# @USAGE: [] +# @DESCRIPTION: +# Obtain and print the compiler flags for linking against Lua, +# for the given implementation. If no implementation is provided, +# ${ELUA} will be used. +# +# Please note that this function requires Lua and pkg-config installed, +# and therefore proper build-time dependencies need be added to the ebuild. +lua_get_LIBS() { + debug-print-function ${FUNCNAME} "${@}" + + _lua_export "${@}" LUA_LIBS + echo "${LUA_LIBS}" +} + +# @FUNCTION: lua_get_lmod_dir +# @USAGE: [] +# @DESCRIPTION: +# Obtain and print the name of the directory into which native-Lua +# modules are installed, for the given implementation. If no implementation +# is provided, ${ELUA} will be used. +# +# Please note that this function requires Lua and pkg-config installed, +# and therefore proper build-time dependencies need be added to the ebuild. +lua_get_lmod_dir() { + debug-print-function ${FUNCNAME} "${@}" + + _lua_export "${@}" LUA_LMOD_DIR + echo "${LUA_LMOD_DIR}" +} + +# @FUNCTION: lua_get_shared_lib +# @USAGE: [] +# @DESCRIPTION: +# Obtain and print the expected name, with path, of the main shared library +# of the given Lua implementation. If no implementation is provided, +# ${ELUA} will be used. +# +# Note that it is up to the ebuild maintainer to ensure Lua actually +# provides a shared library. +# +# Please note that this function requires Lua and pkg-config installed, +# and therefore proper build-time dependencies need be added to the ebuild. +lua_get_shared_lib() { + debug-print-function ${FUNCNAME} "${@}" + + _lua_export "${@}" LUA_SHARED_LIB + echo "${LUA_SHARED_LIB}" +} + +# @FUNCTION: lua_get_version +# @USAGE: [] +# @DESCRIPTION: +# Obtain and print the full version number of the given Lua implementation. +# If no implementation is provided, ${ELUA} will be used. +# +# Please note that this function requires Lua and pkg-config installed, +# and therefore proper build-time dependencies need be added to the ebuild. +lua_get_version() { + debug-print-function ${FUNCNAME} "${@}" + + _lua_export "${@}" LUA_VERSION + echo "${LUA_VERSION}" +} + +_LUA_UTILS_R0=1 +fi diff --git a/eclass/lua.eclass b/eclass/lua.eclass index 7dccba6980a0..46d9e848c87f 100644 --- a/eclass/lua.eclass +++ b/eclass/lua.eclass @@ -7,7 +7,7 @@ # Marek Szuba # @AUTHOR: # Marek Szuba -# Based on python{,-utils}-r1.eclass by Michał Górny et al. +# Based on python-r1.eclass by Michał Górny et al. # @SUPPORTED_EAPIS: 7 # @BLURB: A common eclass for Lua packages # @DESCRIPTION: @@ -21,7 +21,9 @@ # package easily. It also provides methods to easily run a command for # each enabled Lua implementation and duplicate the sources for them. # -# Please note that for the time being this eclass does NOT support luajit. +# Note that since this eclass always inherits lua-utils as well, in ebuilds +# using the former there is no need to explicitly inherit the latter in order +# to use helper functions such as lua_get_CFLAGS. # # @EXAMPLE: # @CODE @@ -36,15 +38,15 @@ # REQUIRED_USE="${LUA_REQUIRED_USE}" # DEPEND="${LUA_DEPS}" # RDEPEND="${DEPEND} -# dev-lua/foo[${LUA_USEDEP}]" +# dev-lua/foo[${LUA_USEDEP}]" # BDEPEND="virtual/pkgconfig" # # lua_src_install() { -# emake LUA_VERSION="$(lua_get_version)" install +# emake LUA_VERSION="$(lua_get_version)" install # } # # src_install() { -# lua_foreach_impl lua_src_install +# lua_foreach_impl lua_src_install # } # @CODE @@ -61,7 +63,11 @@ esac if [[ ! ${_LUA_R0} ]]; then -inherit multibuild toolchain-funcs +if [[ ${_LUA_SINGLE_R0} ]]; then + die 'lua.eclass cannot be used with lua-single.eclass.' +fi + +inherit multibuild lua-utils fi @@ -140,28 +146,6 @@ fi # ${WORKDIR}/foo-1.3-lua5-1 # @CODE -# @ECLASS-VARIABLE: ELUA -# @DEFAULT_UNSET -# @DESCRIPTION: -# The executable name of the current Lua interpreter. This variable is set -# automatically in functions called by lua_foreach_impl(). -# -# Example value: -# @CODE -# lua5.1 -# @CODE - -# @ECLASS-VARIABLE: LUA -# @DEFAULT_UNSET -# @DESCRIPTION: -# The absolute path to the current Lua interpreter. This variable is set -# automatically in functions called by lua_foreach_impl(). -# -# Example value: -# @CODE -# /usr/bin/lua5.1 -# @CODE - # @ECLASS-VARIABLE: LUA_DEPS # @OUTPUT_VARIABLE # @DESCRIPTION: @@ -219,112 +203,6 @@ fi if [[ ! ${_LUA_R0} ]]; then -# @FUNCTION: _lua_export -# @USAGE: [] ... -# @INTERNAL -# @DESCRIPTION: -# Set and export the Lua implementation-relevant variables passed -# as parameters. -# -# The optional first parameter may specify the requested Lua -# implementation (either as LUA_TARGETS value, e.g. lua5-2, -# or an ELUA one, e.g. lua5.2). If no implementation passed, -# the current one will be obtained from ${ELUA}. -_lua_export() { - debug-print-function ${FUNCNAME} "${@}" - - local impl var - - case "${1}" in - lua*) - impl=${1/-/.} - shift - ;; - *) - impl=${ELUA} - if [[ -z ${impl} ]]; then - die "_lua_export called without a Lua implementation and ELUA is unset" - fi - ;; - esac - debug-print "${FUNCNAME}: implementation: ${impl}" - - for var; do - case "${var}" in - ELUA) - export ELUA=${impl} - debug-print "${FUNCNAME}: ELUA = ${ELUA}" - ;; - LUA) - export LUA="${EPREFIX}"/usr/bin/${impl} - debug-print "${FUNCNAME}: LUA = ${LUA}" - ;; - LUA_CFLAGS) - local val - - val=$($(tc-getPKG_CONFIG) --cflags ${impl}) || die - - export LUA_CFLAGS=${val} - debug-print "${FUNCNAME}: LUA_CFLAGS = ${LUA_CFLAGS}" - ;; - LUA_CMOD_DIR) - local val - - val=$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD ${impl}) || die - - export LUA_CMOD_DIR=${val} - debug-print "${FUNCNAME}: LUA_CMOD_DIR = ${LUA_CMOD_DIR}" - ;; - LUA_LIBS) - local val - - val=$($(tc-getPKG_CONFIG) --libs ${impl}) || die - - export LUA_LIBS=${val} - debug-print "${FUNCNAME}: LUA_LIBS = ${LUA_LIBS}" - ;; - LUA_LMOD_DIR) - local val - - val=$($(tc-getPKG_CONFIG) --variable INSTALL_LMOD ${impl}) || die - - export LUA_LMOD_DIR=${val} - debug-print "${FUNCNAME}: LUA_LMOD_DIR = ${LUA_LMOD_DIR}" - ;; - LUA_PKG_DEP) - local d - case ${impl} in - lua*) - LUA_PKG_DEP="dev-lang/lua:${impl#lua}" - ;; - *) - die "Invalid implementation: ${impl}" - ;; - esac - - # use-dep - if [[ ${LUA_REQ_USE} ]]; then - LUA_PKG_DEP+=[${LUA_REQ_USE}] - fi - - export LUA_PKG_DEP - debug-print "${FUNCNAME}: LUA_PKG_DEP = ${LUA_PKG_DEP}" - ;; - LUA_VERSION) - local val - - val=$($(tc-getPKG_CONFIG) --modversion ${impl}) || die - - export LUA_VERSION=${val} - debug-print "${FUNCNAME}: LUA_VERSION = ${LUA_VERSION}" - ;; - *) - die "_lua_export: unknown variable ${var}" - ;; - esac - done -} - # @FUNCTION: _lua_validate_useflags # @INTERNAL # @DESCRIPTION: @@ -401,61 +279,6 @@ _lua_multibuild_wrapper() { "${@}" } -# @FUNCTION: _lua_wrapper_setup -# @USAGE: [ []] -# @INTERNAL -# @DESCRIPTION: -# Create proper Lua executables and pkg-config wrappers -# (if available) in the directory named by . Set up PATH -# and PKG_CONFIG_PATH appropriately. defaults to ${T}/${ELUA}. -# -# The wrappers will be created for implementation named by , -# or for one named by ${ELUA} if no passed. -# -# If the named directory contains a lua symlink already, it will -# be assumed to contain proper wrappers already and only environment -# setup will be done. If wrapper update is requested, the directory -# shall be removed first. -_lua_wrapper_setup() { - debug-print-function ${FUNCNAME} "${@}" - - local workdir=${1:-${T}/${ELUA}} - local impl=${2:-${ELUA}} - - [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified." - [[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified." - - if [[ ! -x ${workdir}/bin/lua ]]; then - mkdir -p "${workdir}"/{bin,pkgconfig} || die - - # Clean up, in case we were supposed to do a cheap update - rm -f "${workdir}"/bin/lua{,c} || die - rm -f "${workdir}"/pkgconfig/lua.pc || die - - local ELUA LUA - _lua_export "${impl}" ELUA LUA - - # Lua interpreter and compiler - ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die - ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die - - # pkg-config - ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \ - "${workdir}"/pkgconfig/lua.pc || die - fi - - # Now, set the environment. - # But note that ${workdir} may be shared with something else, - # and thus already on top of PATH. - if [[ ${PATH##:*} != ${workdir}/bin ]]; then - PATH=${workdir}/bin${PATH:+:${PATH}} - fi - if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then - PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} - fi - export PATH PKG_CONFIG_PATH -} - # @FUNCTION: lua_copy_sources # @DESCRIPTION: # Create a single copy of the package sources for each enabled Lua @@ -495,161 +318,9 @@ lua_foreach_impl() { multibuild_foreach_variant _lua_multibuild_wrapper "${@}" } -# @FUNCTION: lua_get_CFLAGS -# @USAGE: [] -# @DESCRIPTION: -# Obtain and print the compiler flags for building against Lua, -# for the given implementation. If no implementation is provided, -# ${ELUA} will be used. -# -# Please note that this function requires Lua and pkg-config installed, -# and therefore proper build-time dependencies need be added to the ebuild. -lua_get_CFLAGS() { - debug-print-function ${FUNCNAME} "${@}" - - _lua_export "${@}" LUA_CFLAGS - echo "${LUA_CFLAGS}" -} - -# @FUNCTION: lua_get_cmod_dir -# @USAGE: [] -# @DESCRIPTION: -# Obtain and print the name of the directory into which compiled Lua -# modules are installed, for the given implementation. If no implementation -# is provided, ${ELUA} will be used. -# -# Please note that this function requires Lua and pkg-config installed, -# and therefore proper build-time dependencies need be added to the ebuild. -lua_get_cmod_dir() { - debug-print-function ${FUNCNAME} "${@}" - - _lua_export "${@}" LUA_CMOD_DIR - echo "${LUA_CMOD_DIR}" -} - -# @FUNCTION: lua_get_LIBS -# @USAGE: [] -# @DESCRIPTION: -# Obtain and print the compiler flags for linking against Lua, -# for the given implementation. If no implementation is provided, -# ${ELUA} will be used. -# -# Please note that this function requires Lua and pkg-config installed, -# and therefore proper build-time dependencies need be added to the ebuild. -lua_get_LIBS() { - debug-print-function ${FUNCNAME} "${@}" - - _lua_export "${@}" LUA_LIBS - echo "${LUA_LIBS}" -} - -# @FUNCTION: lua_get_lmod_dir -# @USAGE: [] -# @DESCRIPTION: -# Obtain and print the name of the directory into which native-Lua -# modules are installed, for the given implementation. If no implementation -# is provided, ${ELUA} will be used. -# -# Please note that this function requires Lua and pkg-config installed, -# and therefore proper build-time dependencies need be added to the ebuild. -lua_get_lmod_dir() { - debug-print-function ${FUNCNAME} "${@}" - - _lua_export "${@}" LUA_LMOD_DIR - echo "${LUA_LMOD_DIR}" -} - -# @FUNCTION: lua_get_version -# @USAGE: [] -# @DESCRIPTION: -# Obtain and print the full version number of the given Lua implementation. -# If no implementation is provided, ${ELUA} will be used. -# -# Please note that this function requires Lua and pkg-config installed, -# and therefore proper build-time dependencies need be added to the ebuild. -lua_get_version() { - debug-print-function ${FUNCNAME} "${@}" - - _lua_export "${@}" LUA_VERSION - echo "${LUA_VERSION}" -} - _LUA_R0=1 fi -# @ECLASS-VARIABLE: _LUA_ALL_IMPLS -# @INTERNAL -# @DESCRIPTION: -# All supported Lua implementations, most preferred last -_LUA_ALL_IMPLS=( - lua5-1 - lua5-2 - lua5-3 - lua5-4 -) -readonly _LUA_ALL_IMPLS - -# @FUNCTION: _lua_set_impls -# @INTERNAL -# @DESCRIPTION: -# Check LUA_COMPAT for well-formedness and validity, then set -# two global variables: -# -# - _LUA_SUPPORTED_IMPLS containing valid implementations supported -# by the ebuild (LUA_COMPAT minus dead implementations), -# -# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that -# are not supported by the ebuild. -# -# Implementations in both variables are ordered using the pre-defined -# eclass implementation ordering. -# -# This function must only be called once. -_lua_set_impls() { - local i - - if ! declare -p LUA_COMPAT &>/dev/null; then - die 'LUA_COMPAT not declared.' - fi - if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then - die 'LUA_COMPAT must be an array.' - fi - - local supp=() unsupp=() - - for i in "${_LUA_ALL_IMPLS[@]}"; do - if has "${i}" "${LUA_COMPAT[@]}"; then - supp+=( "${i}" ) - else - unsupp+=( "${i}" ) - fi - done - - if [[ ! ${supp[@]} ]]; then - die "No supported implementation in LUA_COMPAT." - fi - - if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then - # set once already, verify integrity - if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then - eerror "Supported impls (LUA_COMPAT) changed between inherits!" - eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}" - eerror "Now : ${supp[*]}" - die "_LUA_SUPPORTED_IMPLS integrity check failed" - fi - if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then - eerror "Unsupported impls changed between inherits!" - eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}" - eerror "Now : ${unsupp[*]}" - die "_LUA_UNSUPPORTED_IMPLS integrity check failed" - fi - else - _LUA_SUPPORTED_IMPLS=( "${supp[@]}" ) - _LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" ) - readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS - fi -} - # @FUNCTION: _lua_set_globals # @INTERNAL # @DESCRIPTION: @@ -707,4 +378,4 @@ _lua_set_globals() { } _lua_set_globals -unset -f _lua_set_globals _lua_set_impls +unset -f _lua_set_globals diff --git a/eclass/mono.eclass b/eclass/mono.eclass index 913c04c85c70..b1dc1e56d487 100644 --- a/eclass/mono.eclass +++ b/eclass/mono.eclass @@ -1,10 +1,11 @@ -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: mono.eclass # @MAINTAINER: # dotnet@gentoo.org # @BLURB: common settings and functions for mono and dotnet related packages +# @DEPRECATED: mono-env # @DESCRIPTION: # The mono eclass contains common environment settings that are useful for # dotnet packages. Currently, it provides no functions, just exports diff --git a/eclass/mozcoreconf-v5.eclass b/eclass/mozcoreconf-v5.eclass index a78b190aff69..008b1b759ccc 100644 --- a/eclass/mozcoreconf-v5.eclass +++ b/eclass/mozcoreconf-v5.eclass @@ -124,6 +124,7 @@ mozconfig_init() { declare FF=$([[ ${PN} == firefox ]] && echo true || echo false) declare SM=$([[ ${PN} == seamonkey ]] && echo true || echo false) declare TB=$([[ ${PN} == thunderbird ]] && echo true || echo false) + declare WF=$([[ ${PN} == waterfox* ]] && echo true || echo false) #################################### # @@ -136,7 +137,7 @@ mozconfig_init() { *xulrunner) cp xulrunner/config/mozconfig .mozconfig \ || die "cp xulrunner/config/mozconfig failed" ;; - *firefox) + *firefox|waterfox*) cp browser/config/mozconfig .mozconfig \ || die "cp browser/config/mozconfig failed" ;; seamonkey) diff --git a/eclass/mozcoreconf-v6.eclass b/eclass/mozcoreconf-v6.eclass index 045aabc164c8..b4f75ae017d1 100644 --- a/eclass/mozcoreconf-v6.eclass +++ b/eclass/mozcoreconf-v6.eclass @@ -122,6 +122,7 @@ mozconfig_init() { declare SM=$([[ ${PN} == seamonkey ]] && echo true || echo false) declare TB=$([[ ${PN} == thunderbird ]] && echo true || echo false) declare TRB=$([[ ${PN} == torbrowser ]] && echo true || echo false) + declare WF=$([[ ${PN} == waterfox* ]] && echo true || echo false) #################################### # @@ -134,7 +135,7 @@ mozconfig_init() { *xulrunner) cp xulrunner/config/mozconfig .mozconfig \ || die "cp xulrunner/config/mozconfig failed" ;; - *firefox) + *firefox|waterfox*) cp browser/config/mozconfig .mozconfig \ || die "cp browser/config/mozconfig failed" ;; *torbrowser) diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass index 9c7042fcd299..095e3a4f4508 100644 --- a/eclass/multilib.eclass +++ b/eclass/multilib.eclass @@ -3,7 +3,6 @@ # @ECLASS: multilib.eclass # @MAINTAINER: -# amd64@gentoo.org # toolchain@gentoo.org # @BLURB: This eclass is for all functions pertaining to handling multilib configurations. # @DESCRIPTION: @@ -498,6 +497,7 @@ multilib_toolchain_setup() { STRIP PKG_CONFIG_LIBDIR PKG_CONFIG_PATH + PKG_CONFIG_SYSTEM_INCLUDE_PATH PKG_CONFIG_SYSTEM_LIBRARY_PATH ) @@ -547,7 +547,8 @@ multilib_toolchain_setup() { export CHOST=$(get_abi_CHOST $1) export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig - export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/usr/$(get_libdir) + export PKG_CONFIG_SYSTEM_INCLUDE_PATH=${EPREFIX}/usr/include + export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir) fi } diff --git a/eclass/nvidia-driver.eclass b/eclass/nvidia-driver.eclass index d0b6cd41d598..a2206c5e7894 100644 --- a/eclass/nvidia-driver.eclass +++ b/eclass/nvidia-driver.eclass @@ -1,9 +1,9 @@ -# Copyright 1999-2014 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: nvidia-driver.eclass # @MAINTAINER: -# Jeroen Roovers +# David Seifert # @AUTHOR: # Original author: Doug Goldstein # @BLURB: Provide useful messages for nvidia-drivers diff --git a/eclass/opam.eclass b/eclass/opam.eclass index 382dc00e511b..0420b99f71c5 100644 --- a/eclass/opam.eclass +++ b/eclass/opam.eclass @@ -1,9 +1,9 @@ -# Copyright 1999-2019 Gentoo Authors +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: opam.eclass # @MAINTAINER: -# maintainer-needed@gentoo.org +# Mark Wright # @AUTHOR: # Alexis Ballier # @SUPPORTED_EAPIS: 5 6 7 @@ -17,9 +17,21 @@ case ${EAPI:-0} in *) die "${ECLASS}: EAPI ${EAPI} not supported" ;; esac +# @ECLASS-VARIABLE: OPAM_INSTALLER_DEP +# @DESCRIPTION: +# Override dependency for OPAM_INSTALLER +: ${OPAM_INSTALLER_DEP:="dev-ml/opam-installer"} + RDEPEND=">=dev-lang/ocaml-4:=" -DEPEND="${RDEPEND} - dev-ml/opam" +case ${EAPI:-0} in + 0|1|2|3|4|5|6) DEPEND="${RDEPEND} ${OPAM_INSTALLER_DEP}";; + *) BDEPEND="${OPAM_INSTALLER_DEP} dev-lang/ocaml"; DEPEND="${RDEPEND}" ;; +esac + +# @ECLASS-VARIABLE: OPAM_INSTALLER +# @DESCRIPTION: +# Eclass can use different opam-installer binary than the one provided in by system. +: ${OPAM_INSTALLER:=opam-installer} # @FUNCTION: opam-install # @USAGE: @@ -29,7 +41,7 @@ DEPEND="${RDEPEND} opam-install() { local pkg for pkg ; do - opam-installer -i \ + ${OPAM_INSTALLER} -i \ --prefix="${ED%/}/usr" \ --libdir="${D%/}/$(ocamlc -where)" \ --docdir="${ED%/}/usr/share/doc/${PF}" \ diff --git a/eclass/pam.eclass b/eclass/pam.eclass index 271751131b59..97fcb89d3f5b 100644 --- a/eclass/pam.eclass +++ b/eclass/pam.eclass @@ -182,11 +182,7 @@ pamd_mimic() { originalstack=$1 authlevels="auth account password session" - if has_version '/dev/null 2>&1)" == "declare -a"* ]] || @@ -189,17 +179,10 @@ selinux-policy-2_src_prepare() { # Apply the additional patches refered to by the module ebuild. # But first some magic to differentiate between bash arrays and strings - if [[ "$(declare -p POLICY_PATCH 2>/dev/null 2>&1)" == "declare -a"* ]] || - [[ -n ${POLICY_PATCH} ]]; then - cd "${S}/refpolicy/policy/modules" - for POLPATCH in ${POLICY_PATCH[@]}; - do - if [[ ${EAPI:-0} == 5 ]]; then - epatch "${POLPATCH}" - else - eapply "${POLPATCH}" - fi - done + if [[ "$(declare -p POLICY_PATCH 2>/dev/null 2>&1)" == "declare -a"* ]]; then + [[ -n ${POLICY_PATCH[*]} ]] && eapply -d "${S}/refpolicy/policy/modules" "${POLICY_PATCH[@]}" + else + [[ -n ${POLICY_PATCH} ]] && eapply -d "${S}/refpolicy/policy/modules" ${POLICY_PATCH} fi # Collect only those files needed for this particular module diff --git a/eclass/tests/eapi8-dosym.sh b/eclass/tests/eapi8-dosym.sh new file mode 100755 index 000000000000..e1160c42d875 --- /dev/null +++ b/eclass/tests/eapi8-dosym.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +source tests-common.sh + +inherit eapi8-dosym + +dosym() { + echo "$1" +} + +# reference implementation using GNU realpath +ref_canonicalize() { + realpath -m -s "$1" +} + +ref_dosym_r() { + local link=$(realpath -m -s "/${2#/}") + realpath -m -s --relative-to="$(dirname "${link}")" "$1" +} + +randompath() { + dd if=/dev/urandom bs=128 count=1 2>/dev/null | LC_ALL=C sed \ + -e 's/[^a-zA-M]//g;s/[A-E]/\/.\//g;s/[F-J]/\/..\//g;s/[K-M]/\//g' \ + -e 's/^/\//;q' +} + +teq() { + local expected=$1; shift + tbegin "$* -> ${expected}" + local got=$("$@") + [[ ${got} == "${expected}" ]] + tend $? "returned: ${got}" +} + +for f in ref_canonicalize "_dosym8_canonicalize"; do + # canonicalize absolute paths + teq / ${f} / + teq /foo/baz/quux ${f} /foo/bar/../baz/quux + teq /foo ${f} /../../../foo + teq /bar ${f} /foo//./..///bar + teq /baz ${f} /foo/bar/../../../baz + teq /a/d/f/g ${f} /a/b/c/../../d/e/../f/g +done + +# canonicalize relative paths (not actually used) +teq . _dosym8_canonicalize . +teq foo _dosym8_canonicalize foo +teq foo _dosym8_canonicalize ./foo +teq ../foo _dosym8_canonicalize ../foo +teq ../baz _dosym8_canonicalize foo/bar/../../../baz + +for f in ref_dosym_r "dosym8 -r"; do + teq ../../bin/foo ${f} /bin/foo /usr/bin/foo + teq ../../../doc/foo-1 \ + ${f} /usr/share/doc/foo-1 /usr/share/texmf-site/doc/fonts/foo + teq ../../opt/bar/foo ${f} /opt/bar/foo /usr/bin/foo + teq ../c/d/e ${f} /a/b/c/d/e a/b/f/g + teq b/f ${f} /a/b///./c/d/../e/..//../f /a/././///g/../h + teq ../h ${f} /a/././///g/../h /a/b///./c/d/../e/..//../f + teq . ${f} /foo /foo/bar + teq .. ${f} /foo /foo/bar/baz + teq '../../fo . o/b ar' ${f} '/fo . o/b ar' '/baz / qu .. ux/qu x' + teq '../../f"o\o/b$a[]r' ${f} '/f"o\o/b$a[]r' '/ba\z/qu$u"x/qux' +done + +# set RANDOMTESTS to a positive number to enable random tests +for (( i = 0; i < RANDOMTESTS; i++ )); do + targ=$(randompath) + link=$(randompath) + out=$(ref_dosym_r "${targ}" "${link}") + teq "${out}" dosym8 -r "${targ}" "${link}" +done + +texit diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 32996a2f8f71..59f8660a3d90 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -181,6 +181,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then tc_version_is_at_least 9.1 && IUSE+=" lto" tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=(zstd) tc_version_is_at_least 11 && IUSE+=" valgrind" TC_FEATURES+=(valgrind) + tc_version_is_at_least 11 && IUSE+=" custom-cflags" fi if tc_version_is_at_least 10; then @@ -1391,12 +1392,18 @@ downgrade_arch_flags() { } gcc_do_filter_flags() { - # Be conservative here: - # - don't allow -O3 and like to over-optimize libgcc # 701786 - # - don't allow -O0 to generate potentially invalid startup code - strip-flags - filter-flags '-O?' - append-flags -O2 + # Allow users to explicitly avoid flag sanitization via + # USE=custom-cflags. + if ! _tc_use_if_iuse custom-cflags; then + # Over-zealous CFLAGS can often cause problems. What may work for one + # person may not work for another. To avoid a large influx of bugs + # relating to failed builds, we strip most CFLAGS out to ensure as few + # problems as possible. + strip-flags + # Lock gcc at -O2; we want to be conservative here. + filter-flags '-O?' + append-flags -O2 + fi # dont want to funk ourselves filter-flags '-mabi*' -m31 -m32 -m64 diff --git a/eclass/user.eclass b/eclass/user.eclass index b70698356a3a..f8993b827741 100644 --- a/eclass/user.eclass +++ b/eclass/user.eclass @@ -6,6 +6,7 @@ # base-system@gentoo.org (Linux) # Michał Górny (NetBSD) # @BLURB: user management in ebuilds +# @DEPRECATED: acct-user/acct-group packages # @DESCRIPTION: # The user eclass contains a suite of functions that allow ebuilds # to quickly make sure users in the installed system are sane. @@ -13,6 +14,19 @@ if [[ -z ${_USER_ECLASS} ]]; then _USER_ECLASS=1 +case ${EAPI:-0} in + 0|1|2|3|4|5|6|7) ;; + *) + if [[ ${CATEGORY} != acct-* ]]; then + eerror "In EAPI ${EAPI}, packages must not inherit user.eclass" + eerror "unless they are in the acct-user or acct-group category." + eerror "Migrate your package to GLEP 81 user/group management," + eerror "or inherit user-info if you need only the query functions." + die "Invalid \"inherit user\" in EAPI ${EAPI}" + fi + ;; +esac + inherit user-info # @FUNCTION: _assert_pkg_ebuild_phase diff --git a/eclass/verify-sig.eclass b/eclass/verify-sig.eclass new file mode 100644 index 000000000000..e3ef7f240283 --- /dev/null +++ b/eclass/verify-sig.eclass @@ -0,0 +1,271 @@ +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: verify-sig.eclass +# @MAINTAINER: +# Michał Górny +# @SUPPORTED_EAPIS: 7 +# @BLURB: Eclass to verify upstream signatures on distfiles +# @DESCRIPTION: +# verify-sig eclass provides a streamlined approach to verifying +# upstream signatures on distfiles. Its primary purpose is to permit +# developers to easily verify signatures while bumping packages. +# The eclass removes the risk of developer forgetting to perform +# the verification, or performing it incorrectly, e.g. due to additional +# keys in the local keyring. It also permits users to verify +# the developer's work. +# +# To use the eclass, start by packaging the upstream's key +# as app-crypt/openpgp-keys-*. Then inherit the eclass, add detached +# signatures to SRC_URI and set VERIFY_SIG_OPENPGP_KEY_PATH. The eclass +# provides verify-sig USE flag to toggle the verification. +# +# Example use: +# @CODE +# inherit verify-sig +# +# SRC_URI="https://example.org/${P}.tar.gz +# verify-sig? ( https://example.org/${P}.tar.gz.sig )" +# BDEPEND=" +# verify-sig? ( app-crypt/openpgp-keys-example )" +# +# VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/example.asc +# @CODE + +case "${EAPI:-0}" in + 0|1|2|3|4|5|6) + die "Unsupported EAPI=${EAPI} (obsolete) for ${ECLASS}" + ;; + 7) + ;; + *) + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" + ;; +esac + +EXPORT_FUNCTIONS src_unpack + +if [[ ! ${_VERIFY_SIG_ECLASS} ]]; then + +IUSE="verify-sig" + +BDEPEND=" + verify-sig? ( + app-crypt/gnupg + >=app-portage/gemato-16 + )" + +# @ECLASS-VARIABLE: VERIFY_SIG_OPENPGP_KEY_PATH +# @DEFAULT_UNSET +# @DESCRIPTION: +# Path to key bundle used to perform the verification. This is required +# when using default src_unpack. Alternatively, the key path can be +# passed directly to the verification functions. + +# @ECLASS-VARIABLE: VERIFY_SIG_OPENPGP_KEYSERVER +# @DEFAULT_UNSET +# @DESCRIPTION: +# Keyserver used to refresh keys. If not specified, the keyserver +# preference from the key will be respected. If no preference +# is specified by the key, the GnuPG default will be used. + +# @ECLASS-VARIABLE: VERIFY_SIG_OPENPGP_KEY_REFRESH +# @USER_VARIABLE +# @DESCRIPTION: +# Attempt to refresh keys via WKD/keyserver. Set it to "yes" +# in make.conf to enable. Note that this requires working Internet +# connection. +: ${VERIFY_SIG_OPENPGP_KEY_REFRESH:=no} + +# @FUNCTION: verify-sig_verify_detached +# @USAGE: [] +# @DESCRIPTION: +# Read the detached signature from and verify against +# it. can either be passed directly, or it defaults +# to VERIFY_SIG_OPENPGP_KEY_PATH. The function dies if verification +# fails. +verify-sig_verify_detached() { + local file=${1} + local sig=${2} + local key=${3:-${VERIFY_SIG_OPENPGP_KEY_PATH}} + + [[ -n ${key} ]] || + die "${FUNCNAME}: no key passed and VERIFY_SIG_OPENPGP_KEY_PATH unset" + + local extra_args=() + [[ ${VERIFY_SIG_OPENPGP_KEY_REFRESH} == yes ]] || extra_args+=( -R ) + [[ -n ${VERIFY_SIG_OPENPGP_KEYSERVER+1} ]] && extra_args+=( + --keyserver "${VERIFY_SIG_OPENPGP_KEYSERVER}" + ) + + # GPG upstream knows better than to follow the spec, so we can't + # override this directory. However, there is a clean fallback + # to GNUPGHOME. + addpredict /run/user + + local filename=${file##*/} + [[ ${file} == - ]] && filename='(stdin)' + einfo "Verifying ${filename} ..." + gemato gpg-wrap -K "${key}" "${extra_args[@]}" -- \ + gpg --verify "${sig}" "${file}" || + die "PGP signature verification failed" +} + +# @FUNCTION: verify-sig_verify_message +# @USAGE: [] +# @DESCRIPTION: +# Verify that the file ('-' for stdin) contains a valid, signed PGP +# message and write the message into ('-' for stdout). +# can either be passed directly, or it defaults +# to VERIFY_SIG_OPENPGP_KEY_PATH. The function dies if verification +# fails. Note that using output from is important as it +# prevents the injection of unsigned data. +verify-sig_verify_message() { + local file=${1} + local output_file=${2} + local key=${3:-${VERIFY_SIG_OPENPGP_KEY_PATH}} + + [[ -n ${key} ]] || + die "${FUNCNAME}: no key passed and VERIFY_SIG_OPENPGP_KEY_PATH unset" + + local extra_args=() + [[ ${VERIFY_SIG_OPENPGP_KEY_REFRESH} == yes ]] || extra_args+=( -R ) + [[ -n ${VERIFY_SIG_OPENPGP_KEYSERVER+1} ]] && extra_args+=( + --keyserver "${VERIFY_SIG_OPENPGP_KEYSERVER}" + ) + + # GPG upstream knows better than to follow the spec, so we can't + # override this directory. However, there is a clean fallback + # to GNUPGHOME. + addpredict /run/user + + local filename=${file##*/} + [[ ${file} == - ]] && filename='(stdin)' + einfo "Verifying ${filename} ..." + gemato gpg-wrap -K "${key}" "${extra_args[@]}" -- \ + gpg --verify --output="${output_file}" "${file}" || + die "PGP signature verification failed" +} + +# @FUNCTION: verify-sig_verify_signed_checksums +# @USAGE: [] +# @DESCRIPTION: +# Verify the checksums for all files listed in the space-separated list +# (akin to ${A}) using a PGP-signed . +# specified the checksum algorithm (e.g. sha256). can either +# be passed directly, or it defaults to VERIFY_SIG_OPENPGP_KEY_PATH. +# +# The function dies if PGP verification fails, the checksum file +# contains unsigned data, one of the files do not match checksums +# or are missing from the checksum file. +verify-sig_verify_signed_checksums() { + local checksum_file=${1} + local algo=${2} + local files=() + read -r -d '' -a files <<<"${3}" + local key=${4:-${VERIFY_SIG_OPENPGP_KEY_PATH}} + + local chksum_prog chksum_len + case ${algo} in + sha256) + chksum_prog=sha256sum + chksum_len=64 + ;; + *) + die "${FUNCNAME}: unknown checksum algo ${algo}" + ;; + esac + + [[ -n ${key} ]] || + die "${FUNCNAME}: no key passed and VERIFY_SIG_OPENPGP_KEY_PATH unset" + + local checksum filename junk ret=0 count=0 + while read -r checksum filename junk; do + [[ ${#checksum} -eq ${chksum_len} ]] || continue + [[ -z ${checksum//[0-9a-f]} ]] || continue + has "${filename}" "${files[@]}" || continue + [[ -z ${junk} ]] || continue + + "${chksum_prog}" -c --strict - <<<"${checksum} ${filename}" + if [[ ${?} -eq 0 ]]; then + (( count++ )) + else + ret=1 + fi + done < <(verify-sig_verify_message "${checksum_file}" - "${key}") + + [[ ${ret} -eq 0 ]] || + die "${FUNCNAME}: at least one file did not verify successfully" + [[ ${count} -eq ${#files[@]} ]] || + die "${FUNCNAME}: checksums for some of the specified files were missing" +} + +# @FUNCTION: verify-sig_src_unpack +# @DESCRIPTION: +# Default src_unpack override that verifies signatures for all +# distfiles if 'verify-sig' flag is enabled. The function dies if any +# of the signatures fails to verify or if any distfiles are not signed. +# Please write src_unpack() yourself if you need to perform partial +# verification. +verify-sig_src_unpack() { + if use verify-sig; then + local f suffix found + local distfiles=() signatures=() nosigfound=() straysigs=() + + # find all distfiles and signatures, and combine them + for f in ${A}; do + found= + for suffix in .asc .sig; do + if [[ ${f} == *${suffix} ]]; then + signatures+=( "${f}" ) + found=sig + break + else + if has "${f}${suffix}" ${A}; then + distfiles+=( "${f}" ) + found=dist+sig + break + fi + fi + done + if [[ ! ${found} ]]; then + nosigfound+=( "${f}" ) + fi + done + + # check if all distfiles are signed + if [[ ${#nosigfound[@]} -gt 0 ]]; then + eerror "The following distfiles lack detached signatures:" + for f in "${nosigfound[@]}"; do + eerror " ${f}" + done + die "Unsigned distfiles found" + fi + + # check if there are no stray signatures + for f in "${signatures[@]}"; do + if ! has "${f%.*}" "${distfiles[@]}"; then + straysigs+=( "${f}" ) + fi + done + if [[ ${#straysigs[@]} -gt 0 ]]; then + eerror "The following signatures do not match any distfiles:" + for f in "${straysigs[@]}"; do + eerror " ${f}" + done + die "Unused signatures found" + fi + + # now perform the verification + for f in "${signatures[@]}"; do + verify-sig_verify_detached \ + "${DISTDIR}/${f%.*}" "${DISTDIR}/${f}" + done + fi + + # finally, unpack the distfiles + default_src_unpack +} + +_VERIFY_SIG_ECLASS=1 +fi diff --git a/eclass/versionator.eclass b/eclass/versionator.eclass index 0f5d5770350b..8a1066a0fd30 100644 --- a/eclass/versionator.eclass +++ b/eclass/versionator.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2018 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: versionator.eclass @@ -7,6 +7,7 @@ # base-system@gentoo.org # @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 # @BLURB: functions which simplify manipulation of ${PV} and similar version strings +# @DEPRECATED: ver_* functions from EAPI 7 # @DESCRIPTION: # This eclass provides functions which simplify manipulating $PV and similar # variables. Most functions default to working with $PV, although other diff --git a/eclass/virtualx.eclass b/eclass/virtualx.eclass index 6aba6bf488dd..fa16784bd943 100644 --- a/eclass/virtualx.eclass +++ b/eclass/virtualx.eclass @@ -40,7 +40,7 @@ esac # complicated dep is needed. # You can specify the variable BEFORE inherit to add more dependencies. VIRTUALX_DEPEND="${VIRTUALX_DEPEND} - !prefix? ( x11-base/xorg-server[xvfb] ) + x11-base/xorg-server[xvfb] x11-apps/xhost " diff --git a/eclass/xorg-3.eclass b/eclass/xorg-3.eclass index 78c843401cc7..7b4c7f97deb5 100644 --- a/eclass/xorg-3.eclass +++ b/eclass/xorg-3.eclass @@ -168,8 +168,6 @@ if [[ ${FONT} == yes ]]; then FONT_DIR=${FONT_DIR/otf/OTF} FONT_DIR=${FONT_DIR/type1/Type1} FONT_DIR=${FONT_DIR/speedo/Speedo} - - [[ ${PN} = font-misc-misc || ${PN} = font-schumacher-misc || ${PN##*-} = 75dpi || ${PN##*-} = 100dpi || ${PN##*-} = cyrillic ]] && IUSE+=" nls" fi # @ECLASS-VARIABLE: XORG_STATIC @@ -332,30 +330,12 @@ xorg-3_font_configure() { debug-print-function ${FUNCNAME} "$@" if has nls ${IUSE//+} && ! use nls; then - if grep -q -s "disable-all-encodings" ${ECONF_SOURCE:-.}/configure; then - FONT_OPTIONS+=" - --disable-all-encodings - --enable-iso8859-1" - else - FONT_OPTIONS+=" - --disable-iso8859-2 - --disable-iso8859-3 - --disable-iso8859-4 - --disable-iso8859-5 - --disable-iso8859-6 - --disable-iso8859-7 - --disable-iso8859-8 - --disable-iso8859-9 - --disable-iso8859-10 - --disable-iso8859-11 - --disable-iso8859-12 - --disable-iso8859-13 - --disable-iso8859-14 - --disable-iso8859-15 - --disable-iso8859-16 - --disable-jisx0201 - --disable-koi8-r" + if ! grep -q -s "disable-all-encodings" ${ECONF_SOURCE:-.}/configure; then + die "--disable-all-encodings option not available in configure" fi + FONT_OPTIONS+=" + --disable-all-encodings + --enable-iso8859-1" fi } -- cgit v1.2.3