From 0f564cd0f073272faae306bfbc41b952b12fc0b9 Mon Sep 17 00:00:00 2001 From: David Michael Date: Sat, 3 Jul 2021 13:36:05 -0400 Subject: [PATCH 1/2] db-use.eclass: EAPI 8 support This also includes the following cleanups: - Drop support for undocumented banned EAPIs. - Properly document functions for manpage generation. - Make syntax errors fatal. - Support cross-compiling. - Allow db_findver to accept zero arguments for consistency. - Use modern Gentoo bash conventions. Signed-off-by: David Michael --- eclass/db-use.eclass | 166 +++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 102 deletions(-) diff --git a/eclass/db-use.eclass b/eclass/db-use.eclass index d23b08d199967..6a75c6584dd65 100644 --- a/eclass/db-use.eclass +++ b/eclass/db-use.eclass @@ -1,129 +1,91 @@ # Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 -# This is a common location for functions that aid the use of sys-libs/db -# # @ECLASS: db-use.eclass # @MAINTAINER: -# maintainer-needed@gentoo.org +# base-system@gentoo.org # @AUTHOR: # Paul de Vrieze -# @SUPPORTED_EAPIS: 5 6 7 -# @BLURB: This is a common location for functions that aid the use of sys-libs/db +# @SUPPORTED_EAPIS: 5 6 7 8 +# @BLURB: functions that aid the use of sys-libs/db # @DESCRIPTION: -# This eclass is designed to provide helpful functions for depending on -# sys-libs/db. +# This eclass provides helpful functions for depending on sys-libs/db. -# multilib is used for get_libname in all EAPI -case "${EAPI:-0}" in - 0|1|2|3|4|5|6) inherit eapi7-ver multilib ;; - *) inherit multilib ;; +case ${EAPI} in + 5|6|7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -#Convert a version to a db slot +if [[ -z ${_DB_USE_ECLASS} ]]; then +_DB_USE_ECLASS=1 + +# multilib is used for get_libname +[[ ${EAPI} == [56] ]] && inherit eapi7-ver +inherit multilib + +# @FUNCTION: db_ver_to_slot +# @USAGE: +# @DESCRIPTION: +# Convert a version to a db slot. db_ver_to_slot() { - if [ $# -ne 1 ]; then - eerror "Function db_ver_to_slot needs one argument" >&2 - eerror "args given:" >&2 - for f in $@ - do - eerror " - \"$@\"" >&2 - done - return 1 - fi + [[ $# -eq 1 ]] || die "${FUNCNAME} needs one argument" + # 5.0.x uses 5.0 as slot value, so this replacement will break it; # older sys-libs/db might have been using this but it's no longer # the case, so make it work for latest rather than older stuff. - # echo -n "${1/.0/}" - echo -n "$1" + echo "$1" } -#Find the version that correspond to the given atom +# @FUNCTION: db_findver +# @USAGE: [atom] +# @DESCRIPTION: +# Output the best version that corresponds to the given atom. If no atom is +# given, sys-libs/db is used by default. db_findver() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= - if [ $# -ne 1 ]; then - eerror "Function db_findver needs one argument" >&2 - eerror "args given:" >&2 - for f in $@ - do - eerror " - \"$@\"" >&2 - done - return 1 - fi + [[ $# -le 1 ]] || die "${FUNCNAME} needs zero or one arguments" - PKG="$(best_version $1)" - VER="$(ver_cut 1-2 "${PKG/*db-/}")" - if [ -d "${EPREFIX}"/usr/include/db$(db_ver_to_slot "$VER") ]; then - #einfo "Found db version ${VER}" >&2 - echo -n "$VER" - return 0 - else - return 1 - fi + local pkg=$(best_version "${1:-sys-libs/db}") + local ver=$(ver_cut 1-2 "${pkg#*db-}") + [[ -d ${ESYSROOT:-${EPREFIX}}/usr/include/db$(db_ver_to_slot "${ver}") ]] || return 1 + echo "${ver}" } -# Get the include dir for berkeley db. -# This function has two modes. Without any arguments it will give the best -# version available. With arguments that form the versions of db packages -# to test for, it will aim to find the library corresponding to it. - +# @FUNCTION: db_includedir +# @USAGE: [version]... +# @DESCRIPTION: +# Output the include directory for berkeley db. Without any arguments, it will +# give the best version available. With a list of versions, it will output the +# include directory of the first version found. db_includedir() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= - if [ $# -eq 0 ]; then - VER="$(db_findver sys-libs/db)" || return 1 - VER="$(db_ver_to_slot "$VER")" - echo "include version ${VER}" >&2 - if [ -d "${EPREFIX}/usr/include/db${VER}" ]; then - echo -n "${EPREFIX}/usr/include/db${VER}" - return 0 - else - eerror "sys-libs/db package requested, but headers not found" >&2 - return 1 - fi - else - #arguments given - for x in $@ - do - if VER=$(db_findver "=sys-libs/db-${x}*") && - [ -d "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)" ]; then - echo -n "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)" - return 0 - fi - done - eerror "No suitable db version found" - return 1 - fi + local ver + for ver in "${@:-}"; do + ver=$(db_findver ${ver:+"=sys-libs/db-${ver}*"}) && + ver=$(db_ver_to_slot "${ver}") && + [[ -d ${ESYSROOT:-${EPREFIX}}/usr/include/db${ver} ]] && + echo "${ESYSROOT:-${EPREFIX}}/usr/include/db${ver}" && + return + done + eerror "No suitable db version found" + return 1 } -# Get the library name for berkeley db. Something like "db-4.2" will be the -# outcome. This function has two modes. Without any arguments it will give -# the best version available. With arguments that form the versions of db -# packages to test for, it will aim to find the library corresponding to it. - +# @FUNCTION: db_libname +# @USAGE: [version]... +# @DESCRIPTION: +# Output the library name for berkeley db of the form "db-4.2". Without any +# arguments, it will give the best version available. With a list of versions, +# it will output the library name of the first version found. db_libname() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= - if [ $# -eq 0 ]; then - VER="$(db_findver sys-libs/db)" || return 1 - if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then - echo -n "db-${VER}" - return 0 - else - eerror "sys-libs/db package requested, but library not found" >&2 - return 1 - fi - else - #arguments given - for x in $@ - do - if VER=$(db_findver "=sys-libs/db-${x}*"); then - if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then - echo -n "db-${VER}" - return 0 - fi - fi - done - eerror "No suitable db version found" >&2 - return 1 - fi + local ver + for ver in "${@:-}"; do + ver=$(db_findver ${ver:+"=sys-libs/db-${ver}*"}) && + [[ -e ${ESYSROOT:-${EPREFIX}}/usr/$(get_libdir)/libdb-${ver}$(get_libname) ]] && + echo "db-${ver}" && + return + done + eerror "No suitable db version found" + return 1 } + +fi From 81a5324ce68276c1d8964dfc66692cb4ea13e145 Mon Sep 17 00:00:00 2001 From: David Michael Date: Fri, 25 Jun 2021 15:52:01 -0400 Subject: [PATCH 2/2] qmake-utils.eclass: EAPI 8 support Signed-off-by: David Michael --- eclass/qmake-utils.eclass | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eclass/qmake-utils.eclass b/eclass/qmake-utils.eclass index 0d49eb94382c1..d726b36202952 100644 --- a/eclass/qmake-utils.eclass +++ b/eclass/qmake-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2020 Gentoo Authors +# Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: qmake-utils.eclass @@ -6,7 +6,7 @@ # qt@gentoo.org # @AUTHOR: # Davide Pesavento -# @SUPPORTED_EAPIS: 7 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: Common functions for qmake-based packages. # @DESCRIPTION: # Utility eclass providing wrapper functions for Qt5 qmake. @@ -14,14 +14,14 @@ # This eclass does not set any metadata variables nor export any phase # functions. It can be inherited safely. -if [[ -z ${_QMAKE_UTILS_ECLASS} ]]; then -_QMAKE_UTILS_ECLASS=1 - case ${EAPI} in - 7) ;; - *) die "EAPI=${EAPI:-0} is not supported" ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac +if [[ -z ${_QMAKE_UTILS_ECLASS} ]]; then +_QMAKE_UTILS_ECLASS=1 + inherit toolchain-funcs # @FUNCTION: _qmake-utils_banned_func