From c8a52e17017058394ea35394ebfae0e049c8779c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 20 Jun 2021 21:48:43 +0200 Subject: [PATCH 1/2] Fix exposing evaluated PROPERTIES & RESTRICT in EAPI 8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reorder the code to prevent eclass PROPERTIES & RESTRICT logic from overriding the processed values gotten from PORTAGE_PROPERTIES and PORTAGE_RESTRICT. Otherwise, code in Portage misbehaves due to unexpected USE-conditionals in PROPERTIES/RESTRICT. Bug: https://bugs.gentoo.org/796959 Reviewed-by: Zac Medico Closes: https://github.com/gentoo/portage/pull/733 Signed-off-by: Michał Górny --- bin/ebuild.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 2c3b985a9f..904fdf54ed 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -653,13 +653,6 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then shopt -u failglob fi - if [[ "${EBUILD_PHASE}" != "depend" ]] ; then - PROPERTIES=${PORTAGE_PROPERTIES} - RESTRICT=${PORTAGE_RESTRICT} - [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \ - rm "$PORTAGE_BUILDDIR/.ebuild_changed" - fi - [ "${EAPI+set}" = set ] || EAPI=0 # export EAPI for helpers (especially since we unset it above) @@ -688,6 +681,13 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND unset E_BDEPEND E_PROPERTIES E_RESTRICT __INHERITED_QA_CACHE + if [[ "${EBUILD_PHASE}" != "depend" ]] ; then + PROPERTIES=${PORTAGE_PROPERTIES} + RESTRICT=${PORTAGE_RESTRICT} + [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \ + rm "$PORTAGE_BUILDDIR/.ebuild_changed" + fi + # alphabetically ordered by $EBUILD_PHASE value case ${EAPI} in 0|1) From c3e4919fd004ce0f5c91c67ea377bbda83558ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 20 Jun 2021 22:54:36 +0200 Subject: [PATCH 2/2] Use PORTAGE_PROPERTIES and PORTAGE_RESTRICT internally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use PORTAGE_PROPERTIES and PORTAGE_RESTRICT directly for internal purposes rather than relying on PROPERTIES and RESTRICT having the flattened values. Reviewed-by: Zac Medico Closes: https://github.com/gentoo/portage/pull/734 Signed-off-by: Michał Górny --- bin/ebuild.sh | 2 +- bin/estrip | 14 +++++++------- bin/install-qa-check.d/10executable-issues | 2 +- bin/install-qa-check.d/10ignored-flags | 4 ++-- bin/install-qa-check.d/80libraries | 2 +- bin/misc-functions.sh | 2 +- bin/phase-functions.sh | 8 ++++---- bin/phase-helpers.sh | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 904fdf54ed..5916bedfcb 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -737,7 +737,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then fi fi -if has nostrip ${FEATURES} ${RESTRICT} || has strip ${RESTRICT} +if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT} then export DEBUGBUILD=1 fi diff --git a/bin/estrip b/bin/estrip index 81f78e8478..7ef1ec35cf 100755 --- a/bin/estrip +++ b/bin/estrip @@ -16,7 +16,7 @@ exp_tf() { done } exp_tf FEATURES compressdebug installsources nostrip splitdebug xattr -exp_tf RESTRICT binchecks installsources splitdebug strip +exp_tf PORTAGE_RESTRICT binchecks installsources splitdebug strip if ! ___eapi_has_prefix_variables; then EPREFIX= ED=${D} @@ -24,7 +24,7 @@ fi banner=false SKIP_STRIP=false -if ${RESTRICT_strip} || ${FEATURES_nostrip} ; then +if ${PORTAGE_RESTRICT_strip} || ${FEATURES_nostrip} ; then SKIP_STRIP=true banner=true ${FEATURES_installsources} || exit 0 @@ -167,7 +167,7 @@ mkdir -p "${tmpdir}"/{inodes,splitdebug,sources} # Usage: save_elf_sources save_elf_sources() { ${FEATURES_installsources} || return 0 - ${RESTRICT_installsources} && return 0 + ${PORTAGE_RESTRICT_installsources} && return 0 if ! ${debugedit_found} ; then if ! ${debugedit_warned} ; then debugedit_warned=true @@ -192,7 +192,7 @@ save_elf_sources() { # Usage: save_elf_debug [splitdebug file] save_elf_debug() { ${FEATURES_splitdebug} || return 0 - ${RESTRICT_splitdebug} && return 0 + ${PORTAGE_RESTRICT_splitdebug} && return 0 # NOTE: Debug files must be installed in # ${EPREFIX}/usr/lib/debug/${EPREFIX} (note that ${EPREFIX} occurs @@ -318,7 +318,7 @@ process_ar() { # There is no concept of splitdebug for objects not yet # linked in (only for finally linked ELFs), so we have to # retain the debug info in the archive itself. - if ! ${FEATURES_splitdebug} || ${RESTRICT_splitdebug} ; then + if ! ${FEATURES_splitdebug} || ${PORTAGE_RESTRICT_splitdebug} ; then ${STRIP} -g "${x}" && ${RANLIB} "${x}" fi fi @@ -327,7 +327,7 @@ process_ar() { # The existance of the section .symtab tells us that a binary is stripped. # We want to log already stripped binaries, as this may be a QA violation. # They prevent us from getting the splitdebug data. -if ! ${RESTRICT_binchecks} ; then +if ! ${PORTAGE_RESTRICT_binchecks} ; then # We need to do the non-stripped scan serially first before we turn around # and start stripping the files ourselves. The log parsing can be done in # parallel though. @@ -459,7 +459,7 @@ __multijob_finish cd "${tmpdir}"/sources/ && cat * > "${tmpdir}/debug.sources" 2>/dev/null if [[ -s ${tmpdir}/debug.sources ]] && \ ${FEATURES_installsources} && \ - ! ${RESTRICT_installsources} && \ + ! ${PORTAGE_RESTRICT_installsources} && \ ${debugedit_found} then __vecho "installsources: rsyncing source files" diff --git a/bin/install-qa-check.d/10executable-issues b/bin/install-qa-check.d/10executable-issues index 6b33d281df..c2355ab8f7 100644 --- a/bin/install-qa-check.d/10executable-issues +++ b/bin/install-qa-check.d/10executable-issues @@ -2,7 +2,7 @@ # text relocations, executable stacks elf_check() { - if ! type -P scanelf >/dev/null || has binchecks ${RESTRICT}; then + if ! type -P scanelf >/dev/null || has binchecks ${PORTAGE_RESTRICT}; then return fi diff --git a/bin/install-qa-check.d/10ignored-flags b/bin/install-qa-check.d/10ignored-flags index 062f513252..89706cd4ca 100644 --- a/bin/install-qa-check.d/10ignored-flags +++ b/bin/install-qa-check.d/10ignored-flags @@ -2,7 +2,7 @@ ignored_flag_check() { type -P scanelf > /dev/null || return - has binchecks ${RESTRICT} && return + has binchecks ${PORTAGE_RESTRICT} && return local qa_var="QA_FLAGS_IGNORED_${ARCH/-/_}" eval "[[ -n \${!qa_var} ]] && QA_FLAGS_IGNORED=(\"\${${qa_var}[@]}\")" @@ -65,7 +65,7 @@ ignored_flag_check() { # Check for files built without respecting LDFLAGS if [[ "${LDFLAGS}" == *,--defsym=__gentoo_check_ldflags__* ]] && \ - ! has binchecks ${RESTRICT} ; then + ! has binchecks ${PORTAGE_RESTRICT} ; then f=$(LC_ALL=C comm -2 -3 <(scanelf -qyRF '#k%p' -k .dynsym "${ED%/}/" | LC_ALL=C sort) \ <(scanelf -qyRF '#s%p' -s __gentoo_check_ldflags__ "${ED%/}/" | LC_ALL=C sort)) if [[ -n ${f} ]] ; then diff --git a/bin/install-qa-check.d/80libraries b/bin/install-qa-check.d/80libraries index d1d2c4fddf..8dc35bb879 100644 --- a/bin/install-qa-check.d/80libraries +++ b/bin/install-qa-check.d/80libraries @@ -92,7 +92,7 @@ scanelf_lib_check() { lib_check() { local f x i j - if type -P scanelf >/dev/null && ! has binchecks ${RESTRICT}; then + if type -P scanelf >/dev/null && ! has binchecks ${PORTAGE_RESTRICT}; then scanelf_lib_check fi diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 97bd78ec8e..bd1fb7553a 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -206,7 +206,7 @@ install_qa_check() { eqawarn "QA Notice: found on package installing ELF files" fi - if has binchecks ${RESTRICT}; then + if has binchecks ${PORTAGE_RESTRICT}; then eqawarn "QA Notice: RESTRICT=binchecks prevented checks on these ELF files:" eqawarn "$(while read -r x; do x=${x#*;} ; x=${x%%;*} ; echo "${x#${EPREFIX}}" ; done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.ELF.2)" fi diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 71411d414c..0bb5d86e1b 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -490,8 +490,8 @@ __dyn_test() { die "The source directory '${S}' doesn't exist" fi - if has test ${RESTRICT} && ! has all ${ALLOW_TEST} && - ! { has test_network ${PROPERTIES} && has network ${ALLOW_TEST}; } + if has test ${PORTAGE_RESTRICT} && ! has all ${ALLOW_TEST} && + ! { has test_network ${PORTAGE_PROPERTIES} && has network ${ALLOW_TEST}; } then einfo "Skipping make test/check due to ebuild restriction." __vecho ">>> Test phase [disabled because of RESTRICT=test]: ${CATEGORY}/${PF}" @@ -704,7 +704,7 @@ __dyn_install() { cp "${EBUILD}" "${PF}.ebuild" [ -n "${PORTAGE_REPO_NAME}" ] && echo "${PORTAGE_REPO_NAME}" > repository - if has nostrip ${FEATURES} ${RESTRICT} || has strip ${RESTRICT} + if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT} then >> DEBUGBUILD fi @@ -759,7 +759,7 @@ __dyn_help() { echo " c++ flags : ${CXXFLAGS}" echo " make flags : ${MAKEOPTS}" echo -n " build mode : " - if has nostrip ${FEATURES} ${RESTRICT} || has strip ${RESTRICT} ; + if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT} then echo "debug (large)" else diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 3f53e6c57e..94f4f24f29 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -21,7 +21,7 @@ export PORTAGE_DOCOMPRESS_SIZE_LIMIT="128" declare -a PORTAGE_DOCOMPRESS=( /usr/share/{doc,info,man} ) declare -a PORTAGE_DOCOMPRESS_SKIP=( /usr/share/doc/${PF}/html ) declare -a PORTAGE_DOSTRIP=( / ) -has strip ${RESTRICT} && PORTAGE_DOSTRIP=() +has strip ${PORTAGE_RESTRICT} && PORTAGE_DOSTRIP=() declare -a PORTAGE_DOSTRIP_SKIP=() into() {