diff options
Diffstat (limited to 'eclass')
40 files changed, 804 insertions, 504 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz Binary files differindex 2794fb0adf40..d45340dacba2 100644 --- a/eclass/Manifest.gz +++ b/eclass/Manifest.gz diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass index 0b943454a92e..5550e4a2fb10 100644 --- a/eclass/acct-group.eclass +++ b/eclass/acct-group.eclass @@ -75,7 +75,7 @@ readonly ACCT_GROUP_NAME # << Boilerplate ebuild variables >> : ${DESCRIPTION:="System group: ${ACCT_GROUP_NAME}"} : ${SLOT:=0} -: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sh sparc x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} +: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} S=${WORKDIR} diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass index e3ec3966035d..b66fbbf9d0c2 100644 --- a/eclass/acct-user.eclass +++ b/eclass/acct-user.eclass @@ -115,7 +115,7 @@ readonly ACCT_USER_NAME # << Boilerplate ebuild variables >> : ${DESCRIPTION:="System user: ${ACCT_USER_NAME}"} : ${SLOT:=0} -: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sh sparc x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} +: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} S=${WORKDIR} diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass index 9df0e1b93663..625abd0e9d12 100644 --- a/eclass/autotools.eclass +++ b/eclass/autotools.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.eclass @@ -512,7 +512,7 @@ autotools_run_tool() { fi if ${m4flags} ; then - set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include) + set -- "${1}" $(autotools_m4dir_include) $(autotools_m4sysdir_include) "${@:2}" fi # If the caller wants to probe something, then let them do it directly. diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-completion-r1.eclass index 7a69f485a74f..636371df9d6b 100644 --- a/eclass/bash-completion-r1.eclass +++ b/eclass/bash-completion-r1.eclass @@ -91,7 +91,7 @@ get_bashhelpersdir() { } # @FUNCTION: dobashcomp -# @USAGE: file [...] +# @USAGE: <file> [...] # @DESCRIPTION: # Install bash-completion files passed as args. Has EAPI-dependant failure # behavior (like doins). @@ -106,7 +106,7 @@ dobashcomp() { } # @FUNCTION: newbashcomp -# @USAGE: file newname +# @USAGE: <file> <newname> # @DESCRIPTION: # Install bash-completion file under a new name. Has EAPI-dependant failure # behavior (like newins). diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 6776a4b03ac6..6f7ffdb626b4 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -39,7 +39,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # @DESCRIPTION: # Generates the URIs to put in SRC_URI to help fetch dependencies. cargo_crate_uris() { - local -r regex='^(.*)-([0-9]+\.[0-9]+\.[0-9]+.*)$' + local -r regex='^([a-zA-Z0-9_\-]+)-([0-9]+\.[0-9]+\.[0-9]+.*)$' local crate for crate in "$@"; do local name version url diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass index 192d6fa740dc..a45cbd15fee7 100644 --- a/eclass/check-reqs.eclass +++ b/eclass/check-reqs.eclass @@ -1,4 +1,4 @@ -# Copyright 2004-2019 Gentoo Authors +# Copyright 2004-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: check-reqs.eclass @@ -109,7 +109,7 @@ check-reqs_prepare() { -z ${CHECKREQS_DISK_VAR} ]]; then eerror "Set some check-reqs eclass variables if you want to use it." eerror "If you are user and see this message file a bug against the package." - die "${FUNCNAME}: check-reqs eclass called but not actualy used!" + die "${FUNCNAME}: check-reqs eclass called but not actually used!" fi } diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 160f40b1cf8e..3da3b9aeb555 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -371,15 +371,6 @@ cmake_src_configure() { # Fix xdg collision with sandbox xdg_environment_reset - # @SEE CMAKE_BUILD_TYPE - if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then - # Handle release builds - if ! in_iuse debug || ! use debug; then - local CPPFLAGS=${CPPFLAGS} - append-cppflags -DNDEBUG - fi - fi - # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) local build_rules=${BUILD_DIR}/gentoo_rules.cmake diff --git a/eclass/desktop.eclass b/eclass/desktop.eclass index 6fc72ab8ec03..7d5c0f0f9a26 100644 --- a/eclass/desktop.eclass +++ b/eclass/desktop.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: desktop.eclass @@ -10,7 +10,7 @@ if [[ -z ${_DESKTOP_ECLASS} ]]; then _DESKTOP_ECLASS=1 # @FUNCTION: make_desktop_entry -# @USAGE: make_desktop_entry(<command>, [name], [icon], [type], [fields]) +# @USAGE: <command> [name] [icon] [type] [fields] # @DESCRIPTION: # Make a .desktop file. # @@ -162,8 +162,8 @@ make_desktop_entry() { else local desktop_name="${PN}-${slot}" fi - local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop" - #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop + local desktop="${exec%%[[:space:]]*}" + desktop="${T}/${desktop##*/}-${desktop_name}.desktop" # Don't append another ";" when a valid category value is provided. type=${type%;}${type:+;} diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 27ca236ccf5f..fd6c0193d12e 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -40,8 +40,8 @@ # as well. Thus, all the variables defined and documented there are # relevant to the packages using distutils-r1. # -# For more information, please see the wiki: -# https://wiki.gentoo.org/wiki/Project:Python/distutils-r1 +# For more information, please see the Python Guide: +# https://dev.gentoo.org/~mgorny/python-guide/ case "${EAPI:-0}" in 0|1|2|3|4) @@ -120,10 +120,10 @@ _distutils_set_globals() { local bdep=${rdep} if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then - local sdep="dev-python/setuptools[${PYTHON_USEDEP}]" + local sdep=">=dev-python/setuptools-42.0.2[${PYTHON_USEDEP}]" else local sdep="$(python_gen_cond_dep ' - dev-python/setuptools[${PYTHON_MULTI_USEDEP}] + >=dev-python/setuptools-42.0.2[${PYTHON_MULTI_USEDEP}] ')" fi @@ -355,7 +355,7 @@ distutils_enable_sphinx() { if grep -F -q 'sphinx.ext.autodoc' "${confpy}"; then die "distutils_enable_sphinx: --no-autodoc passed but sphinx.ext.autodoc found in ${confpy}" fi - else + elif [[ -z ${_DISTUTILS_SPHINX_PLUGINS[@]} ]]; then if ! grep -F -q 'sphinx.ext.autodoc' "${confpy}"; then die "distutils_enable_sphinx: sphinx.ext.autodoc not found in ${confpy}, pass --no-autodoc" fi @@ -771,13 +771,11 @@ _distutils-r1_wrap_scripts() { local path=${1} local bindir=${2} - local PYTHON_SCRIPTDIR - python_export PYTHON_SCRIPTDIR - + local scriptdir=$(python_get_scriptdir) local f python_files=() non_python_files=() - if [[ -d ${path}${PYTHON_SCRIPTDIR} ]]; then - for f in "${path}${PYTHON_SCRIPTDIR}"/*; do + if [[ -d ${path}${scriptdir} ]]; then + for f in "${path}${scriptdir}"/*; do [[ -d ${f} ]] && die "Unexpected directory: ${f}" debug-print "${FUNCNAME}: found executable at ${f#${path}/}" @@ -894,9 +892,7 @@ distutils-r1_python_install() { ${shopt_save} if [[ -n ${pypy_dirs} ]]; then - local cmd=die - [[ ${EAPI} == [45] ]] && cmd=eqawarn - "${cmd}" "Package installs 'share' in PyPy prefix, see bug #465546." + die "Package installs 'share' in PyPy prefix, see bug #465546." fi if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then @@ -922,8 +918,6 @@ distutils-r1_python_install_all() { ) docompress -x "/usr/share/doc/${PF}/examples" fi - - _DISTUTILS_DEFAULT_CALLED=1 } # @FUNCTION: distutils-r1_run_phase @@ -1146,21 +1140,12 @@ distutils-r1_src_install() { _distutils-r1_run_foreach_impl distutils-r1_python_install fi - local _DISTUTILS_DEFAULT_CALLED - if declare -f python_install_all >/dev/null; then _distutils-r1_run_common_phase python_install_all else _distutils-r1_run_common_phase distutils-r1_python_install_all fi - if [[ ! ${_DISTUTILS_DEFAULT_CALLED} ]]; then - local cmd=die - [[ ${EAPI} == [45] ]] && cmd=eqawarn - - "${cmd}" "QA: python_install_all() didn't call distutils-r1_python_install_all" - fi - _distutils-r1_check_namespace_pth } diff --git a/eclass/ecm.eclass b/eclass/ecm.eclass index 2892b0e0e942..0e3c64b0a2ad 100644 --- a/eclass/ecm.eclass +++ b/eclass/ecm.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: ecm.eclass @@ -218,27 +218,6 @@ case ${ECM_DESIGNERPLUGIN} in ;; esac -# @ECLASS-VARIABLE: KDE_DESIGNERPLUGIN -# @DESCRIPTION: -# If set to "false", do nothing. -# Otherwise, add "designer" to IUSE to toggle build of designer plugins -# and add the necessary BDEPEND. -# TODO: drop after KDE Applications 19.08.3 removal -: ${KDE_DESIGNERPLUGIN:=false} -case ${KDE_DESIGNERPLUGIN} in - true) - IUSE+=" designer" - BDEPEND+=" - designer? ( >=kde-frameworks/kdesignerplugin-${KFMIN}:${KFSLOT} ) - " - ;; - false) ;; - *) - eerror "Unknown value for \${KDE_DESIGNERPLUGIN}" - die "Value ${KDE_DESIGNERPLUGIN} is not supported" - ;; -esac - case ${ECM_EXAMPLES} in true) IUSE+=" examples" @@ -545,11 +524,6 @@ ecm_src_configure() { cmakeargs+=( -DBUILD_DESIGNERPLUGIN=$(usex designer) ) fi - # TODO: drop after KDE Applications 19.08.3 removal - if in_iuse designer && [[ ${KDE_DESIGNERPLUGIN} != false ]] ; then - cmakeargs+=( $(cmake_use_find_package designer KF5DesignerPlugin) ) - fi - if [[ ${ECM_QTHELP} = true ]]; then cmakeargs+=( -DBUILD_QCH=$(usex doc) ) fi diff --git a/eclass/fcaps.eclass b/eclass/fcaps.eclass index 467f955f5e9a..0bb23f8cca70 100644 --- a/eclass/fcaps.eclass +++ b/eclass/fcaps.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: fcaps.eclass @@ -34,7 +34,10 @@ _FCAPS_ECLASS=1 IUSE="+filecaps" # We can't use libcap-ng atm due to #471414. -DEPEND="filecaps? ( sys-libs/libcap )" +case "${EAPI:-0}" in + [0-6]) DEPEND="filecaps? ( sys-libs/libcap )" ;; + *) BDEPEND="filecaps? ( sys-libs/libcap )" ;; +esac # @ECLASS-VARIABLE: FILECAPS # @DEFAULT_UNSET @@ -78,6 +81,11 @@ DEPEND="filecaps? ( sys-libs/libcap )" fcaps() { debug-print-function ${FUNCNAME} "$@" + if [[ ${EUID} != 0 ]] ; then + einfo "Insufficient privileges to execute ${FUNCNAME}, skipping." + return 0 + fi + # Process the user options first. local owner='root' local group='0' diff --git a/eclass/fixheadtails.eclass b/eclass/fixheadtails.eclass index c19d33924aab..475b182843a5 100644 --- a/eclass/fixheadtails.eclass +++ b/eclass/fixheadtails.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2014 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: fixheadtails.eclass @@ -8,8 +8,6 @@ # Original author John Mylchreest <johnm@gentoo.org> # @BLURB: functions to replace obsolete head/tail with POSIX compliant ones -DEPEND=">=sys-apps/sed-4" - _do_sed_fix() { einfo " - fixed $1" sed -i \ diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass index 5cc58f9e9392..0c67ec9f7a76 100644 --- a/eclass/flag-o-matic.eclass +++ b/eclass/flag-o-matic.eclass @@ -56,7 +56,9 @@ setup-allowed-flags() { -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' -mfloat-abi - -mfix-r10000 -mno-fix-r10000 -mthumb -marm + -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 + -mfix-rm7000 -mno-fix-rm7000 -mfix-r10000 -mno-fix-r10000 + -mr10k-cache-barrier -mthumb -marm # gcc 4.5 -mno-fma4 -mno-movbe -mno-xop -mno-lwp @@ -392,6 +394,7 @@ filter-mfpmath() { # Strip *FLAGS of everything except known good/safe flags. This runs over all # flags returned by all_flag_vars(). strip-flags() { + [[ $# -ne 0 ]] && die "strip-flags takes no arguments" local x y var local ALLOWED_FLAGS @@ -433,43 +436,50 @@ test-flag-PROG() { local lang=$2 shift 2 - [[ -z ${comp} || -z $1 ]] && return 1 + if [[ -z ${comp} ]]; then + return 1 + fi + if [[ -z $1 ]]; then + return 1 + fi # verify selected compiler exists before using it comp=($(tc-get${comp})) # 'comp' can already contain compiler options. # 'type' needs a binary name - type -p ${comp[0]} >/dev/null || return 1 + if ! type -p ${comp[0]} >/dev/null; then + return 1 + fi # Set up test file. local in_src in_ext cmdline_extra=() case "${lang}" in # compiler/assembler only c) - in_ext='.c' + in_ext='c' in_src='int main(void) { return 0; }' cmdline_extra+=(-xc -c) ;; c++) - in_ext='.cc' + in_ext='cc' in_src='int main(void) { return 0; }' cmdline_extra+=(-xc++ -c) ;; f77) - in_ext='.f' + in_ext='f' # fixed source form in_src=' end' cmdline_extra+=(-xf77 -c) ;; f95) - in_ext='.f90' + in_ext='f90' in_src='end' cmdline_extra+=(-xf95 -c) ;; # C compiler/assembler/linker c+ld) - in_ext='.c' + in_ext='c' in_src='int main(void) { return 0; }' cmdline_extra+=(-xc) ;; @@ -477,8 +487,19 @@ test-flag-PROG() { local test_in=${T}/test-flag.${in_ext} local test_out=${T}/test-flag.exe - printf "%s\n" "${in_src}" > "${test_in}" || return 1 - + printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'" + + # Currently we rely on warning-free output of a compiler + # before the flag to see if a flag prduces any warnings. + # This has a few drawbacks: + # - if compiler already generates warnings we filter out + # every single flag: bug #712488 + # - if user actually wants to see warnings we just strip + # them regardless of warnings type. + # + # We can add more selective detection of no-op flags via + # '-Werror=ignored-optimization-argument' and similar error options + # similar to what we are doing with '-Qunused-arguments'. local cmdline=( "${comp[@]}" # Clang will warn about unknown gcc flags but exit 0. @@ -618,6 +639,7 @@ test_version_info() { # @DESCRIPTION: # Strip {C,CXX,F,FC}FLAGS of any flags not supported by the active toolchain. strip-unsupported-flags() { + [[ $# -ne 0 ]] && die "strip-unsupported-flags takes no arguments" export CFLAGS=$(test-flags-CC ${CFLAGS}) export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS}) export FFLAGS=$(test-flags-F77 ${FFLAGS}) @@ -630,6 +652,7 @@ strip-unsupported-flags() { # @DESCRIPTION: # Find and echo the value for a particular flag. Accepts shell globs. get-flag() { + [[ $# -ne 1 ]] && die "usage: <flag>" local f var findflag="$1" # this code looks a little flaky but seems to work for @@ -648,18 +671,11 @@ get-flag() { return 1 } -has_m64() { - die "${FUNCNAME}: don't use this anymore" -} - -has_m32() { - die "${FUNCNAME}: don't use this anymore" -} - # @FUNCTION: replace-sparc64-flags # @DESCRIPTION: # Sets mcpu to v8 and uses the original value as mtune if none specified. replace-sparc64-flags() { + [[ $# -ne 0 ]] && die "replace-sparc64-flags takes no arguments" local SPARC64_CPUS="ultrasparc3 ultrasparc v9" if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then @@ -743,6 +759,7 @@ raw-ldflags() { # @FUNCTION: no-as-needed # @RETURN: Flag to disable asneeded behavior for use with append-ldflags. no-as-needed() { + [[ $# -ne 0 ]] && die "no-as-needed takes no arguments" case $($(tc-getLD) -v 2>&1 </dev/null) in *GNU*) # GNU ld echo "-Wl,--no-as-needed" ;; diff --git a/eclass/font.eclass b/eclass/font.eclass index 1287f2273454..bf24701f12fc 100644 --- a/eclass/font.eclass +++ b/eclass/font.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: font.eclass @@ -25,10 +25,10 @@ EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm FONT_SUFFIX=${FONT_SUFFIX:-} # @ECLASS-VARIABLE: FONT_S -# @REQUIRED +# @DEFAULT_UNSET # @DESCRIPTION: -# Space delimited list of directories containing the fonts. -FONT_S=${FONT_S:-${S}} +# Directory containing the fonts. If unset, ${S} is used instead. +# Can also be an array of several directories. # @ECLASS-VARIABLE: FONT_PN # @DESCRIPTION: @@ -159,27 +159,39 @@ font_pkg_setup() { font_src_install() { local dir suffix commondoc - set -- ${FONT_S:-${S}} - if [[ $# -gt 1 ]]; then - # if we have multiple FONT_S elements then we want to recreate the dir - # structure + if [[ $(declare -p FONT_S 2>/dev/null) == "declare -a"* ]]; then + # recreate the directory structure if FONT_S is an array + for dir in "${FONT_S[@]}"; do + pushd "${dir}" > /dev/null || die "pushd ${dir} failed" + insinto "${FONTDIR}/${dir#"${S}"}" + for suffix in ${FONT_SUFFIX}; do + doins *.${suffix} + done + font_xfont_config "${dir}" + popd > /dev/null || die + done + elif [[ ${FONT_S/ } != "${FONT_S}" ]]; then + # backwards compatibility code, can be removed after 2021-02-14 + eqawarn "Using a space-separated list for FONT_S is deprecated." + eqawarn "Use a bash array instead if there are multiple directories." for dir in ${FONT_S}; do - pushd "${dir}" > /dev/null + pushd "${dir}" > /dev/null || die "pushd ${dir} failed" insinto "${FONTDIR}/${dir//${S}/}" for suffix in ${FONT_SUFFIX}; do doins *.${suffix} done font_xfont_config "${dir}" - popd > /dev/null + popd > /dev/null || die done else - pushd "${FONT_S}" > /dev/null + pushd "${FONT_S:-${S}}" > /dev/null \ + || die "pushd ${FONT_S:-${S}} failed" insinto "${FONTDIR}" for suffix in ${FONT_SUFFIX}; do doins *.${suffix} done font_xfont_config - popd > /dev/null + popd > /dev/null || die fi font_fontconfig diff --git a/eclass/gnome2-utils.eclass b/eclass/gnome2-utils.eclass index 06683a7467f8..06643db0f605 100644 --- a/eclass/gnome2-utils.eclass +++ b/eclass/gnome2-utils.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: gnome2-utils.eclass @@ -15,8 +15,9 @@ # * scrollkeeper (old Gnome help system) management [[ ${EAPI:-0} == [012345] ]] && inherit multilib -[[ ${EAPI:-0} == [0123456] ]] && inherit eutils -inherit xdg-utils +# eutils.eclass: emktemp +# xdg-utils.eclass: xdg_environment_reset, xdg_icon_cache_update +inherit eutils xdg-utils case "${EAPI:-0}" in 0|1|2|3|4|5|6|7) ;; @@ -122,7 +123,7 @@ gnome2_gconf_savelist() { # This function should be called from pkg_postinst. gnome2_gconf_install() { has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" - local updater="${EROOT}${GCONFTOOL_BIN}" + local updater="${EROOT%/}${GCONFTOOL_BIN}" if [[ ! -x "${updater}" ]]; then debug-print "${updater} is not executable" @@ -136,15 +137,15 @@ gnome2_gconf_install() { # We are ready to install the GCONF Scheme now unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL - export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" + export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT%/}/;")" einfo "Installing GNOME 2 GConf schemas" local F for F in ${GNOME2_ECLASS_SCHEMAS}; do - if [[ -e "${EROOT}${F}" ]]; then + if [[ -e "${EROOT%/}/${F}" ]]; then debug-print "Installing schema: ${F}" - "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null + "${updater}" --makefile-install-rule "${EROOT%/}/${F}" 1>/dev/null fi done @@ -163,7 +164,7 @@ gnome2_gconf_install() { # database. gnome2_gconf_uninstall() { has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" - local updater="${EROOT}${GCONFTOOL_BIN}" + local updater="${EROOT%/}${GCONFTOOL_BIN}" if [[ ! -x "${updater}" ]]; then debug-print "${updater} is not executable" @@ -176,15 +177,15 @@ gnome2_gconf_uninstall() { fi unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL - export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" + export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT%/}/;")" einfo "Uninstalling GNOME 2 GConf schemas" local F for F in ${GNOME2_ECLASS_SCHEMAS}; do - if [[ -e "${EROOT}${F}" ]]; then + if [[ -e "${EROOT%/}/${F}" ]]; then debug-print "Uninstalling gconf schema: ${F}" - "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null + "${updater}" --makefile-uninstall-rule "${EROOT%/}/${F}" 1>/dev/null fi done @@ -266,7 +267,7 @@ gnome2_scrollkeeper_savelist() { # This function should be called from pkg_postinst and pkg_postrm. gnome2_scrollkeeper_update() { has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" - local updater="${EROOT}${SCROLLKEEPER_UPDATE_BIN}" + local updater="${EROOT%/}${SCROLLKEEPER_UPDATE_BIN}" if [[ ! -x "${updater}" ]] ; then debug-print "${updater} is not executable" @@ -279,7 +280,7 @@ gnome2_scrollkeeper_update() { fi ebegin "Updating scrollkeeper database ..." - "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}" + "${updater}" -q -p "${EROOT%/}${SCROLLKEEPER_DIR}" eend $? } @@ -297,13 +298,12 @@ gnome2_schemas_savelist() { } # @FUNCTION: gnome2_schemas_update -# @USAGE: gnome2_schemas_update # @DESCRIPTION: # Updates GSettings schemas. # This function should be called from pkg_postinst and pkg_postrm. gnome2_schemas_update() { has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" - local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}" + local updater="${EROOT%/}${GLIB_COMPILE_SCHEMAS}" if [[ ! -x ${updater} ]]; then debug-print "${updater} is not executable" @@ -328,16 +328,15 @@ gnome2_gdk_pixbuf_savelist() { } # @FUNCTION: gnome2_gdk_pixbuf_update -# @USAGE: gnome2_gdk_pixbuf_update # @DESCRIPTION: # Updates gdk-pixbuf loader cache if GNOME2_ECLASS_GDK_PIXBUF_LOADERS has some. # This function should be called from pkg_postinst and pkg_postrm. gnome2_gdk_pixbuf_update() { has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" - local updater="${EROOT}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders" + local updater="${EROOT%/}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders" if [[ ! -x ${updater} ]]; then - updater="${EROOT}/usr/bin/gdk-pixbuf-query-loaders" + updater="${EROOT%/}/usr/bin/gdk-pixbuf-query-loaders" fi if [[ ! -x ${updater} ]]; then @@ -354,13 +353,12 @@ gnome2_gdk_pixbuf_update() { local tmp_file=$(emktemp) ${updater} 1> "${tmp_file}" && chmod 0644 "${tmp_file}" && - cp -f "${tmp_file}" "${EROOT}usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" && + cp -f "${tmp_file}" "${EROOT%/}/usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" && rm "${tmp_file}" # don't replace this with mv, required for SELinux support eend $? } # @FUNCTION: gnome2_query_immodules_gtk2 -# @USAGE: gnome2_query_immodules_gtk2 # @DESCRIPTION: # Updates gtk2 immodules/gdk-pixbuf loaders listing. gnome2_query_immodules_gtk2() { @@ -368,13 +366,12 @@ gnome2_query_immodules_gtk2() { [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-2.0 ebegin "Updating gtk2 input method module cache" - GTK_IM_MODULE_FILE="${EROOT}usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache" \ + GTK_IM_MODULE_FILE="${EROOT%/}/usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache" \ "${updater}" --update-cache eend $? } # @FUNCTION: gnome2_query_immodules_gtk3 -# @USAGE: gnome2_query_immodules_gtk3 # @DESCRIPTION: # Updates gtk3 immodules/gdk-pixbuf loaders listing. gnome2_query_immodules_gtk3() { @@ -382,22 +379,21 @@ gnome2_query_immodules_gtk3() { [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-3.0 ebegin "Updating gtk3 input method module cache" - GTK_IM_MODULE_FILE="${EROOT}usr/$(get_libdir)/gtk-3.0/3.0.0/immodules.cache" \ + GTK_IM_MODULE_FILE="${EROOT%/}/usr/$(get_libdir)/gtk-3.0/3.0.0/immodules.cache" \ "${updater}" --update-cache eend $? } # @FUNCTION: gnome2_giomodule_cache_update -# @USAGE: gnome2_giomodule_cache_update # @DESCRIPTION: # Updates glib's gio modules cache. # This function should be called from pkg_postinst and pkg_postrm. gnome2_giomodule_cache_update() { has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" - local updater="${EROOT}/usr/bin/${CHOST}-gio-querymodules" + local updater="${EROOT%/}/usr/bin/${CHOST}-gio-querymodules" if [[ ! -x ${updater} ]]; then - updater="${EROOT}/usr/bin/gio-querymodules" + updater="${EROOT%/}/usr/bin/gio-querymodules" fi if [[ ! -x ${updater} ]]; then diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass index 80ff2902b3ad..17d37494f15f 100644 --- a/eclass/go-module.eclass +++ b/eclass/go-module.eclass @@ -4,28 +4,29 @@ # @ECLASS: go-module.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> +# @AUTHOR: +# William Hubbs <williamh@gentoo.org> +# Robin H. Johnson <robbat2@gentoo.org> # @SUPPORTED_EAPIS: 7 # @BLURB: basic eclass for building software written as go modules # @DESCRIPTION: -# This eclass provides basic settings and functions -# needed by all software written in the go programming language that uses -# go modules. -# -# You will know the software you are packaging uses modules because -# it will have files named go.sum and go.mod in its top-level source -# directory. If it does not have these files, use the golang-* eclasses. +# This eclass provides basic settings and functions needed by all software +# written in the go programming language that uses modules. # -# If it has these files and a directory named vendor in its top-level -# source directory, you only need to inherit the eclass since upstream -# is vendoring the dependencies. +# If the software you are packaging has a file named go.mod in its top +# level directory, it uses modules and your ebuild should inherit this +# eclass. If it does not, your ebuild should use the golang-* eclasses. # -# If it does not have a vendor directory, you should use the EGO_VENDOR -# variable and the go-module_vendor_uris function as shown in the -# example below to handle dependencies. +# If, besides go.mod, your software has a directory named vendor in its +# top level directory, the only thing you need to do is inherit the +# eclass. If there is no vendor directory, you need to also populate +# EGO_SUM and call go-module_set_globals as discussed below. # # Since Go programs are statically linked, it is important that your ebuild's # LICENSE= setting includes the licenses of all statically linked # dependencies. So please make sure it is accurate. +# You can use a utility like dev-util/golicense (network connectivity is +# required) to extract this information from the compiled binary. # # @EXAMPLE: # @@ -33,19 +34,21 @@ # # inherit go-module # -# EGO_VENDOR=( -# "github.com/xenolf/lego 6cac0ea7d8b28c889f709ec7fa92e92b82f490dd" -# "golang.org/x/crypto 453249f01cfeb54c3d549ddb75ff152ca243f9d8 github.com/golang/crypto" +# EGO_SUM=( +# "github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod" +# "github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59" # ) # +# go-module_set_globals +# # SRC_URI="https://github.com/example/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz -# $(go-module_vendor_uris)" +# ${EGO_SUM_SRC_URI}" # # @CODE case ${EAPI:-0} in 7) ;; - *) die "${ECLASS} API in EAPI ${EAPI} not yet established." + *) die "${ECLASS} EAPI ${EAPI} is not supported." esac if [[ -z ${_GO_MODULE} ]]; then @@ -54,6 +57,12 @@ _GO_MODULE=1 BDEPEND=">=dev-lang/go-1.12" +# Workaround for pkgcheck false positive: https://github.com/pkgcore/pkgcheck/issues/214 +# MissingUnpackerDep: version ...: missing BDEPEND="app-arch/unzip" +# Added here rather than to each affected package, so it can be cleaned up just +# once when pkgcheck is improved. +BDEPEND+=" app-arch/unzip" + # Force go to build in module mode. # In this mode the GOPATH environment variable is ignored. # this will become the default in the future. @@ -64,41 +73,69 @@ export GO111MODULE=on export GOCACHE="${T}/go-build" # The following go flags should be used for all builds. -# -mod=vendor stopps downloading of dependencies from the internet. # -v prints the names of packages as they are compiled # -x prints commands as they are executed -export GOFLAGS="-mod=vendor -v -x" +# -mod=readonly do not update go.mod/go.sum but fail if updates are needed +# -mod=vendor use the vendor directory instead of downloading dependencies +export GOFLAGS="-v -x -mod=readonly" # Do not complain about CFLAGS etc since go projects do not use them. QA_FLAGS_IGNORED='.*' # Go packages should not be stripped with strip(1). -RESTRICT="strip" +RESTRICT+=" strip" EXPORT_FUNCTIONS src_unpack pkg_postinst +# @ECLASS-VARIABLE: EGO_SUM +# @DESCRIPTION: +# This is an array based on the go.sum content from inside the target package. +# Each array entry must be quoted and contain information from a single +# line from go.sum. +# +# The format of go.sum is described upstream here: +# https://tip.golang.org/cmd/go/#hdr-Module_authentication_using_go_sum +# +# For inclusion in EGO_SUM, the h1: value and other future extensions SHOULD be +# omitted at this time. The EGO_SUM parser will accept them for ease of ebuild +# creation. +# +# h1:<hash> is the Hash1 structure used by upstream Go +# The Hash1 is MORE stable than Gentoo distfile hashing, and upstream warns +# that it's conceptually possible for the Hash1 value to remain stable while +# the upstream zipfiles change. Here are examples that do NOT change the h1: +# hash, but do change a regular checksum over all bytes of the file: +# - Differing mtimes within zipfile +# - Differing filename ordering with the zipfile +# - Differing zipfile compression parameters +# - Differing zipfile extra fields +# +# For Gentoo usage, the authors of this eclass feel that the h1: hash should +# NOT be included in the EGO_SUM at this time in order to reduce size of the +# ebuilds. This position will be reconsidered in future when a Go module +# distfile collision comes to light, where the Hash1 value of two distfiles is +# the same, but checksums over the file as a byte stream consider the files to +# be different. +# +# This decision does NOT weaken Go module security, as Go will verify the +# go.sum copy of the Hash1 values during building of the package. + # @ECLASS-VARIABLE: EGO_VENDOR # @DESCRIPTION: -# This variable contains a list of vendored packages. -# The items of this array are strings that contain the -# import path and the git commit hash for a vendored package. -# If the import path does not start with github.com, the third argument -# can be used to point to a github repository. +# This variable is deprecated and should no longer be used. Please +# convert your ebuilds to use EGO_SUM. # @FUNCTION: go-module_vendor_uris # @DESCRIPTION: -# Convert the information in EGO_VENDOR to a format suitable for -# SRC_URI. -# A call to this function should be added to SRC_URI in your ebuild if -# the upstream package does not include vendored dependencies. +# This function is deprecated. go-module_vendor_uris() { local hash import line repo x for line in "${EGO_VENDOR[@]}"; do read -r import hash repo x <<< "${line}" - if [[ -n $x ]]; then + if [[ -n ${x} ]]; then eerror "Trailing information in EGO_VENDOR in ${P}.ebuild" eerror "${line}" - eerror "Trailing information is: \"$x\"" + eerror "Trailing information is: \"${x}\"" die "Invalid EGO_VENDOR format" fi : "${repo:=${import}}" @@ -106,18 +143,226 @@ go-module_vendor_uris() { done } +# @ECLASS-VARIABLE: _GOMODULE_GOPROXY_BASEURI +# @DESCRIPTION: +# Golang module proxy service to fetch module files from. Note that the module +# proxy generally verifies modules via the Hash1 code. +# +# Users in China may find some mirrors in the default list blocked, and should +# explicitly set an entry in /etc/portage/mirrors for goproxy to +# https://goproxy.cn/ or another mirror that is not blocked in China. +# See https://arslan.io/2019/08/02/why-you-should-use-a-go-module-proxy/ for +# further details +# +# This variable is NOT intended for user-level configuration of mirrors, but +# rather to cover go modules that might exist only on specific Goproxy +# servers for non-technical reasons. +# +# This variable should NOT be present in user-level configuration e.g. +# /etc/portage/make.conf, as it will violate metadata immutability! +# +# I am considering removing this and just hard coding mirror://goproxy +# below, so please do not rely on it. +: "${_GOMODULE_GOPROXY_BASEURI:=mirror://goproxy/}" + +# @ECLASS-VARIABLE: _GOMODULE_GOSUM_REVERSE_MAP +# @DESCRIPTION: +# Mapping back from Gentoo distfile name to upstream distfile path. +# Associative array to avoid O(N*M) performance when populating the GOPROXY +# directory structure. +declare -A -g _GOMODULE_GOSUM_REVERSE_MAP + +# @FUNCTION: go-module_set_globals +# @DESCRIPTION: +# Convert the information in EGO_SUM for other usage in the ebuild. +# - Populates EGO_SUM_SRC_URI that can be added to SRC_URI +# - Exports _GOMODULE_GOSUM_REVERSE_MAP which provides reverse mapping from +# distfile back to the relative part of SRC_URI, as needed for +# GOPROXY=file:///... +go-module_set_globals() { + local line exts + # for tracking go.sum errors + local error_in_gosum=0 + local -a gosum_errorlines + # used make SRC_URI easier to read + local newline=$'\n' + + # Now parse EGO_SUM + for line in "${EGO_SUM[@]}"; do + local module version modfile version_modfile kvs x + read -r module version_modfile kvs <<< "${line}" + # kvs contains the hash and may contain other data from + # upstream in the future. We do not currently use any of this data. + + # Split 'v0.3.0/go.mod' into 'v0.3.0' and '/go.mod' + # It might NOT have the trailing /go.mod + IFS=/ read -r version modfile x <<<"${version_modfile}" + # Reject multiple slashes + if [[ -n ${x} ]]; then + error_in_gosum=1 + gosum_errorlines+=( "Bad version: ${version_modfile}" ) + continue + fi + + # The modfile variable should be either empty or '/go.mod' + # There is a chance that upstream Go might add something else here in + # the future, and we should be prepared to capture it. + # The .info files do not need to be downloaded, they will be created + # based on the .mod file. + # See https://github.com/golang/go/issues/35922#issuecomment-584824275 + exts=() + local errormsg='' + case "${modfile}" in + '') exts=( zip ) ;; + 'go.mod'|'/go.mod') exts=( mod ) ;; + *) errormsg="Unknown modfile: line='${line}', modfile='${modfile}'" ;; + esac + + # If it was a bad entry, restart the loop + if [[ -n ${errormsg} ]]; then + error_in_gosum=1 + gosum_errorlines+=( "${errormsg} line='${line}', modfile='${modfile}'" ) + continue + fi + + _dir=$(_go-module_gomod_encode "${module}") + + for _ext in "${exts[@]}" ; do + # Relative URI within a GOPROXY for a file + _reluri="${_dir}/@v/${version}.${_ext}" + # SRC_URI: LHS entry + _uri="${_GOMODULE_GOPROXY_BASEURI}/${_reluri}" +# _uri="mirror://goproxy/${_reluri}" + # SRC_URI: RHS entry, encode any slash in the path as + # %2F in the filename + _distfile="${_reluri//\//%2F}" + + EGO_SUM_SRC_URI+=" ${_uri} -> ${_distfile}${newline}" + _GOMODULE_GOSUM_REVERSE_MAP["${_distfile}"]="${_reluri}" + done + done + + if [[ ${error_in_gosum} != 0 ]]; then + eerror "Trailing information in EGO_SUM in ${P}.ebuild" + for line in "${gosum_errorlines[@]}" ; do + eerror "${line}" + done + die "Invalid EGO_SUM format" + fi + + # Ensure these variables are not changed past this point + readonly EGO_SUM + readonly EGO_SUM_SRC_URI + readonly _GOMODULE_GOSUM_REVERSE_MAP + + # Set the guard that we are safe + _GO_MODULE_SET_GLOBALS_CALLED=1 +} + # @FUNCTION: go-module_src_unpack # @DESCRIPTION: +# - If EGO_VENDOR is set, use the deprecated function to unpack the base +# tarballs and the tarballs indicated in EGO_VENDOR to the correct +# locations. +# - Otherwise, if EGO_SUM is set, unpack the base tarball(s) and set up the +# local go proxy. +# - Otherwise do a normal unpack. +go-module_src_unpack() { + if [[ "${#EGO_VENDOR[@]}" -gt 0 ]]; then + _go-module_src_unpack_vendor + elif [[ "${#EGO_SUM[@]}" -gt 0 ]]; then + _go-module_src_unpack_gosum + else + default + fi +} + +# @FUNCTION: _go-module_src_unpack_gosum +# @DESCRIPTION: +# Populate a GOPROXY directory hierarchy with distfiles from EGO_SUM and +# unpack the base distfiles. +# +# Exports GOPROXY environment variable so that Go calls will source the +# directory correctly. +_go-module_src_unpack_gosum() { + # shellcheck disable=SC2120 + debug-print-function "${FUNCNAME}" "$@" + + if [[ ! ${_GO_MODULE_SET_GLOBALS_CALLED} ]]; then + die "go-module_set_globals must be called in global scope" + fi + + local goproxy_dir="${T}/go-proxy" + mkdir -p "${goproxy_dir}" || die + + # For each Golang module distfile, look up where it's supposed to go, and + # symlink into place. + local f + local goproxy_mod_dir + for f in ${A}; do + goproxy_mod_path="${_GOMODULE_GOSUM_REVERSE_MAP["${f}"]}" + if [[ -n "${goproxy_mod_path}" ]]; then + debug-print-function "Populating go proxy for ${goproxy_mod_path}" + # Build symlink hierarchy + goproxy_mod_dir=$( dirname "${goproxy_dir}"/"${goproxy_mod_path}" ) + mkdir -p "${goproxy_mod_dir}" || die + ln -sf "${DISTDIR}"/"${f}" "${goproxy_dir}/${goproxy_mod_path}" || + die "Failed to ln" + local v=${goproxy_mod_path} + v="${v%.mod}" + v="${v%.zip}" + v="${v//*\/}" + _go-module_gosum_synthesize_files "${goproxy_mod_dir}" "${v}" + else + unpack "$f" + fi + done + export GOPROXY="file://${goproxy_dir}" + + # Validate the gosum now + _go-module_src_unpack_verify_gosum +} + +# @FUNCTION: _go-module_gosum_synthesize_files +# @DESCRIPTION: +# Given a path & version, populate all Goproxy metadata files which aren't +# needed to be downloaded directly. +# - .../@v/${version}.info +# - .../@v/list +_go-module_gosum_synthesize_files() { + local target=$1 + local version=$2 + # 'go get' doesn't care about the hash of the .info files, they + # just need a 'version' element! + # This saves a download of a tiny file + # The .time key is omitted, because that is the time a module was added + # to the upstream goproxy, and not metadata about the module itself. + cat >"${target}/${version}.info" <<-EOF + { + "Version": "${version}", + "shortName": "${version}", + "Name": "${version}" + } + EOF + listfile="${target}"/list + if ! grep -sq -x -e "${version}" "${listfile}" 2>/dev/null; then + echo "${version}" >>"${listfile}" + fi +} + +# @FUNCTION: _go-module_src_unpack_vendor +# @DESCRIPTION: # Extract all archives in ${a} which are not nentioned in ${EGO_VENDOR} # to their usual locations then extract all archives mentioned in # ${EGO_VENDOR} to ${S}/vendor. -go-module_src_unpack() { - debug-print-function ${FUNCNAME} "$@" +_go-module_src_unpack_vendor() { + # shellcheck disable=SC2120 + debug-print-function "${FUNCNAME}" "$@" local f hash import line repo tarball vendor_tarballs x vendor_tarballs=() for line in "${EGO_VENDOR[@]}"; do read -r import hash repo x <<< "${line}" - if [[ -n $x ]]; then + if [[ -n ${x} ]]; then eerror "Trailing information in EGO_VENDOR in ${P}.ebuild" eerror "${line}" die "Invalid EGO_VENDOR format" @@ -125,10 +370,10 @@ go-module_src_unpack() { : "${repo:=${import}}" vendor_tarballs+=("${repo//\//-}-${hash}.tar.gz") done - for f in $A; do - [[ -n ${vendor_tarballs[*]} ]] && has "$f" "${vendor_tarballs[@]}" && + for f in ${A}; do + [[ -n ${vendor_tarballs[*]} ]] && has "${f}" "${vendor_tarballs[@]}" && continue - unpack "$f" + unpack "${f}" done [[ -z ${vendor_tarballs[*]} ]] && return @@ -143,6 +388,39 @@ go-module_src_unpack() { -f "${DISTDIR}/${tarball}" || die eend done + # replace GOFLAGS if EGO_VENDOR is being used + [[ ${#EGO_VENDOR[@]} -gt 0 ]] && + GOFLAGS="-v -x -mod=vendor" + eqawarn "${P}.ebuild: EGO_VENDOR will be removed in the future." + eqawarn "Please request that the author migrate to EGO_SUM." +} + +# @FUNCTION: _go-module_src_unpack_verify_gosum +# @DESCRIPTION: +# Validate the Go modules declared by EGO_SUM are sufficient to cover building +# the package, without actually building it yet. +_go-module_src_unpack_verify_gosum() { + # shellcheck disable=SC2120 + debug-print-function "${FUNCNAME}" "$@" + + if [[ ! ${_GO_MODULE_SET_GLOBALS_CALLED} ]]; then + die "go-module_set_globals must be called in global scope" + fi + + cd "${S}" + + # Cleanup the modules before starting anything else + # This will print 'downloading' messages, but it's accessing content from + # the $GOPROXY file:/// URL! + einfo "Tidying go.mod/go.sum" + go mod tidy >/dev/null + + # This used to call 'go get' to verify by fetching everything from the main + # go.mod. However 'go get' also turns out to recursively try to fetch + # everything in dependencies, even materials that are used only for tests + # of the dependencies, or code generation. + # If EGO_SUM is missing an entry now, it will fail during the build process + # rather than this helper function. } # @FUNCTION: go-module_live_vendor @@ -150,13 +428,14 @@ go-module_src_unpack() { # This function is used in live ebuilds to vendor the dependencies when # upstream doesn't vendor them. go-module_live_vendor() { - debug-print-function ${FUNCNAME} "$@" + debug-print-function "${FUNCNAME}" "$@" + # shellcheck disable=SC2086 has live ${PROPERTIES} || die "${FUNCNAME} only allowed in live ebuilds" [[ "${EBUILD_PHASE}" == unpack ]] || die "${FUNCNAME} only allowed in src_unpack" - [[ -d "${S}"/vendor ]] || + [[ -d "${S}"/vendor ]] && die "${FUNCNAME} only allowed when upstream isn't vendoring" pushd "${S}" >& /dev/null || die @@ -168,7 +447,7 @@ go-module_live_vendor() { # @DESCRIPTION: # Display a warning about security updates for Go programs. go-module_pkg_postinst() { - debug-print-function ${FUNCNAME} "$@" + debug-print-function "${FUNCNAME}" "$@" [[ -n ${REPLACING_VERSIONS} ]] && return 0 ewarn "${PN} is written in the Go programming language." ewarn "Since this language is statically linked, security" @@ -179,4 +458,30 @@ go-module_pkg_postinst() { ewarn "stable tree." } +# @FUNCTION: _go-module_gomod_encode +# @DESCRIPTION: +# Encode the name(path) of a Golang module in the format expected by Goproxy. +# +# Upper letters are replaced by their lowercase version with a '!' prefix. +# +_go-module_gomod_encode() { + ## Python: + # return re.sub('([A-Z]{1})', r'!\1', s).lower() + + ## Sed: + ## This uses GNU Sed extension \l to downcase the match + #echo "${module}" |sed 's,[A-Z],!\l&,g' + # + # Bash variant: + debug-print-function "${FUNCNAME}" "$@" + #local re input lower + re='(.*)([A-Z])(.*)' + input="${1}" + while [[ ${input} =~ ${re} ]]; do + lower='!'"${BASH_REMATCH[2],}" + input="${BASH_REMATCH[1]}${lower}${BASH_REMATCH[3]}" + done + echo "${input}" +} + fi diff --git a/eclass/gstreamer.eclass b/eclass/gstreamer.eclass index 319f88128518..e592d726863d 100644 --- a/eclass/gstreamer.eclass +++ b/eclass/gstreamer.eclass @@ -139,7 +139,7 @@ gstreamer_get_plugins() { } # @FUNCTION: gstreamer_get_plugin_dir -# @USAGE: gstreamer_get_plugin_dir [<build_dir>] +# @USAGE: [build_dir] # @INTERNAL # @DESCRIPTION: # Finds plugin build directory and output it. @@ -161,7 +161,7 @@ gstreamer_get_plugin_dir() { } # @FUNCTION: gstreamer_system_link -# @USAGE: gstreamer_system_link gst-libs/gst/audio:gstreamer-audio [...] +# @USAGE: <gst-libs/gst/audio:gstreamer-audio> [...] # @DESCRIPTION: # Walks through makefiles in order to make sure build will link against system # libraries. diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index 1e46e9b55780..29f13e031f48 100644 --- a/eclass/java-utils-2.eclass +++ b/eclass/java-utils-2.eclass @@ -266,7 +266,7 @@ java-pkg_addres() { } # @FUNCTION: java-pkg_rm_files -# @USAGE: java-pkg_rm_files File1.java File2.java ... +# @USAGE: <File1.java> [File2.java] ... # @DESCRIPTION: # Remove unneeded files in ${S}. # diff --git a/eclass/kde.org.eclass b/eclass/kde.org.eclass index 2776b5b972f2..bb9bd618eb2e 100644 --- a/eclass/kde.org.eclass +++ b/eclass/kde.org.eclass @@ -110,10 +110,9 @@ _kde.org_calculate_src_uri() { if [[ ${KDE_RELEASE_SERVICE} = true ]]; then case ${PV} in ??.??.[6-9]? ) - _src_uri+="unstable/applications/${PV}/src/" + _src_uri+="unstable/release-service/${PV}/src/" RESTRICT+=" mirror" ;; - 19.08.3? ) _src_uri+="stable/applications/${PV}/src/" ;; *) _src_uri+="stable/release-service/${PV}/src/" ;; esac fi diff --git a/eclass/kde5-functions.eclass b/eclass/kde5-functions.eclass index bbb8d6d90f25..df63e517bef8 100644 --- a/eclass/kde5-functions.eclass +++ b/eclass/kde5-functions.eclass @@ -1,6 +1,7 @@ # Copyright 1999-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +# @DEAD # @ECLASS: kde5-functions.eclass # @MAINTAINER: # kde@gentoo.org @@ -15,6 +16,11 @@ if [[ -z ${_KDE5_FUNCTIONS_ECLASS} ]]; then _KDE5_FUNCTIONS_ECLASS=1 +if [[ -z ${_KDE5_ECLASS} ]]; then + eerror "This DEAD eclass must not be inherited directly by an ebuild." + die "Removal due on 2020-04-16." +fi + case ${EAPI} in 7) ;; *) die "EAPI=${EAPI:-0} is not supported" ;; diff --git a/eclass/kde5.eclass b/eclass/kde5.eclass index 884d4b4a47d5..0b8aa82ecf70 100644 --- a/eclass/kde5.eclass +++ b/eclass/kde5.eclass @@ -1,6 +1,7 @@ # Copyright 1999-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +# @DEAD # @ECLASS: kde5.eclass # @MAINTAINER: # kde@gentoo.org @@ -239,11 +240,16 @@ _kde5_strip_handbook_translations() { # @FUNCTION: cmake_use_find_package # @USAGE: <USE flag> <package name> # @DESCRIPTION: -# Compatibility alias for cmake.eclass -> cmake.eclass +# Compatibility alias for cmake-utils.eclass -> cmake.eclass cmake-utils_use_find_package() { cmake_use_find_package "$@" ; } +_kde5_really_dead() { + eqawarn "${CATEGORY}/${PN} is using DEAD kde5.eclass that will be removed" + eqawarn "on 2020-04-16. Read PORTING notes inside kde5.eclass and kde5-functions.eclass." +} + # @FUNCTION: kde5_pkg_pretend # @DESCRIPTION: # Checks if the active compiler meets the minimum version requirements. @@ -261,6 +267,7 @@ kde5_pkg_pretend() { # Checks if the active compiler meets the minimum version requirements. kde5_pkg_setup() { debug-print-function ${FUNCNAME} "$@" + _kde5_really_dead case ${KDE_AUTODEPS} in false) ;; *) ecm_pkg_setup ;; @@ -411,6 +418,7 @@ kde5_pkg_preinst() { # Updates the various XDG caches (icon, desktop, mime) if necessary. kde5_pkg_postinst() { debug-print-function ${FUNCNAME} "$@" + _kde5_really_dead case ${KDE_AUTODEPS} in false) xdg_pkg_postinst ;; *) ecm_pkg_postinst ;; diff --git a/eclass/leechcraft.eclass b/eclass/leechcraft.eclass index 16b4f8d4c93e..c53f6712d863 100644 --- a/eclass/leechcraft.eclass +++ b/eclass/leechcraft.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: leechcraft.eclass @@ -22,18 +22,16 @@ # Only EAPI >=6 is supported case ${EAPI:-0} in - 6|7) ;; + 6) inherit cmake-utils ;; + 7) inherit cmake ;; *) die "EAPI not supported, bug ebuild mantainer" ;; esac -inherit cmake-utils - if [[ ${PV} == 9999 ]]; then EGIT_REPO_URI="https://github.com/0xd34df00d/leechcraft.git" inherit git-r3 else - DEPEND="app-arch/xz-utils" SRC_URI="https://dist.leechcraft.org/LeechCraft/${PV}/leechcraft-${PV}.tar.xz" S="${WORKDIR}/leechcraft-${PV}" fi @@ -41,6 +39,12 @@ 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: diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass index 98ec0ac8dabe..44eebcf52a92 100644 --- a/eclass/linux-info.eclass +++ b/eclass/linux-info.eclass @@ -159,7 +159,7 @@ qeerror() { qout eerror "${@}" ; } # --------------------------------------- # @FUNCTION: getfilevar -# @USAGE: variable configfile +# @USAGE: <variable> <configfile> # @RETURN: the value of the variable # @DESCRIPTION: # It detects the value of the variable defined in the file configfile. This is @@ -195,7 +195,7 @@ getfilevar() { } # @FUNCTION: getfilevar_noexec -# @USAGE: variable configfile +# @USAGE: <variable> <configfile> # @RETURN: the value of the variable # @DESCRIPTION: # It detects the value of the variable defined in the file configfile. @@ -310,7 +310,7 @@ require_configured_kernel() { } # @FUNCTION: linux_chkconfig_present -# @USAGE: option +# @USAGE: <option> # @RETURN: true or false # @DESCRIPTION: # It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config @@ -322,7 +322,7 @@ linux_chkconfig_present() { } # @FUNCTION: linux_chkconfig_module -# @USAGE: option +# @USAGE: <option> # @RETURN: true or false # @DESCRIPTION: # It checks that CONFIG_<option>=m is present in the current kernel .config @@ -334,7 +334,7 @@ linux_chkconfig_module() { } # @FUNCTION: linux_chkconfig_builtin -# @USAGE: option +# @USAGE: <option> # @RETURN: true or false # @DESCRIPTION: # It checks that CONFIG_<option>=y is present in the current kernel .config @@ -346,7 +346,7 @@ linux_chkconfig_builtin() { } # @FUNCTION: linux_chkconfig_string -# @USAGE: option +# @USAGE: <option> # @RETURN: CONFIG_<option> # @DESCRIPTION: # It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel). @@ -361,7 +361,7 @@ linux_chkconfig_string() { # --------------------------------------- # @FUNCTION: kernel_is -# @USAGE: [-lt -gt -le -ge -eq] major_number [minor_number patch_number] +# @USAGE: [-lt -gt -le -ge -eq] <major_number> [minor_number patch_number] # @RETURN: true or false # @DESCRIPTION: # It returns true when the current kernel version satisfies the comparison against the passed version. diff --git a/eclass/linux-mod.eclass b/eclass/linux-mod.eclass index 5b1b8f65cee0..7c26a4a1539d 100644 --- a/eclass/linux-mod.eclass +++ b/eclass/linux-mod.eclass @@ -214,7 +214,7 @@ use_m() { } # @FUNCTION: convert_to_m -# @USAGE: /path/to/the/file +# @USAGE: </path/to/the/file> # @DESCRIPTION: # It converts a file (e.g. a makefile) to use M= instead of SUBDIRS= convert_to_m() { diff --git a/eclass/meson.eclass b/eclass/meson.eclass index 0588590b31e1..16e17dd4a384 100644 --- a/eclass/meson.eclass +++ b/eclass/meson.eclass @@ -149,6 +149,9 @@ _meson_create_cross_file() { # This may require adjustment based on CFLAGS local cpu=${CHOST%%-*} + local needs_exe_wrapper=false + tc-is-cross-compiler && needs_exe_wrapper=true + cat > "${T}/meson.${CHOST}.${ABI}" <<-EOF [binaries] ar = $(_meson_env_array "$(tc-getAR)") @@ -173,6 +176,7 @@ _meson_create_cross_file() { objc_link_args = $(_meson_env_array "${OBJCFLAGS} ${LDFLAGS}") objcpp_args = $(_meson_env_array "${OBJCXXFLAGS} ${CPPFLAGS}") objcpp_link_args = $(_meson_env_array "${OBJCXXFLAGS} ${LDFLAGS}") + needs_exe_wrapper = ${needs_exe_wrapper} [host_machine] system = '${system}' diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass index 63bde5cbb601..bbaab709b4fa 100644 --- a/eclass/multilib.eclass +++ b/eclass/multilib.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: multilib.eclass @@ -294,11 +294,22 @@ get_modname() { } # This is for the toolchain to setup profile variables when pulling in -# a crosscompiler (and thus they aren't set in the profile) +# a crosscompiler (and thus they aren't set in the profile). multilib_env() { local CTARGET=${1:-${CTARGET}} local cpu=${CTARGET%%*-} + if [[ ${CTARGET} = *-musl* ]]; then + # musl has no multilib support and can run only in 'lib': + # - https://bugs.gentoo.org/675954 + # - https://gcc.gnu.org/PR90077 + # - https://github.com/gentoo/musl/issues/245 + : ${MULTILIB_ABIS=default} + : ${DEFAULT_ABI=default} + export MULTILIB_ABIS DEFAULT_ABI + return + fi + case ${cpu} in aarch64*) # Not possible to do multilib with aarch64 and a single toolchain. diff --git a/eclass/office-ext-r1.eclass b/eclass/office-ext-r1.eclass index 04df18698fb8..298f958a13aa 100644 --- a/eclass/office-ext-r1.eclass +++ b/eclass/office-ext-r1.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: office-ext-r1.eclass @@ -12,11 +12,14 @@ # Eclass for easing maintenance of libreoffice/openoffice extensions. case "${EAPI:-0}" in - 5|6) inherit eutils multilib ;; + 5|6) inherit multilib ;; 7) ;; *) die "EAPI=${EAPI} is not supported" ;; esac +# eutils.eclass: emktemp +inherit eutils + OEXT_EXPORTED_FUNCTIONS="src_unpack src_install pkg_postinst pkg_prerm" # @ECLASS-VARIABLE: OFFICE_REQ_USE diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass index 878e337ff3c2..eef4c57b7e25 100644 --- a/eclass/python-any-r1.eclass +++ b/eclass/python-any-r1.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: python-any-r1.eclass @@ -33,8 +33,8 @@ # packages using python-any-r1, and there is no need ever to inherit # both. # -# For more information, please see the wiki: -# https://wiki.gentoo.org/wiki/Project:Python/python-any-r1 +# For more information, please see the Python Guide: +# https://dev.gentoo.org/~mgorny/python-guide/ case "${EAPI:-0}" in [0-4]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;; @@ -151,7 +151,7 @@ _python_any_set_globals() { _python_set_impls for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do - python_export "${i}" PYTHON_PKG_DEP + _python_export "${i}" PYTHON_PKG_DEP # note: need to strip '=' slot operator for || deps deps="${PYTHON_PKG_DEP/:0=/:0} ${deps}" @@ -232,7 +232,7 @@ python_gen_any_dep() { local i PYTHON_PKG_DEP out= for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)" - python_export "${i}" PYTHON_PKG_DEP + _python_export "${i}" PYTHON_PKG_DEP local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}} # note: need to strip '=' slot operator for || deps @@ -299,16 +299,18 @@ python_setup() { ewarn ewarn "Dependencies won't be satisfied, and EPYTHON/eselect-python will be ignored." - python_export "${impls[0]}" EPYTHON PYTHON - python_wrapper_setup + _python_export "${impls[0]}" EPYTHON PYTHON + _python_wrapper_setup + einfo "Using ${EPYTHON} to build" return fi # first, try ${EPYTHON}... maybe it's good enough for us. if [[ ${EPYTHON} ]]; then if _python_EPYTHON_supported "${EPYTHON}"; then - python_export EPYTHON PYTHON - python_wrapper_setup + _python_export EPYTHON PYTHON + _python_wrapper_setup + einfo "Using ${EPYTHON} to build" return fi fi @@ -322,8 +324,9 @@ python_setup() { # no eselect-python? break elif _python_EPYTHON_supported "${i}"; then - python_export "${i}" EPYTHON PYTHON - python_wrapper_setup + _python_export "${i}" EPYTHON PYTHON + _python_wrapper_setup + einfo "Using ${EPYTHON} to build" return fi done @@ -331,9 +334,10 @@ python_setup() { # fallback to best installed impl. # (reverse iteration over _PYTHON_SUPPORTED_IMPLS) for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do - python_export "${_PYTHON_SUPPORTED_IMPLS[i]}" EPYTHON PYTHON + _python_export "${_PYTHON_SUPPORTED_IMPLS[i]}" EPYTHON PYTHON if _python_EPYTHON_supported "${EPYTHON}"; then - python_wrapper_setup + _python_wrapper_setup + einfo "Using ${EPYTHON} to build" return fi done diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index dd350a436fa5..8687b595123a 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.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: python-r1.eclass @@ -26,8 +26,8 @@ # in the packages using python-r1, and there is no need ever to inherit # both. # -# For more information, please see the wiki: -# https://wiki.gentoo.org/wiki/Project:Python/python-r1 +# For more information, please see the Python Guide: +# https://dev.gentoo.org/~mgorny/python-guide/ case "${EAPI:-0}" in 0|1|2|3|4) @@ -173,7 +173,7 @@ _python_set_globals() { _python_set_impls for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do - python_export "${i}" PYTHON_PKG_DEP + _python_export "${i}" PYTHON_PKG_DEP deps+="python_targets_${i}? ( ${PYTHON_PKG_DEP} ) " done @@ -485,7 +485,7 @@ python_gen_impl_dep() { for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do if _python_impl_matches "${impl}" "${@}"; then local PYTHON_PKG_DEP - python_export "${impl}" PYTHON_PKG_DEP + _python_export "${impl}" PYTHON_PKG_DEP matches+=( "python_targets_${impl}? ( ${PYTHON_PKG_DEP} )" ) fi done @@ -563,7 +563,7 @@ python_gen_any_dep() { for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do if _python_impl_matches "${i}" "${@}"; then local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)" - python_export "${i}" PYTHON_PKG_DEP + _python_export "${i}" PYTHON_PKG_DEP local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}} # note: need to strip '=' slot operator for || deps @@ -637,8 +637,8 @@ _python_multibuild_wrapper() { local -x EPYTHON PYTHON local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH} - python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON - python_wrapper_setup + _python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON + _python_wrapper_setup "${@}" } @@ -760,7 +760,7 @@ python_setup() { # check patterns _python_impl_matches "${impl}" "${@}" || continue - python_export "${impl}" EPYTHON PYTHON + _python_export "${impl}" EPYTHON PYTHON # if python_check_deps() is declared, switch into any-of mode if [[ ${has_check_deps} ]]; then @@ -784,7 +784,8 @@ python_setup() { die "${FUNCNAME}: no enabled implementation satisfy requirements" fi - python_wrapper_setup + _python_wrapper_setup + einfo "Using ${EPYTHON} in global scope" } # @FUNCTION: python_replicate_script @@ -802,7 +803,7 @@ python_replicate_script() { local _PYTHON_FIX_SHEBANG_QUIET=1 local PYTHON_SCRIPTDIR - python_export PYTHON_SCRIPTDIR + _python_export PYTHON_SCRIPTDIR ( exeopts -m 0755 diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass index 739a394ddd18..ab3df94dcf11 100644 --- a/eclass/python-single-r1.eclass +++ b/eclass/python-single-r1.eclass @@ -33,8 +33,8 @@ # in the packages using python-single-r1, and there is no need ever # to inherit both. # -# For more information, please see the wiki: -# https://wiki.gentoo.org/wiki/Project:Python/python-single-r1 +# For more information, please see the Python Guide: +# https://dev.gentoo.org/~mgorny/python-guide/ case "${EAPI:-0}" in 0|1|2|3|4) @@ -213,7 +213,7 @@ _python_single_set_globals() { local deps= i PYTHON_PKG_DEP for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do - python_export "${i}" PYTHON_PKG_DEP + _python_export "${i}" PYTHON_PKG_DEP # 1) well, python-exec would suffice as an RDEP # but no point in making this overcomplex, BDEP doesn't hurt anyone # 2) python-exec should be built with all targets forced anyway @@ -436,7 +436,7 @@ python_gen_impl_dep() { for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do if _python_impl_matches "${impl}" "${@}"; then local PYTHON_PKG_DEP - python_export "${impl}" PYTHON_PKG_DEP + _python_export "${impl}" PYTHON_PKG_DEP matches+=( "python_single_target_${impl}? ( ${PYTHON_PKG_DEP} )" ) fi done @@ -465,8 +465,9 @@ python_setup() { ewarn ewarn "Dependencies won't be satisfied, and PYTHON_SINGLE_TARGET flags will be ignored." - python_export "${impls[0]}" EPYTHON PYTHON - python_wrapper_setup + _python_export "${impls[0]}" EPYTHON PYTHON + _python_wrapper_setup + einfo "Using ${EPYTHON} to build" return fi @@ -482,8 +483,9 @@ python_setup() { die "More than one implementation in PYTHON_SINGLE_TARGET." fi - python_export "${impl}" EPYTHON PYTHON - python_wrapper_setup + _python_export "${impl}" EPYTHON PYTHON + _python_wrapper_setup + einfo "Using ${EPYTHON} to build" fi done diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 91a32434dfaa..77982c9b9c76 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.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: python-utils-r1.eclass @@ -16,8 +16,8 @@ # This eclass does not set any metadata variables nor export any phase # functions. It can be inherited safely. # -# For more information, please see the wiki: -# https://wiki.gentoo.org/wiki/Project:Python/python-utils-r1 +# For more information, please see the Python Guide: +# https://dev.gentoo.org/~mgorny/python-guide/ case "${EAPI:-0}" in [0-4]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;; @@ -198,7 +198,7 @@ _python_impl_matches() { # This variable is set automatically in the following contexts: # # python-r1: Set in functions called by python_foreach_impl() or after -# calling python_export_best(). +# calling python_setup(). # # python-single-r1: Set after calling python-single-r1_pkg_setup(). # @@ -217,7 +217,7 @@ _python_impl_matches() { # This variable is set automatically in the following contexts: # # python-r1: Set in functions called by python_foreach_impl() or after -# calling python_export_best(). +# calling python_setup(). # # python-single-r1: Set after calling python-single-r1_pkg_setup(). # @@ -228,116 +228,24 @@ _python_impl_matches() { # python2.7 # @CODE -# @ECLASS-VARIABLE: PYTHON_SITEDIR -# @DEFAULT_UNSET -# @DESCRIPTION: -# The path to Python site-packages directory. -# -# Set and exported on request using python_export(). -# Requires a proper build-time dependency on the Python implementation. -# -# Example value: -# @CODE -# /usr/lib64/python2.7/site-packages -# @CODE - -# @ECLASS-VARIABLE: PYTHON_INCLUDEDIR -# @DEFAULT_UNSET -# @DESCRIPTION: -# The path to Python include directory. -# -# Set and exported on request using python_export(). -# Requires a proper build-time dependency on the Python implementation. -# -# Example value: -# @CODE -# /usr/include/python2.7 -# @CODE - -# @ECLASS-VARIABLE: PYTHON_LIBPATH -# @DEFAULT_UNSET -# @DESCRIPTION: -# The path to Python library. -# -# Set and exported on request using python_export(). -# Valid only for CPython. Requires a proper build-time dependency -# on the Python implementation. -# -# Example value: -# @CODE -# /usr/lib64/libpython2.7.so -# @CODE - -# @ECLASS-VARIABLE: PYTHON_CFLAGS -# @DEFAULT_UNSET -# @DESCRIPTION: -# Proper C compiler flags for building against Python. Obtained from -# pkg-config or python-config. -# -# Set and exported on request using python_export(). -# Valid only for CPython. Requires a proper build-time dependency -# on the Python implementation and on pkg-config. -# -# Example value: -# @CODE -# -I/usr/include/python2.7 -# @CODE - -# @ECLASS-VARIABLE: PYTHON_LIBS -# @DEFAULT_UNSET -# @DESCRIPTION: -# Proper C compiler flags for linking against Python. Obtained from -# pkg-config or python-config. -# -# Set and exported on request using python_export(). -# Valid only for CPython. Requires a proper build-time dependency -# on the Python implementation and on pkg-config. -# -# Example value: -# @CODE -# -lpython2.7 -# @CODE - -# @ECLASS-VARIABLE: PYTHON_CONFIG -# @DEFAULT_UNSET +# @FUNCTION: python_export +# @USAGE: [<impl>] <variables>... +# @INTERNAL # @DESCRIPTION: -# Path to the python-config executable. -# -# Set and exported on request using python_export(). -# Valid only for CPython. Requires a proper build-time dependency -# on the Python implementation and on pkg-config. -# -# Example value: -# @CODE -# /usr/bin/python2.7-config -# @CODE +# Backwards compatibility function. The relevant API is now considered +# private, please use python_get* instead. +python_export() { + debug-print-function ${FUNCNAME} "${@}" -# @ECLASS-VARIABLE: PYTHON_PKG_DEP -# @DEFAULT_UNSET -# @DESCRIPTION: -# The complete dependency on a particular Python package as a string. -# -# Set and exported on request using python_export(). -# -# Example value: -# @CODE -# dev-lang/python:2.7[xml] -# @CODE + eqawarn "python_export() is part of private eclass API." + eqawarn "Please call python_get*() instead." -# @ECLASS-VARIABLE: PYTHON_SCRIPTDIR -# @DEFAULT_UNSET -# @DESCRIPTION: -# The location where Python scripts must be installed for current impl. -# -# Set and exported on request using python_export(). -# -# Example value: -# @CODE -# /usr/lib/python-exec/python2.7 -# @CODE + _python_export "${@}" +} -# @FUNCTION: python_export +# @FUNCTION: _python_export # @USAGE: [<impl>] <variables>... +# @INTERNAL # @DESCRIPTION: # Set and export the Python implementation-relevant variables passed # as parameters. @@ -350,7 +258,7 @@ _python_impl_matches() { # The variables which can be exported are: PYTHON, EPYTHON, # PYTHON_SITEDIR. They are described more completely in the eclass # variable documentation. -python_export() { +_python_export() { debug-print-function ${FUNCNAME} "${@}" local impl var @@ -367,7 +275,7 @@ python_export() { *) impl=${EPYTHON} if [[ -z ${impl} ]]; then - die "python_export called without a python implementation and EPYTHON is unset" + die "_python_export called without a python implementation and EPYTHON is unset" fi ;; esac @@ -466,17 +374,15 @@ python_export() { local d case ${impl} in python2.7) - PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7';; - python3.3) - PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3';; - python*) - PYTHON_PKG_DEP="dev-lang/python:${impl#python}";; - pypy) - PYTHON_PKG_DEP='>=dev-python/pypy-5:0=';; + PYTHON_PKG_DEP='>=dev-lang/python-2.7.17-r1:2.7';; + python3.6) + PYTHON_PKG_DEP=">=dev-lang/python-3.6.10:3.6";; + python3.7) + PYTHON_PKG_DEP=">=dev-lang/python-3.7.6:3.7";; + python3.8) + PYTHON_PKG_DEP=">=dev-lang/python-3.8.2:3.8";; pypy3) - PYTHON_PKG_DEP='>=dev-python/pypy3-5:0=';; - jython2.7) - PYTHON_PKG_DEP='dev-java/jython:2.7';; + PYTHON_PKG_DEP='>=dev-python/pypy3-7.3.0:0=';; *) die "Invalid implementation: ${impl}" esac @@ -495,7 +401,7 @@ python_export() { debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}" ;; *) - die "python_export: unknown variable ${var}" + die "_python_export: unknown variable ${var}" esac done } @@ -506,13 +412,10 @@ python_export() { # Obtain and print the 'site-packages' path for the given # implementation. If no implementation is provided, ${EPYTHON} will # be used. -# -# If you just need to have PYTHON_SITEDIR set (and exported), then it is -# better to use python_export() directly instead. python_get_sitedir() { debug-print-function ${FUNCNAME} "${@}" - python_export "${@}" PYTHON_SITEDIR + _python_export "${@}" PYTHON_SITEDIR echo "${PYTHON_SITEDIR}" } @@ -521,13 +424,10 @@ python_get_sitedir() { # @DESCRIPTION: # Obtain and print the include path for the given implementation. If no # implementation is provided, ${EPYTHON} will be used. -# -# If you just need to have PYTHON_INCLUDEDIR set (and exported), then it -# is better to use python_export() directly instead. python_get_includedir() { debug-print-function ${FUNCNAME} "${@}" - python_export "${@}" PYTHON_INCLUDEDIR + _python_export "${@}" PYTHON_INCLUDEDIR echo "${PYTHON_INCLUDEDIR}" } @@ -542,7 +442,7 @@ python_get_includedir() { python_get_library_path() { debug-print-function ${FUNCNAME} "${@}" - python_export "${@}" PYTHON_LIBPATH + _python_export "${@}" PYTHON_LIBPATH echo "${PYTHON_LIBPATH}" } @@ -559,7 +459,7 @@ python_get_library_path() { python_get_CFLAGS() { debug-print-function ${FUNCNAME} "${@}" - python_export "${@}" PYTHON_CFLAGS + _python_export "${@}" PYTHON_CFLAGS echo "${PYTHON_CFLAGS}" } @@ -576,7 +476,7 @@ python_get_CFLAGS() { python_get_LIBS() { debug-print-function ${FUNCNAME} "${@}" - python_export "${@}" PYTHON_LIBS + _python_export "${@}" PYTHON_LIBS echo "${PYTHON_LIBS}" } @@ -593,7 +493,7 @@ python_get_LIBS() { python_get_PYTHON_CONFIG() { debug-print-function ${FUNCNAME} "${@}" - python_export "${@}" PYTHON_CONFIG + _python_export "${@}" PYTHON_CONFIG echo "${PYTHON_CONFIG}" } @@ -606,7 +506,7 @@ python_get_PYTHON_CONFIG() { python_get_scriptdir() { debug-print-function ${FUNCNAME} "${@}" - python_export "${@}" PYTHON_SCRIPTDIR + _python_export "${@}" PYTHON_SCRIPTDIR echo "${PYTHON_SCRIPTDIR}" } @@ -671,7 +571,7 @@ python_optimize() { [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' local PYTHON=${PYTHON} - [[ ${PYTHON} ]] || python_export PYTHON + [[ ${PYTHON} ]] || _python_export PYTHON # default to sys.path if [[ ${#} -eq 0 ]]; then @@ -774,9 +674,8 @@ python_newexe() { local f=${1} local newfn=${2} - local PYTHON_SCRIPTDIR d - python_export PYTHON_SCRIPTDIR - d=${PYTHON_SCRIPTDIR#${EPREFIX}} + local scriptdir=$(python_get_scriptdir) + local d=${scriptdir#${EPREFIX}} ( dodir "${wrapd}" @@ -902,10 +801,8 @@ python_domodule() { d=${python_moduleroot} else # relative to site-packages - local PYTHON_SITEDIR=${PYTHON_SITEDIR} - [[ ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR - - d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//} + local sitedir=$(python_get_sitedir) + d=${sitedir#${EPREFIX}}/${python_moduleroot//.//} fi ( @@ -935,10 +832,8 @@ python_doheader() { [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' - local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR} - [[ ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR - - d=${PYTHON_INCLUDEDIR#${EPREFIX}} + local includedir=$(python_get_includedir) + local d=${includedir#${EPREFIX}} ( insopts -m 0644 @@ -950,6 +845,21 @@ python_doheader() { # @FUNCTION: python_wrapper_setup # @USAGE: [<path> [<impl>]] # @DESCRIPTION: +# Backwards compatibility function. The relevant API is now considered +# private, please use python_setup instead. +python_wrapper_setup() { + debug-print-function ${FUNCNAME} "${@}" + + eqawarn "python_wrapper_setup() is part of private eclass API." + eqawarn "Please call python_setup() instead." + + _python_wrapper_setup "${@}" +} + +# @FUNCTION: _python_wrapper_setup +# @USAGE: [<path> [<impl>]] +# @INTERNAL +# @DESCRIPTION: # Create proper 'python' executable and pkg-config wrappers # (if available) in the directory named by <path>. Set up PATH # and PKG_CONFIG_PATH appropriately. <path> defaults to ${T}/${EPYTHON}. @@ -961,7 +871,7 @@ python_doheader() { # 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. -python_wrapper_setup() { +_python_wrapper_setup() { debug-print-function ${FUNCNAME} "${@}" local workdir=${1:-${T}/${EPYTHON}} @@ -978,10 +888,10 @@ python_wrapper_setup() { # Clean up, in case we were supposed to do a cheap update. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die rm -f "${workdir}"/bin/2to3 || die - rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die + rm -f "${workdir}"/pkgconfig/python{2,3}{,-embed}.pc || die local EPYTHON PYTHON - python_export "${impl}" EPYTHON PYTHON + _python_export "${impl}" EPYTHON PYTHON local pyver pyother if python_is_python3; then @@ -1021,8 +931,13 @@ python_wrapper_setup() { # Python 2.7+. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc \ - "${workdir}"/pkgconfig/python.pc || die - ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die + "${workdir}"/pkgconfig/python${pyver}.pc || die + + # Python 3.8+. + if [[ ${EPYTHON} != python[23].[67] ]]; then + ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}-embed.pc \ + "${workdir}"/pkgconfig/python${pyver}-embed.pc || die + fi else nonsupp+=( 2to3 python-config "python${pyver}-config" ) fi @@ -1085,23 +1000,9 @@ python_is_installed() { ;; esac - case "${impl}" in - pypy|pypy3) - local append= - if [[ ${PYTHON_REQ_USE} ]]; then - append=[${PYTHON_REQ_USE}] - fi - - # be happy with just the interpeter, no need for the virtual - has_version "${hasv_args[@]}" "dev-python/${impl}${append}" \ - || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}" - ;; - *) - local PYTHON_PKG_DEP - python_export "${impl}" PYTHON_PKG_DEP - has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}" - ;; - esac + local PYTHON_PKG_DEP + _python_export "${impl}" PYTHON_PKG_DEP + has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}" } # @FUNCTION: python_fix_shebang @@ -1261,6 +1162,7 @@ python_fix_shebang() { # @FUNCTION: _python_check_locale_sanity # @USAGE: <locale> +# @INTERNAL # @RETURN: 0 if sane, 1 otherwise # @DESCRIPTION: # Check whether the specified locale sanely maps between lowercase diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass index e1b32e71ab4f..9a757ccedf2f 100644 --- a/eclass/qt5-build.eclass +++ b/eclass/qt5-build.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: qt5-build.eclass @@ -6,18 +6,17 @@ # qt@gentoo.org # @AUTHOR: # Davide Pesavento <pesa@gentoo.org> -# @SUPPORTED_EAPIS: 6 7 +# @SUPPORTED_EAPIS: 7 # @BLURB: Eclass for Qt5 split ebuilds. # @DESCRIPTION: # This eclass contains various functions that are used when building Qt5. -# Requires EAPI 6. +# Requires EAPI 7. if [[ ${CATEGORY} != dev-qt ]]; then die "qt5-build.eclass is only to be used for building Qt 5" fi case ${EAPI} in - 6) inherit eapi7-ver ;; 7) : ;; *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;; esac @@ -105,10 +104,11 @@ EGIT_REPO_URI=( # @OUTPUT_VARIABLE # @DESCRIPTION: # Build directory for out-of-source builds. -case ${QT5_BUILD_TYPE} in - live) : ${QT5_BUILD_DIR:=${S}_build} ;; - release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312 -esac +if ver_test ${PV} -lt 5.14.2; then + : ${QT5_BUILD_DIR:=${S}} # workaround for bug 497312 +else + : ${QT5_BUILD_DIR:=${S}_build} +fi IUSE="debug test" @@ -118,9 +118,6 @@ BDEPEND=" dev-lang/perl virtual/pkgconfig " -case ${EAPI} in - 6) DEPEND+=" ${BDEPEND}" ;; -esac if [[ ${PN} != qttest ]]; then DEPEND+=" test? ( ~dev-qt/qttest-${PV} )" fi @@ -288,7 +285,7 @@ qt5-build_src_install() { qt5_install_module_config # prune libtool files - find "${D}" -name '*.la' -delete || die + find "${D}" -name '*.la' -type f -delete || die } # @FUNCTION: qt5-build_pkg_postinst @@ -568,8 +565,13 @@ qt5_base_configure() { -no-libpng -no-libjpeg -no-freetype -no-harfbuzz -no-openssl -no-libproxy + $([[ ${QT5_MINOR_VERSION} -ge 14 ]] && echo -no-feature-gssapi) -no-xcb-xlib - -no-xcb-xinput -no-xkbcommon # bug 672340 + + # bug 672340 + -no-xkbcommon + $([[ ${QT5_MINOR_VERSION} -lt 15 ]] && echo -no-xcb-xinput) + $([[ ${QT5_MINOR_VERSION} -ge 15 ]] && echo -no-bundled-xcb-xinput) # cannot use -no-gif because there is no way to override it later #-no-gif @@ -617,7 +619,7 @@ qt5_base_configure() { # disable undocumented X11-related flags, override in qtgui # (not shown in ./configure -help output) - -no-xkb + $([[ ${QT5_MINOR_VERSION} -lt 15 ]] && echo -no-xkb) # always enable session management support: it doesn't need extra deps # at configure time and turning it off is dangerous, see bug 518262 @@ -644,7 +646,7 @@ qt5_base_configure() { -no-gui -no-widgets # QTBUG-76521, default will change to zstd in Qt6 - $([[ ${QT5_MINOR_VERSION} -ge 13 ]] && echo -no-zstd) + -no-zstd # module-specific options "${myconf[@]}" @@ -657,7 +659,12 @@ qt5_base_configure() { # a forwarding header is no longer created since 5.8, causing the system # config to always be used. bug 599636 - cp src/corelib/global/qconfig.h include/QtCore/ || die + # ${S}/include does not exist in live sources + local basedir="${S}/" + if ver_test ${PV} -lt 5.14.2 || [[ ${QT5_BUILD_TYPE} == live ]]; then + basedir="" + fi + cp src/corelib/global/qconfig.h "${basedir}"include/QtCore/ || die popd >/dev/null || die @@ -814,18 +821,18 @@ qt5_install_module_config() { qt5_regenerate_global_configs() { einfo "Regenerating gentoo-qconfig.h" - find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \ + find "${ROOT}${QT5_HEADERDIR}"/Gentoo \ -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \ -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty" - cp "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \ + cp "${T}"/gentoo-qconfig.h "${ROOT}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \ || eerror "Failed to install new gentoo-qconfig.h" einfo "Updating QT_CONFIG in qconfig.pri" - local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri - local qconfig_pri_orig=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/gentoo/qconfig-qtcore.pri + local qconfig_pri=${ROOT}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri + local qconfig_pri_orig=${ROOT}${QT5_ARCHDATADIR}/mkspecs/gentoo/qconfig-qtcore.pri if [[ -f ${qconfig_pri} ]]; then local x qconfig_add= qconfig_remove= local qt_config new_qt_config= @@ -838,7 +845,7 @@ qt5_regenerate_global_configs() { # generate list of QT_CONFIG entries from the existing list, # appending QCONFIG_ADD and excluding QCONFIG_REMOVE eshopts_push -s nullglob - for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do + for x in "${ROOT}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")" qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")" done @@ -858,8 +865,8 @@ qt5_regenerate_global_configs() { einfo "Updating QT.global_private in qmodule.pri" - local qmodule_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qmodule.pri - local qmodule_pri_orig=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/gentoo/qmodule-qtcore.pri + local qmodule_pri=${ROOT}${QT5_ARCHDATADIR}/mkspecs/qmodule.pri + local qmodule_pri_orig=${ROOT}${QT5_ARCHDATADIR}/mkspecs/gentoo/qmodule-qtcore.pri if [[ -f ${qmodule_pri} && -f ${qmodule_pri_orig} ]]; then local x local qprivateconfig_enabled= qprivateconfig_disabled= @@ -870,7 +877,7 @@ qt5_regenerate_global_configs() { qprivateconfig_orig_enabled="$(sed -n 's/^QT.global_private.enabled_features\s=\s*//p' "${qmodule_pri_orig}")" qprivateconfig_orig_disabled="$(sed -n 's/^QT.global_private.disabled_features\s=\s*//p' "${qmodule_pri_orig}")" eshopts_push -s nullglob - for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qmodule.pri; do + for x in "${ROOT}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qmodule.pri; do qprivateconfig_enabled+=" $(sed -n 's/^QT.global_private.enabled_features\s=\s*//p' "${x}")" qprivateconfig_disabled+=" $(sed -n 's/^QT.global_private.disabled_features\s=\s*//p' "${x}")" done diff --git a/eclass/tests/distutils-r1.sh b/eclass/tests/distutils-r1.sh index 9ef4562edf1a..10f57b59edf9 100755 --- a/eclass/tests/distutils-r1.sh +++ b/eclass/tests/distutils-r1.sh @@ -63,7 +63,7 @@ tend einfo distutils_enable_tests eindent BASE_IUSE="python_targets_python2_7" -BASE_DEPS="python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_python2_7(-)]" +BASE_DEPS="python_targets_python2_7? ( >=dev-lang/python-2.7.17-r1:2.7 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_python2_7(-)]" TEST_RESTRICT=" !test? ( test )" einfo "empty RDEPEND" diff --git a/eclass/tests/multilib.sh b/eclass/tests/multilib.sh new file mode 100755 index 000000000000..a483d4bef360 --- /dev/null +++ b/eclass/tests/multilib.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +source tests-common.sh + +inherit multilib + +# Run 'multilib_env' and check what variables it expands to +test-multilib_env() { + local target=$1 exp_abi=$2 exp_vars=" $3" + tbegin "expand-target $1" + + # Reset default + unset MULTILIB_ABIS + unset DEFAULT_ABI + CFLAGS_default= + LDFLAGS_default= + LIBDIR_default=lib + CHOST_default=${target} + CTARGET_default=${CHOST_default} + LIBDIR_default=lib + + multilib_env ${target} + + local actual_abi="${DEFAULT_ABI}:${MULTILIB_ABIS}" + + local actual_vars="" + local abi var v + for abi in ${MULTILIB_ABIS}; do + actual_vars+=" ${abi}? (" + for var in CHOST LIBDIR CFLAGS LDFLAGS; do + v=${var}_${abi} + actual_vars+=" ${var}=${!v}" + done + actual_vars+=" )" + done + + [[ "${exp_abi}" == "${actual_abi}" && "${exp_vars}" == "${actual_vars}" ]] + + if ! tend $? ; then + printf '### EXPECTED ABI: %s\n' "${exp_abi}" + printf '### ACTUAL ABI: %s\n' "${actual_abi}" + printf '### EXPECTED VARS: %s\n' "${exp_vars}" + printf '### ACTUAL VARS: %s\n' "${actual_vars}" + fi +} + +# Pick a few interesting targets from: +# $ grep -h -o -R 'CHOST=.*' ../../profiles/ | sort -u + +test-multilib_env \ + "x86_64-pc-linux-gnu" \ + "amd64:amd64 x86" \ + "amd64? ( CHOST=x86_64-pc-linux-gnu LIBDIR=lib64 CFLAGS=-m64 LDFLAGS= ) x86? ( CHOST=i686-pc-linux-gnu LIBDIR=lib CFLAGS=-m32 LDFLAGS= )" +test-multilib_env \ + "x86_64-pc-linux-gnux32" \ + "x32:x32 amd64 x86" \ + "x32? ( CHOST=x86_64-pc-linux-gnux32 LIBDIR=libx32 CFLAGS=-mx32 LDFLAGS= ) amd64? ( CHOST=x86_64-pc-linux-gnu LIBDIR=lib64 CFLAGS=-m64 LDFLAGS= ) x86? ( CHOST=i686-pc-linux-gnu LIBDIR=lib CFLAGS=-m32 LDFLAGS= )" +test-multilib_env \ + "x86_64-gentoo-linux-musl" \ + "default:default" \ + "default? ( CHOST=x86_64-gentoo-linux-musl LIBDIR=lib CFLAGS= LDFLAGS= )" + +texit diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh index 4367890a08a1..377bb474a3ac 100755 --- a/eclass/tests/python-utils-r1.sh +++ b/eclass/tests/python-utils-r1.sh @@ -13,7 +13,7 @@ test_var() { tbegin "${var} for ${impl}" local ${var} - python_export ${impl} PYTHON ${var} + _python_export ${impl} PYTHON ${var} [[ ${!var} == ${expect} ]] || eerror "(${impl}: ${var}: ${!var} != ${expect}" tend ${?} @@ -101,23 +101,6 @@ fi test_var PYTHON_PKG_DEP python3_7 '*dev-lang/python*:3.7' test_var PYTHON_SCRIPTDIR python3_7 /usr/lib/python-exec/python3.7 -test_var EPYTHON jython2_7 jython2.7 -test_var PYTHON jython2_7 /usr/bin/jython2.7 -if [[ -x /usr/bin/jython2.7 ]]; then - test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages -fi -test_var PYTHON_PKG_DEP jython2_7 '*dev-java/jython*:2.7' -test_var PYTHON_SCRIPTDIR jython2_7 /usr/lib/python-exec/jython2.7 - -test_var EPYTHON pypy pypy -test_var PYTHON pypy /usr/bin/pypy -if [[ -x /usr/bin/pypy ]]; then - test_var PYTHON_SITEDIR pypy "/usr/lib*/pypy2.7/site-packages" - test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy2.7/include" -fi -test_var PYTHON_PKG_DEP pypy '*dev-python/pypy*:0=' -test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy - test_var EPYTHON pypy3 pypy3 test_var PYTHON pypy3 /usr/bin/pypy3 if [[ -x /usr/bin/pypy3 ]]; then @@ -129,16 +112,13 @@ test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3 test_is "python_is_python3 python2.7" 1 test_is "python_is_python3 python3.2" 0 -test_is "python_is_python3 jython2.7" 1 test_is "python_is_python3 pypy" 1 test_is "python_is_python3 pypy3" 0 # generic shebangs test_fix_shebang '#!/usr/bin/python' python2.7 '#!/usr/bin/python2.7' test_fix_shebang '#!/usr/bin/python' python3.6 '#!/usr/bin/python3.6' -test_fix_shebang '#!/usr/bin/python' pypy '#!/usr/bin/pypy' test_fix_shebang '#!/usr/bin/python' pypy3 '#!/usr/bin/pypy3' -test_fix_shebang '#!/usr/bin/python' jython2.7 '#!/usr/bin/jython2.7' # python2/python3 matching test_fix_shebang '#!/usr/bin/python2' python2.7 '#!/usr/bin/python2.7' @@ -155,12 +135,8 @@ test_fix_shebang '#!/usr/bin/python2.7' python3.2 '#!/usr/bin/python3.2' --force test_fix_shebang '#!/usr/bin/python3.2' python3.2 '#!/usr/bin/python3.2' test_fix_shebang '#!/usr/bin/python3.2' python2.7 FAIL test_fix_shebang '#!/usr/bin/python3.2' python2.7 '#!/usr/bin/python2.7' --force -test_fix_shebang '#!/usr/bin/pypy' pypy '#!/usr/bin/pypy' test_fix_shebang '#!/usr/bin/pypy' python2.7 FAIL test_fix_shebang '#!/usr/bin/pypy' python2.7 '#!/usr/bin/python2.7' --force -test_fix_shebang '#!/usr/bin/jython2.7' jython2.7 '#!/usr/bin/jython2.7' -test_fix_shebang '#!/usr/bin/jython2.7' jython3.2 FAIL -test_fix_shebang '#!/usr/bin/jython2.7' jython3.2 '#!/usr/bin/jython3.2' --force # fancy path handling test_fix_shebang '#!/mnt/python2/usr/bin/python' python3.6 \ @@ -196,39 +172,32 @@ test_is "_python_impl_supported pypy1_9" 1 test_is "_python_impl_supported pypy2_0" 1 test_is "_python_impl_supported pypy" 1 test_is "_python_impl_supported pypy3" 0 -test_is "_python_impl_supported jython2_7" 1 # check _python_impl_matches behavior test_is "_python_impl_matches python2_7 -2" 0 test_is "_python_impl_matches python3_6 -2" 1 test_is "_python_impl_matches python3_7 -2" 1 -test_is "_python_impl_matches pypy -2" 0 test_is "_python_impl_matches pypy3 -2" 1 test_is "_python_impl_matches python2_7 -3" 1 test_is "_python_impl_matches python3_6 -3" 0 test_is "_python_impl_matches python3_7 -3" 0 -test_is "_python_impl_matches pypy -3" 1 test_is "_python_impl_matches pypy3 -3" 0 test_is "_python_impl_matches python2_7 -2 python3_6" 0 test_is "_python_impl_matches python3_6 -2 python3_6" 0 test_is "_python_impl_matches python3_7 -2 python3_6" 1 -test_is "_python_impl_matches pypy -2 python3_6" 0 test_is "_python_impl_matches pypy3 -2 python3_6" 1 test_is "_python_impl_matches python2_7 pypy3 -2 python3_6" 0 test_is "_python_impl_matches python3_6 pypy3 -2 python3_6" 0 test_is "_python_impl_matches python3_7 pypy3 -2 python3_6" 1 -test_is "_python_impl_matches pypy pypy3 -2 python3_6" 0 test_is "_python_impl_matches pypy3 pypy3 -2 python3_6" 0 set -f test_is "_python_impl_matches python2_7 pypy*" 1 test_is "_python_impl_matches python3_6 pypy*" 1 test_is "_python_impl_matches python3_7 pypy*" 1 -test_is "_python_impl_matches pypy pypy*" 0 test_is "_python_impl_matches pypy3 pypy*" 0 test_is "_python_impl_matches python2_7 python*" 0 test_is "_python_impl_matches python3_6 python*" 0 test_is "_python_impl_matches python3_7 python*" 0 -test_is "_python_impl_matches pypy python*" 1 test_is "_python_impl_matches pypy3 python*" 1 set +f diff --git a/eclass/texlive-common.eclass b/eclass/texlive-common.eclass index 2618cba2e1ac..2072d3ad1605 100644 --- a/eclass/texlive-common.eclass +++ b/eclass/texlive-common.eclass @@ -67,7 +67,7 @@ texlive-common_is_file_present_in_texmf() { } # @FUNCTION: texlive-common_do_symlinks -# @USAGE: < src > < dest > +# @USAGE: <src> <dest> # @DESCRIPTION: # Mimic the install_link function of texlinks # @@ -103,7 +103,7 @@ texlive-common_do_symlinks() { } # @FUNCTION: etexlinks -# @USAGE: < file > +# @USAGE: <file> # @DESCRIPTION: # Mimic texlinks on a fmtutil format file # @@ -121,7 +121,7 @@ etexlinks() { } # @FUNCTION: dobin_texmf_scripts -# @USAGE: < file1 file2 ... > +# @USAGE: <file1> [file2] ... # @DESCRIPTION: # Symlinks a script from the texmf tree to /usr/bin. Requires permissions to be # correctly set for the file that it will point to. @@ -137,10 +137,10 @@ dobin_texmf_scripts() { } # @FUNCTION: etexmf-update -# @USAGE: In ebuilds' pkg_postinst and pkg_postrm phases # @DESCRIPTION: # Runs texmf-update if it is available and prints a warning otherwise. This -# function helps in factorizing some code. +# function helps in factorizing some code. Useful in ebuilds' pkg_postinst and +# pkg_postrm phases. etexmf-update() { if has_version 'app-text/texlive-core' ; then @@ -155,10 +155,10 @@ etexmf-update() { } # @FUNCTION: efmtutil-sys -# @USAGE: In ebuilds' pkg_postinst to force a rebuild of TeX formats. # @DESCRIPTION: # Runs fmtutil-sys if it is available and prints a warning otherwise. This -# function helps in factorizing some code. +# function helps in factorizing some code. Used in ebuilds' pkg_postinst to +# force a rebuild of TeX formats. efmtutil-sys() { if has_version 'app-text/texlive-core' ; then diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass index 5c4dec838d77..a415205e035f 100644 --- a/eclass/texlive-module.eclass +++ b/eclass/texlive-module.eclass @@ -350,8 +350,10 @@ texlive-module_src_install() { done dodir /usr/share - if use doc && [[ -d texmf-doc ]]; then - cp -pR texmf-doc "${ED}/usr/share/" || die + if use doc; then + if [[ -d texmf-doc ]]; then + cp -pR texmf-doc "${ED}/usr/share/" || die + fi else if [[ -d texmf-dist/doc ]]; then rm -rf texmf-dist/doc || die diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 62520ae92dff..c7eeb63b6d22 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -14,7 +14,7 @@ tc_is_live() { } if tc_is_live ; then - EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git" + EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git" # naming style: # gcc-10.1.0_pre9999 -> gcc-10-branch # Note that the micro version is required or lots of stuff will break. @@ -172,8 +172,9 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then tc_version_is_at_least 4.2 && IUSE+=" +openmp" tc_version_is_at_least 4.3 && IUSE+=" fixed-point" tc_version_is_at_least 4.7 && IUSE+=" go" - tc_version_is_at_least 4.8 && - IUSE+=" +sanitize" + # sanitizer support appeared in gcc-4.8, but <gcc-5 does not + # support modern glibc. + tc_version_is_at_least 5 && IUSE+=" +sanitize" # Note: # <gcc-4.8 supported graphite, it required forked ppl # versions which we dropped. Since graphite was also experimental in @@ -183,7 +184,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then tc_version_is_at_least 6.5 && IUSE+=" graphite" TC_FEATURES+=(graphite) tc_version_is_between 4.9 8 && IUSE+=" cilk" - tc_version_is_at_least 4.9 && IUSE+=" +vtv" + tc_version_is_at_least 4.9 && IUSE+=" ada +vtv" tc_version_is_at_least 5.0 && IUSE+=" jit" tc_version_is_between 5.0 9 && IUSE+=" mpx" tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch" @@ -231,7 +232,7 @@ if tc_has_feature graphite ; then RDEPEND+=" graphite? ( >=dev-libs/isl-0.14:0= )" fi -DEPEND="${RDEPEND} +BDEPEND=" >=sys-devel/bison-1.875 >=sys-devel/flex-2.5.4 nls? ( sys-devel/gettext ) @@ -239,6 +240,7 @@ DEPEND="${RDEPEND} >=dev-util/dejagnu-1.4.4 >=sys-devel/autogen-5.5.4 )" +DEPEND="${RDEPEND}" if tc_has_feature gcj ; then GCJ_DEPS=">=media-libs/libart_lgpl-2.1" @@ -264,6 +266,10 @@ if tc_has_feature zstd ; then DEPEND+=" zstd? ( app-arch/zstd )" fi +case ${EAPI:-0} in + 5*|6) DEPEND+=" ${BDEPEND}" ;; +esac + PDEPEND=">=sys-devel/gcc-config-1.7" #---->> S + SRC_URI essentials <<---- @@ -420,17 +426,7 @@ SRC_URI=$(get_gcc_src_uri) #---->> pkg_pretend <<---- -toolchain_is_unsupported() { - [[ -n ${SNAPSHOT} ]] || tc_is_live -} - toolchain_pkg_pretend() { - if toolchain_is_unsupported && - [[ -z ${I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS} ]] ; then - die "Please \`export I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS=1\` or define it" \ - "in your make.conf if you want to use this version." - fi - if ! use_if_iuse cxx ; then use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"' use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"' @@ -593,7 +589,7 @@ toolchain_src_prepare() { # Prevent new texinfo from breaking old versions (see #198182, #464008) if tc_version_is_at_least 4.1; then - tc_apply_patches "Remove texinfo (bug #198182, bug ##464008)" "${FILESDIR}"/gcc-configure-texinfo.patch + tc_apply_patches "Remove texinfo (bug #198182, bug #464008)" "${FILESDIR}"/gcc-configure-texinfo.patch fi # >=gcc-4 @@ -641,7 +637,13 @@ do_gcc_CYGWINPORTS_patches() { local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}" # readarray -t is available since bash-4.4 only, #690686 - local patches=( $(sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport) ) + local patches=( $( + for p in $( + sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport + ); do + echo "${d}/${p}" + done + ) ) tc_apply_patches "Applying cygwin port patches ..." ${patches[*]} } @@ -897,8 +899,7 @@ toolchain_src_configure() { is_f77 && GCC_LANG+=",f77" is_f95 && GCC_LANG+=",f95" - # We do NOT want 'ADA support' in here! - # is_ada && GCC_LANG+=",ada" + is_ada && GCC_LANG+=",ada" confgcc+=( --enable-languages=${GCC_LANG} ) @@ -1258,6 +1259,10 @@ toolchain_src_configure() { fi fi + if in_iuse ada ; then + confgcc+=( --disable-libada ) + fi + if in_iuse cilk ; then confgcc+=( $(use_enable cilk libcilkrts) ) fi @@ -1307,9 +1312,13 @@ toolchain_src_configure() { confgcc+=( --without-{cloog,ppl} ) fi - if tc_version_is_at_least 4.8 && in_iuse sanitize ; then - # See Note [implicitly enabled flags] - confgcc+=( $(usex sanitize '' --disable-libsanitizer) ) + if tc_version_is_at_least 4.8; then + if in_iuse sanitize ; then + # See Note [implicitly enabled flags] + confgcc+=( $(usex sanitize '' --disable-libsanitizer) ) + else + confgcc+=( --disable-libsanitizer ) + fi fi if tc_version_is_at_least 6.0 && in_iuse pie ; then @@ -1494,8 +1503,12 @@ 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 - replace-flags -O? -O2 + filter-flags '-O?' + append-flags -O2 # dont want to funk ourselves filter-flags '-mabi*' -m31 -m32 -m64 @@ -1643,6 +1656,11 @@ toolchain_src_compile() { [[ ! -x /usr/bin/perl ]] \ && find "${WORKDIR}"/build -name '*.[17]' -exec touch {} + + # To compile ada library standard files special compiler options are passed + # via ADAFLAGS in the Makefile. + # Unset ADAFLAGS as setting this override the options + unset ADAFLAGS + # Older gcc versions did not detect bash and re-exec itself, so force the # use of bash. Newer ones will auto-detect, but this is not harmful. # This needs to be set for compile as well, as it's used in libtool @@ -1711,6 +1729,17 @@ gcc_do_make() { ${GCC_MAKE_TARGET} \ || die "emake failed with ${GCC_MAKE_TARGET}" + if is_ada; then + # Without these links it is not getting the good compiler + # Need to check why + ln -s gcc ../build/prev-gcc || die + ln -s ${CHOST} ../build/prev-${CHOST} || die + # Building standard ada library + emake -C gcc gnatlib-shared + # Building gnat toold + emake -C gcc gnattools + fi + if ! is_crosscompile && use_if_iuse cxx && use_if_iuse doc ; then if type -p doxygen > /dev/null ; then if tc_version_is_at_least 4.3 ; then @@ -2214,12 +2243,6 @@ toolchain_pkg_postinst() { # handling of binpkgs, don't require these to be found cp "${ROOT%/}${DATAPATH}"/c{89,99} "${EROOT%/}"/usr/bin/ 2>/dev/null fi - - if toolchain_is_unsupported ; then - einfo "This GCC ebuild is provided for your convenience, and the use" - einfo "of this compiler is not supported by the Gentoo Developers." - einfo "Please report bugs to upstream at http://gcc.gnu.org/bugzilla/" - fi } toolchain_pkg_postrm() { diff --git a/eclass/waf-utils.eclass b/eclass/waf-utils.eclass index 2cb26bc8dfd9..7a894f6bbb73 100644 --- a/eclass/waf-utils.eclass +++ b/eclass/waf-utils.eclass @@ -69,19 +69,23 @@ waf-utils_src_configure() { [[ ${fail} ]] && die "Invalid use of waf-utils.eclass" - local libdir=() - # @ECLASS-VARIABLE: WAF_BINARY # @DESCRIPTION: # Eclass can use different waf executable. Usually it is located in "${S}/waf". : ${WAF_BINARY:="${S}/waf"} - # @ECLASS-VARIABLE: NO_WAF_LIBDIR - # @DEFAULT_UNSET - # @DESCRIPTION: - # Variable specifying that you don't want to set the libdir for waf script. - # Some scripts does not allow setting it at all and die if they find it. - [[ -z ${NO_WAF_LIBDIR} ]] && libdir=(--libdir="${EPREFIX}/usr/$(get_libdir)") + local conf_args=() + + local waf_help=$("${WAF_BINARY}" --help 2>/dev/null) + if [[ ${waf_help} == *--docdir* ]]; then + conf_args+=( --docdir="${EPREFIX}"/usr/share/doc/${PF} ) + fi + if [[ ${waf_help} == *--htmldir* ]]; then + conf_args+=( --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html ) + fi + if [[ ${waf_help} == *--libdir* ]]; then + conf_args+=( --libdir="${EPREFIX}/usr/$(get_libdir)" ) + fi tc-export AR CC CPP CXX RANLIB @@ -91,7 +95,7 @@ waf-utils_src_configure() { PKGCONFIG="$(tc-getPKG_CONFIG)" "${WAF_BINARY}" "--prefix=${EPREFIX}/usr" - "${libdir[@]}" + "${conf_args[@]}" "${@}" configure ) |