From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AAAC6158087 for ; Fri, 14 Jan 2022 12:28:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CBF792BC024; Fri, 14 Jan 2022 12:28:22 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 569292BC024 for ; Fri, 14 Jan 2022 12:28:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DF95A342E8E for ; Fri, 14 Jan 2022 12:28:20 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 33AC0D0 for ; Fri, 14 Jan 2022 12:28:19 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1642163296.c6c1c09765855d9a1984b358066b4cadfb3c92da.grobian@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: sys-apps/portage/, sys-apps/portage/files/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: sys-apps/portage/Manifest sys-apps/portage/files/portage-3.0.30-ebuildshell.patch sys-apps/portage/files/portage-3.0.30-prefix-stack.patch sys-apps/portage/portage-3.0.30.ebuild X-VCS-Directories: sys-apps/portage/ sys-apps/portage/files/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: c6c1c09765855d9a1984b358066b4cadfb3c92da X-VCS-Branch: master Date: Fri, 14 Jan 2022 12:28:19 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b25b3ebd-f3d3-495c-bfa1-5ba51884f6b8 X-Archives-Hash: 391cbf68f50f03b0d4766913b65b8041 commit: c6c1c09765855d9a1984b358066b4cadfb3c92da Author: Fabian Groffen gentoo org> AuthorDate: Fri Jan 14 12:28:16 2022 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri Jan 14 12:28:16 2022 +0000 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=c6c1c097 sys-apps/portage-3.0.30: version bump Package-Manager: Portage-3.0.30, Repoman-3.0.3 Signed-off-by: Fabian Groffen gentoo.org> sys-apps/portage/Manifest | 1 + .../portage/files/portage-3.0.30-ebuildshell.patch | 349 +++++++++++++++++++++ .../files/portage-3.0.30-prefix-stack.patch | 81 +++++ sys-apps/portage/portage-3.0.30.ebuild | 307 ++++++++++++++++++ 4 files changed, 738 insertions(+) diff --git a/sys-apps/portage/Manifest b/sys-apps/portage/Manifest index 13a1d23d2a..59b77c8363 100644 --- a/sys-apps/portage/Manifest +++ b/sys-apps/portage/Manifest @@ -1 +1,2 @@ DIST prefix-portage-3.0.21.tar.bz2 1339211 BLAKE2B 019cf0f3d2d1c45e7849221fc40b49e2c84949b74c8a8c74fbd2ca451a2dd075fb7b8bfec121a173ca0848c57a5a57a62d465b2957c4eb4d87f6a180299da91e SHA512 0aff5004ae80e2cd9dce740c56c3c2643ef390510c3b3821d893e5c76733d3a8d4e7648963febb29479b9ee155868ec11526a393beb3b383e741451178f39e5a +DIST prefix-portage-3.0.30.tar.bz2 1465506 BLAKE2B 5a575bc6c6c537518a1d4738f59d6f5eec467c834d434493e83cb0262c9c121b0e55906b9f1b877b6e68b4b78f69548df03d8901a619ce1c69d9ffe5f2623e55 SHA512 52bb91057c8c983f227f1d30dcda1bdf915aecc1de89375b2af648e7bfc5543a30f9b670b3d7720724f8277f3e65745a22dfe670038222d61e939fd75c9b7bfd diff --git a/sys-apps/portage/files/portage-3.0.30-ebuildshell.patch b/sys-apps/portage/files/portage-3.0.30-ebuildshell.patch new file mode 100644 index 0000000000..20f0aab813 --- /dev/null +++ b/sys-apps/portage/files/portage-3.0.30-ebuildshell.patch @@ -0,0 +1,349 @@ +From 8c6b115fa0325b5bed2e1a9c4c8e8af45cdecc2e Mon Sep 17 00:00:00 2001 +From: Michael Haubenwallner +Date: Wed, 6 Nov 2013 12:40:05 +0100 +Subject: [PATCH 1/2] Add ebuildshell feature, bug#155161. + +--- + bin/ebuild.sh | 146 ++++++++++++++++++++++++++++++++++- + bin/filter-bash-environment.py | 55 +++++++++---- + bin/save-ebuild-env.sh | 2 +- + man/make.conf.5 | 6 ++ + lib/_emerge/AbstractEbuildProcess.py | 1 + + lib/portage/const.py | 1 + + 6 files changed, 194 insertions(+), 17 deletions(-) + +diff --git a/bin/ebuild.sh b/bin/ebuild.sh +index f76a48d8e..683a4e9c1 100755 +--- a/bin/ebuild.sh ++++ b/bin/ebuild.sh +@@ -121,7 +121,7 @@ __qa_source() { + __qa_call() { + local shopts=$(shopt) OLDIFS="$IFS" + local retval +- "$@" ++ __call-ebuildshell "$@" + retval=$? + set +e + [[ $shopts != $(shopt) ]] && +@@ -547,6 +547,150 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then + unset BIN_PATH BIN BODY FUNC_SRC + fi + ++__call-ebuildshell() { ++ if ! has ebuildshell ${FEATURES}; then ++ "$@" ++ return $? ++ fi ++ local __ebuildshell_args=( "$@" ) ++ # These are the variables I have seen 'bash -i' maintaining the values for: ++ local __ebuildshell_bash_i_vars="__ebuildshell_.* ++ _ BASH_ARGC BASH_ARGV BASH_COMMAND BASH_LINENO BASH_SOURCE ++ BASH_VERSINFO BASH_SUBSHELL BASHOPTS BASHPID COMP_WORDBREAKS ++ DIRSTACK EUID FUNCNAME GROUPS HISTCMD HISTFILE LINENO PIPESTATUS ++ PPID PS1 PS2 PS3 PS4 PWD RANDOM SECONDS SHELLOPTS UID" ++ # Allow recursive ebuildshell, for use in multibuild.eclass and similar: ++ local __ebuildshell_pid=${BASHPID:-$(__bashpid)} ++ local __ebuildshell_tmpf="${T}/ebuildshell.${__ebuildshell_pid}" ++ rm -f "${__ebuildshell_tmpf}."{ebuild,return}-{env,rovars} ++ ( ++ cat <<-EOE ++ # local variables of functions using recursive ebuildshell are ++ # visible to the EXIT trap of that recursive ebuildshell. To ++ # keep them local, we have to filter them from that recursive ++ # ebuildshell's return-env. As 'declare -p' is unable to tell ++ # local-ity of variables, we abuse the trace attribute for local ++ # variables to filter them from the return-env. So we need the ++ # local alias active before declaring any functions. ++ # On a sidehand, this allows for copy&paste of function body ++ # lines including the local keyword. ++ alias local='declare -t' ++ shopt -s expand_aliases ++ EOE ++ ( ++ declare -p ++ declare -fp ++ shopt -p ++ [[ ${BASH_VERSINFO[0]} == 3 ]] && export ++ ) | ++ ( ++ # we need everything but the bash vars after 'env -i' ++ 2>"${__ebuildshell_tmpf}.ebuild-rovars" \ ++ "${PORTAGE_PYTHON:-/tools/haubi/gentoo/s01en24/usr/bin/python}" \ ++ "${PORTAGE_BIN_PATH}"/filter-bash-environment.py \ ++ --report-readonly-variables \ ++ --preserve-readonly-attribute \ ++ "${__ebuildshell_bash_i_vars}" \ ++ || die "filter-bash-environment.py failed" ++ ) ++ # 'declare -g' is available since bash-4.2, ++ # https://bugs.gentoo.org/show_bug.cgi?id=155161#c35 ++ if (( ${BASH_VERSINFO[0]} > 4 )) || ++ (( ${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} >= 2 )) ++ then ++ __ebuildshell_bash42_true= ++ __ebuildshell_bash42_false='#bash-4.2#' ++ else ++ __ebuildshell_bash42_true='#bash-4.2#' ++ __ebuildshell_bash42_false= ++ fi ++ # The already readonly variables, without bash maintained ones: ++ __ebuildshell_ro_ebuild_vars=$(<"${__ebuildshell_tmpf}.ebuild-rovars") ++ cat <<-EOE ++ # properly quote the function arguments ++ $(declare -p __ebuildshell_args) ++ set -- "\${__ebuildshell_args[@]}" ++ unset __ebuildshell_args ++ # be informative about what to do ++ PS1="EBUILD ${PN} $1 \$ " ++ type $1 ++ ${__ebuildshell_bash42_false}echo 'warning: preserving variables across phases requires bash-4.2' ++ echo "WANTED: \$@" ++ echo "or use: \"\\\$@\"" ++ # use bash history, but not the 'user's real one ++ HISTFILE=~/.bash_history ++ # but do not use history-expansion with '!', ++ # for copy&paste of function body lines containing: ! ++ set +H ++ # this is a debugging shell already ++ shopt -u extdebug ++ trap - DEBUG ++ # at exit, dump the current environment ++ trap " ++ unalias local ++ unset -f __call-ebuildshell ++ rm -f '${__ebuildshell_tmpf}.return-'* ++ ( ++ ( ++ # declare -p does not tell the -g flag, ++ # so we add it by aliasing declare. ++ ${__ebuildshell_bash42_true}echo \"alias declare='declare -g'\" ++ declare -p ++ ${__ebuildshell_bash42_true}echo \"unalias declare\" ++ declare -fp ++ shopt -p | grep -v '\\(expand_aliases\\|extdebug\\)$' ++ $([[ ${BASH_VERSINFO[0]} == 3 ]] && echo export) ++ ) | ++ ( ++ # We may have more readonly variables now, yet we ++ # need to filter variables that were readonly before. ++ # And filter local variables by their trace attribute. ++ 2>'${__ebuildshell_tmpf}.return-rovars' \\ ++ '${PORTAGE_PYTHON:-/tools/haubi/gentoo/s01en24/usr/bin/python}' \\ ++ '${PORTAGE_BIN_PATH}'/filter-bash-environment.py \\ ++ --report-readonly-variables \\ ++ --preserve-readonly-attribute \\ ++ --filter-traced-variables \\ ++ '${__ebuildshell_bash_i_vars} \ ++ ${__ebuildshell_ro_ebuild_vars}' \\ ++ || die 'filter-bash-environment.py failed' ++ ) ++ ) > '${__ebuildshell_tmpf}.return-env' ++ " EXIT ++ # can do some cleanup right now ++ rm -f '${__ebuildshell_tmpf}.ebuild-'* ++ EOE ++ ) > "${__ebuildshell_tmpf}.ebuild-env" ++ ++ # pre-fill the history with "$@" ++ echo '"$@"' >> ~/.bash_history ++ chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} ~/.bash_history &>/dev/null ++ ++ env -i HOME=~ ${BASH} --rcfile "${__ebuildshell_tmpf}.ebuild-env" -i ++ ++ # The environment- and exit-status handling after leaving the ebuildshell ++ # prompt is expected to be identical as without the ebuildshell prompt. ++ local __ebuildshell_status=$? ++ ++ # We might be in a recursive ebuildshell, but do not want ++ # any aliases being active while sourcing the return-env. ++ local __ebuildshell_orig_aliases=$(alias) ++ unalias -a ++ source "${__ebuildshell_tmpf}.return-env" ++ unalias -a ++ eval "${__ebuildshell_orig_aliases}" ++ ++ # Portage has a whitelist of readonly variables: If an ebuild defines ++ # additional readonly variables, their readonly attribute is removed ++ # across ebuild phases. If we ever want to preserve the readonly ++ # attribute of additional ebuild-defined variables across phases, ++ # when returning from the ebuildshell their names are in ++ # "${__ebuildshell_tmpf}.return-rovars" ++ rm -f "${__ebuildshell_tmpf}."{ebuild,return}-{env,rovars} ++ ++ return ${__ebuildshell_status} ++} ++ + # Subshell/helper die support (must export for the die helper). + export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)} + trap 'exit 1' SIGTERM +diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py +index 06cac7214..5590dbfc4 100755 +--- a/bin/filter-bash-environment.py ++++ b/bin/filter-bash-environment.py +@@ -14,7 +14,8 @@ + br'(^|^declare\s+-\S+\s+|^declare\s+|^export\s+)([^=\s]+)=("|\')?.*$' + ) + close_quote_re = re.compile(br'(\\"|"|\')\s*$') +-readonly_re = re.compile(br"^declare\s+-(\S*)r(\S*)\s+") ++readonly_re = re.compile(br"^declare\s+-(\S*)r(\S*)\s+([^=\s]+)") ++trace_re = re.compile(br"^declare\s+-\S*t\S*\s+") + # declare without assignment + var_declare_re = re.compile(br"^declare(\s+-\S+)?\s+([^=\s]+)\s*$") + +@@ -30,7 +31,7 @@ + return close_quote_match is not None and close_quote_match.group(1) == quote + + +-def filter_declare_readonly_opt(line): ++def filter_declare_readonly_opt(line, options): + readonly_match = readonly_re.match(line) + if readonly_match is not None: + declare_opts = b"" +@@ -38,14 +39,19 @@ + group = readonly_match.group(i) + if group is not None: + declare_opts += group ++ var = readonly_match.group(3) ++ if '--report-readonly-variables' in options: ++ getattr(sys.stderr, 'buffer', sys.stderr).write(var + b'\n') ++ if '--preserve-readonly-attribute' in options: ++ declare_opts += b'r' + if declare_opts: +- line = b"declare -" + declare_opts + b" " + line[readonly_match.end() :] ++ line = b"declare -" + declare_opts + b" " + var + line[readonly_match.end() :] + else: +- line = b"declare " + line[readonly_match.end() :] ++ line = b"declare " + var + line[readonly_match.end() :] + return line + + +-def filter_bash_environment(pattern, file_in, file_out): ++def filter_bash_environment(pattern, file_in, file_out, options): + # Filter out any instances of the \1 character from variable values + # since this character multiplies each time that the environment + # is saved (strange bash behavior). This can eventually result in +@@ -68,6 +74,8 @@ + if var_assign_match is not None: + quote = var_assign_match.group(3) + filter_this = pattern.match(var_assign_match.group(2)) is not None ++ if not filter_this and '--filter-traced-variables' in options: ++ filter_this = trace_re.match(line) is not None + # Exclude the start quote when searching for the end quote, + # to ensure that the start quote is not misidentified as the + # end quote (happens if there is a newline immediately after +@@ -78,7 +86,7 @@ + multi_line_quote = quote + multi_line_quote_filter = filter_this + if not filter_this: +- line = filter_declare_readonly_opt(line) ++ line = filter_declare_readonly_opt(line, options) + file_out.write(line.replace(b"\1", b"")) + continue + else: +@@ -86,8 +94,10 @@ + if declare_match is not None: + # declare without assignment + filter_this = pattern.match(declare_match.group(2)) is not None ++ if not filter_this and '--filter-traced-variables' in options: ++ filter_this = trace_re.match(line) is not None + if not filter_this: +- line = filter_declare_readonly_opt(line) ++ line = filter_declare_readonly_opt(line, options) + file_out.write(line) + continue + +@@ -127,8 +137,28 @@ + + "intact. The PATTERN is a space separated list of variable names" + + " and it supports python regular expression syntax." + ) +- usage = "usage: %s PATTERN" % os.path.basename(sys.argv[0]) +- args = sys.argv[1:] ++ usage = "usage: %s [-h|OPTIONS] PATTERN" % os.path.basename(sys.argv[0]) ++ args = [] ++ known_options = { ++ '--report-readonly-variables': ++ "Write names of readonly variables to stderr.", ++ '--preserve-readonly-attribute': ++ "Preserve the '-r' flag in 'declare -r'.", ++ '--filter-traced-variables': ++ "Filter out variables declared with '-t' attribute." ++ } ++ options = {} ++ for arg in sys.argv[1:]: ++ if arg in known_options.keys(): ++ options[arg] = True ++ continue ++ if '-h' == arg or '--help' == arg: ++ sys.stdout.write(usage + "\n\nKnown :\n\n") ++ for option, descr in known_options.items(): ++ sys.stdout.write(" " + option + "\t" + descr + "\n") ++ sys.stdout.flush() ++ sys.exit(os.EX_OK) ++ args.append(arg) + + if "-h" in args or "--help" in args: + sys.stdout.write(usage + "\n") +@@ -150,5 +180,5 @@ + var_pattern.append(br".*\W.*") + + var_pattern = b"^(" + b"|".join(var_pattern) + b")$" +- filter_bash_environment(re.compile(var_pattern), file_in, file_out) ++ filter_bash_environment(re.compile(var_pattern), file_in, file_out, options) + file_out.flush() +diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh +index bb17382d4..af35a3327 100755 +--- a/bin/save-ebuild-env.sh ++++ b/bin/save-ebuild-env.sh +@@ -53,7 +53,7 @@ + einfo einfon ewarn eerror ebegin __eend eend KV_major \ + KV_minor KV_micro KV_to_int get_KV has \ + __has_phase_defined_up_to \ +- hasv hasq __qa_source __qa_call \ ++ hasv hasq __qa_source __qa_call __call-ebuildshell \ + addread addwrite adddeny addpredict __sb_append_var \ + use usev useq has_version portageq \ + best_version use_with use_enable register_die_hook \ +diff --git a/man/make.conf.5 b/man/make.conf.5 +index b0c1aa4f2..568f350a0 100644 +--- a/man/make.conf.5 ++++ b/man/make.conf.5 +@@ -408,6 +408,12 @@ exist). Also see the related \fIunmerge\-backup\fR feature. + Use locks to ensure that unsandboxed ebuild phases never execute + concurrently. Also see \fIparallel\-install\fR. + .TP ++.B ebuildshell ++Drop into an interactive shell for each phase function, meant for ++debugging. Because the shell would normally be used to execute the ++phase function, commands like src_unpack or epatch are available in the ++interactive shell. Use `die` to terminate the merge. ++.TP + .B fail\-clean + Clean up temporary files after a build failure. This is particularly useful + if you have \fBPORTAGE_TMPDIR\fR on tmpfs. If this feature is enabled, you +diff --git a/lib/_emerge/AbstractEbuildProcess.py b/lib/_emerge/AbstractEbuildProcess.py +index 370cac529..a521596e5 100644 +--- a/lib/_emerge/AbstractEbuildProcess.py ++++ b/lib/_emerge/AbstractEbuildProcess.py +@@ -234,6 +234,7 @@ + null_fd = None + if ( + 0 not in self.fd_pipes ++ and "ebuildshell" not in self.settings.features + and self.phase not in self._phases_interactive_whitelist + and "interactive" not in self.settings.get("PROPERTIES", "").split() + ): +diff --git a/lib/portage/const.py b/lib/portage/const.py +index 3c23c85ed..d9c57f300 100644 +--- a/lib/portage/const.py ++++ b/lib/portage/const.py +@@ -172,6 +172,7 @@ + "distlocks", + "downgrade-backup", + "ebuild-locks", ++ "ebuildshell", + "fail-clean", + "fakeroot", + "fixlafiles", +-- +2.16.1 + diff --git a/sys-apps/portage/files/portage-3.0.30-prefix-stack.patch b/sys-apps/portage/files/portage-3.0.30-prefix-stack.patch new file mode 100644 index 0000000000..c49c473ea3 --- /dev/null +++ b/sys-apps/portage/files/portage-3.0.30-prefix-stack.patch @@ -0,0 +1,81 @@ +From 1fe30e79c368ce71e024d70c3ec07a6aed3ef262 Mon Sep 17 00:00:00 2001 +From: Michael Haubenwallner +Date: Fri, 22 Mar 2019 17:52:05 +0100 +Subject: [PATCH] from FEATURES=stacked-prefix to USE=prefix-stack + +Rather than telling the base prefix' portage to support stacked prefix, +be explicit in the stacked prefix about to USE that feature. +Bug: https://bugs.gentoo.org/658572 +--- + bin/install-qa-check.d/05prefix | 10 +++------- + bin/phase-helpers.sh | 12 ++++-------- + lib/portage/const.py | 1 - + 3 files changed, 7 insertions(+), 16 deletions(-) + +diff --git a/bin/install-qa-check.d/05prefix b/bin/install-qa-check.d/05prefix +index 03da3bbce..4f48e4216 100644 +--- a/bin/install-qa-check.d/05prefix ++++ b/bin/install-qa-check.d/05prefix +@@ -36,16 +36,12 @@ install_qa_check_prefix() { + local WHITELIST=" /usr/bin/env " + # shebang can be an absolutised path, bug #342929 + local eprefix=$(canonicalize ${EPREFIX}) +- # Without the stacked-prefix feature, tests using BPREFIX +- # are redundant to EPREFIX, but run only if we will fail. ++ # Without USE=prefix-stack, tests using BPREFIX are ++ # redundant to EPREFIX, but run only if we will fail. + # Otherways, BPREFIX really is BROOT (the EAPI 7 one). + local BPREFIX=${EPREFIX} + local bprefix=${eprefix} +- if has stacked-prefix ${FEATURES} && +- [[ -z ${ROOT%/} ]] && +- [[ ${CBUILD} == ${CHOST} ]] && +- [[ ${EPREFIX} != ${BROOT-${PORTAGE_OVERRIDE_EPREFIX}} ]] && +- :; then ++ if has prefix-stack ${USE} ; then + BPREFIX=${BROOT-${PORTAGE_OVERRIDE_EPREFIX}} + bprefix=$(canonicalize ${BPREFIX}) + fi +diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh +index 606b1cdfd..c64f1106b 100644 +--- a/bin/phase-helpers.sh ++++ b/bin/phase-helpers.sh +@@ -932,18 +932,14 @@ ___best_version_and_has_version_common() { + fi ;; + esac + +- # PREFIX LOCAL: stacked-prefix feature ++ # PREFIX LOCAL: prefix-stack feature + if ___eapi_has_prefix_variables && + has "${root_arg}" '--host-root' '-b' && +- has stacked-prefix ${FEATURES} && ++ has prefix-stack ${USE} && + [[ -z ${ROOT%/} ]] && +- [[ ${CBUILD} == ${CHOST} ]] && +- [[ ${EPREFIX} != ${BROOT-${PORTAGE_OVERRIDE_EPREFIX}} ]] && + :; then +- # When we merge into another EPREFIX, but not into some ROOT, +- # and CHOST is equal to CBUILD, build tools found in EPREFIX +- # perfectly work for the current build environment. +- # In a "stacked prefix" we explicitly utilize this situation. ++ # When we merge into "stacked" EPREFIX, but not into some ROOT, build ++ # tools found in EPREFIX perfectly work for current build environment. + "${FUNCNAME[1]}" "${atom}" && return 0 + fi + # END PREFIX LOCAL +diff --git a/lib/portage/const.py b/lib/portage/const.py +index eddce377d..db02cbc56 100644 +--- a/lib/portage/const.py ++++ b/lib/portage/const.py +@@ -207,8 +207,6 @@ SUPPORTED_FEATURES = frozenset([ + "usersync", + "webrsync-gpg", + "xattr", +- # PREFIX LOCAL +- "stacked-prefix", + ] + ) + +-- +2.19.2 + diff --git a/sys-apps/portage/portage-3.0.30.ebuild b/sys-apps/portage/portage-3.0.30.ebuild new file mode 100644 index 0000000000..88a5cd8eac --- /dev/null +++ b/sys-apps/portage/portage-3.0.30.ebuild @@ -0,0 +1,307 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +DISTUTILS_USE_SETUPTOOLS=no +PYTHON_COMPAT=( pypy3 python3_{7..9} ) +PYTHON_REQ_USE='bzip2(+),threads(+)' + +inherit distutils-r1 linux-info systemd prefix + +DESCRIPTION="Portage package manager used in Gentoo Prefix" +HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage" + +LICENSE="GPL-2" +KEYWORDS="~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" +SLOT="0" +IUSE="apidoc build doc gentoo-dev +ipc +native-extensions rsync-verify selinux test xattr" +RESTRICT="!test? ( test )" + +BDEPEND=" + app-arch/xz-utils + test? ( dev-vcs/git )" +DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') ) + >=app-arch/tar-1.27 + dev-lang/python-exec:2 + >=sys-apps/sed-4.0.5 sys-devel/patch + doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 ) + apidoc? ( + dev-python/sphinx + dev-python/sphinx-epytext + )" +# Require sandbox-2.2 for bug #288863. +# For whirlpool hash, require python[ssl] (bug #425046). +# For compgen, require bash[readline] (bug #445576). +# app-portage/gemato goes without PYTHON_USEDEP since we're calling +# the executable. +RDEPEND=" + !prefix? ( acct-user/portage ) + app-arch/zstd + >=app-arch/tar-1.27 + dev-lang/python-exec:2 + >=sys-apps/findutils-4.4 + !build? ( + >=sys-apps/sed-4.0.5 + >=app-shells/bash-5.0:0[readline] + >=app-admin/eselect-1.2 + rsync-verify? ( + >=app-portage/gemato-14.5[${PYTHON_USEDEP}] + >=sec-keys/openpgp-keys-gentoo-release-20180706 + >=app-crypt/gnupg-2.2.4-r2[ssl(-)] + ) + ) + elibc_glibc? ( !prefix? ( >=sys-apps/sandbox-2.2 ) ) + elibc_musl? ( >=sys-apps/sandbox-2.2 ) + kernel_linux? ( sys-apps/util-linux ) + >=app-misc/pax-utils-0.1.18 + selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] ) + xattr? ( kernel_linux? ( + >=sys-apps/install-xattr-0.3 + ) ) + !> cnf/make.globals || die + fi + + if use native-extensions; then + printf "[build_ext]\nportage_ext_modules=true\n" >> \ + setup.cfg || die + fi + + if ! use ipc ; then + einfo "Disabling ipc..." + sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \ + -i lib/_emerge/AbstractEbuildProcess.py || \ + die "failed to patch AbstractEbuildProcess.py" + fi + + if use xattr && use kernel_linux ; then + einfo "Adding FEATURES=xattr to make.globals ..." + echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \ + || die "failed to append to make.globals" + fi + + if use build || ! use rsync-verify; then + sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \ + -e '/^sync-webrsync-verify-signature/s|yes|no|' \ + -i cnf/repos.conf || die "sed failed" + fi + + if [[ -n ${EPREFIX} ]] ; then + # PREFIX LOCAL: only hack const_autotool + local extrapath="/usr/sbin:/usr/bin:/sbin:/bin" + # ok, we can't rely on PORTAGE_ROOT_USER being there yet, as people + # tend not to update that often, as long as we are a separate ebuild + # we can assume when unset, it's time for some older trick + if [[ -z ${PORTAGE_ROOT_USER} ]] ; then + PORTAGE_ROOT_USER=$(python -c 'from portage.const import rootuser; print rootuser') + fi + # We need to probe for bash in the Prefix, because it may not + # exist, in which case we fall back to the currently in use + # bash. This logic is necessary in particular during bootstrap, + # where we pull ourselves out of a temporary place with tools + local bash="${EPREFIX}/bin/bash" + [[ ! -x ${bash} ]] && bash=${BASH} + + einfo "Adjusting sources for ${EPREFIX}" + find . -type f -exec \ + sed -e "s|@PORTAGE_EPREFIX@|${EPREFIX}|" \ + -e "s|@PORTAGE_MV@|$(type -P mv)|" \ + -e "s|@PORTAGE_BASH@|${bash}|" \ + -e "s|@PREFIX_PORTAGE_PYTHON@|$(type -P python)|" \ + -e "s|@EXTRA_PATH@|${extrapath}|" \ + -e "s|@portagegroup@|${PORTAGE_GROUP:-portage}|" \ + -e "s|@portageuser@|${PORTAGE_USER:-portage}|" \ + -e "s|@rootuser@|${PORTAGE_ROOT_USER:-root}|" \ + -e "s|@rootuid@|$(id -u ${PORTAGE_ROOT_USER:-root})|" \ + -e "s|@rootgid@|$(id -g ${PORTAGE_ROOT_USER:-root})|" \ + -e "s|@sysconfdir@|${EPREFIX}/etc|" \ + -i '{}' + || \ + die "Failed to patch sources" + # We don't need the below, since setup.py deals with this (and + # more) so we don't have to make this correct + # -e "s|@PORTAGE_BASE@|${EPREFIX}/usr/lib/portage/${EPYTHON}|" \ + + # remove Makefiles, or else they will get installed + find . -name "Makefile.*" -delete + + einfo "Prefixing shebangs ..." + while read -r -d $'\0' ; do + local shebang=$(head -n1 "$REPLY") + if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then + sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \ + die "sed failed" + fi + done < <(find . -type f ! -name etc-update -print0) + + einfo "Setting gentoo_prefix as reponame for emerge-webrsync" + sed -i -e 's/repo_name=gentoo/repo_name=gentoo_prefix/' \ + bin/emerge-webrsync || die + + einfo "Making absent gemato non-fatal" + sed -i -e '/exitcode = 127/d' \ + lib/portage/sync/modules/rsync/rsync.py || die + # END PREFIX LOCAL + fi + + # PREFIX LOCAL: make.conf is written by bootstrap-prefix.sh + if use !prefix ; then + cd "${S}/cnf" || die + if [ -f "make.conf.example.${ARCH}".diff ]; then + patch make.conf.example "make.conf.example.${ARCH}".diff || \ + die "Failed to patch make.conf.example" + else + eerror "" + eerror "Portage does not have an arch-specific configuration for this arch." + eerror "Please notify the arch maintainer about this issue. Using generic." + eerror "" + fi + fi +} + +python_compile_all() { + local targets=() + use doc && targets+=( docbook ) + use apidoc && targets+=( apidoc ) + + if [[ ${targets[@]} ]]; then + esetup.py "${targets[@]}" + fi +} + +python_test() { + esetup.py test +} + +python_install() { + # Install sbin scripts to bindir for python-exec linking + # they will be relocated in pkg_preinst() + distutils-r1_python_install \ + --system-prefix="${EPREFIX}/usr" \ + --bindir="$(python_get_scriptdir)" \ + --docdir="${EPREFIX}/usr/share/doc/${PF}" \ + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \ + --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \ + --sbindir="$(python_get_scriptdir)" \ + --sysconfdir="${EPREFIX}/etc" \ + "${@}" +} + +python_install_all() { + distutils-r1_python_install_all + + local targets=() + use doc && targets+=( + install_docbook + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" + ) + use apidoc && targets+=( + install_apidoc + --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" + ) + + # install docs + if [[ ${targets[@]} ]]; then + esetup.py "${targets[@]}" + fi + + dotmpfiles "${FILESDIR}"/portage-ccache.conf + + # Due to distutils/python-exec limitations + # these must be installed to /usr/bin. + local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld' + einfo "Moving admin scripts to the correct directory" + dodir /usr/sbin + for target in ${sbin_relocations}; do + einfo "Moving /usr/bin/${target} to /usr/sbin/${target}" + mv "${ED}/usr/bin/${target}" "${ED}/usr/sbin/${target}" || die "sbin scripts move failed!" + done +} + +pkg_preinst() { + python_setup + local sitedir=$(python_get_sitedir) + [[ -d ${D}${sitedir} ]] || die "${D}${sitedir}: No such directory" + env -u DISTDIR \ + -u PORTAGE_OVERRIDE_EPREFIX \ + -u PORTAGE_REPOSITORIES \ + -u PORTDIR \ + -u PORTDIR_OVERLAY \ + PYTHONPATH="${D}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \ + "${PYTHON}" -m portage._compat_upgrade.default_locations || die + + env -u BINPKG_COMPRESS -u PORTAGE_REPOSITORIES \ + PYTHONPATH="${D}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \ + "${PYTHON}" -m portage._compat_upgrade.binpkg_compression || die + + env -u FEATURES -u PORTAGE_REPOSITORIES \ + PYTHONPATH="${D}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \ + "${PYTHON}" -m portage._compat_upgrade.binpkg_multi_instance || die + + # elog dir must exist to avoid logrotate error for bug #415911. + # This code runs in preinst in order to bypass the mapping of + # portage:portage to root:root which happens after src_install. + keepdir /var/log/portage/elog + # This is allowed to fail if the user/group are invalid for prefix users. + if chown ${PORTAGE_USER}:${PORTAGE_GROUP} "${ED}"/var/log/portage{,/elog} 2>/dev/null ; then + chmod g+s,ug+rwx "${ED}"/var/log/portage{,/elog} + fi + + if has_version "<${CATEGORY}/${PN}-2.3.77"; then + elog "The emerge --autounmask option is now disabled by default, except for" + elog "portions of behavior which are controlled by the --autounmask-use and" + elog "--autounmask-license options. For backward compatibility, previous" + elog "behavior of --autounmask=y and --autounmask=n is entirely preserved." + elog "Users can get the old behavior simply by adding --autounmask to the" + elog "make.conf EMERGE_DEFAULT_OPTS variable. For the rationale for this" + elog "change, see https://bugs.gentoo.org/658648." + fi +}