From 9df60459337bfbe3f3fe7bb2b48ef18c076284af Mon Sep 17 00:00:00 2001 From: Michael Haubenwallner Date: Mon, 2 May 2016 11:15:21 +0200 Subject: +portage-2.2.28-r2: bump ebuildshell patch bug#155161 comment#32 Package-Manager: portage-2.2.28-prefix --- .../portage/files/portage-2.2.28-ebuildshell.patch | 92 ++++---- sys-apps/portage/portage-2.2.28-r1.ebuild | 259 --------------------- sys-apps/portage/portage-2.2.28-r2.ebuild | 259 +++++++++++++++++++++ 3 files changed, 312 insertions(+), 298 deletions(-) delete mode 100644 sys-apps/portage/portage-2.2.28-r1.ebuild create mode 100644 sys-apps/portage/portage-2.2.28-r2.ebuild diff --git a/sys-apps/portage/files/portage-2.2.28-ebuildshell.patch b/sys-apps/portage/files/portage-2.2.28-ebuildshell.patch index 7e7e71d960..afd2f3952f 100644 --- a/sys-apps/portage/files/portage-2.2.28-ebuildshell.patch +++ b/sys-apps/portage/files/portage-2.2.28-ebuildshell.patch @@ -1,19 +1,19 @@ -From 096a74009cea9c79bcc2729d18a3cbcb99783aeb Mon Sep 17 00:00:00 2001 +From c93cb045630db71f8fbc0e0b67960a28764a6852 Mon Sep 17 00:00:00 2001 From: Michael Haubenwallner Date: Wed, 6 Nov 2013 12:40:05 +0100 Subject: [PATCH] Add ebuildshell feature, bug#155161. --- - bin/ebuild.sh | 102 ++++++++++++++++++++++++++++++++++- - bin/filter-bash-environment.py | 65 ++++++++++++++++------ + bin/ebuild.sh | 131 ++++++++++++++++++++++++++++++++++- + bin/filter-bash-environment.py | 50 ++++++++----- bin/save-ebuild-env.sh | 2 +- - man/make.conf.5 | 6 +++ + man/make.conf.5 | 6 ++ pym/_emerge/AbstractEbuildProcess.py | 1 + pym/portage/const.py | 1 + - 6 files changed, 159 insertions(+), 18 deletions(-) + 6 files changed, 173 insertions(+), 18 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh -index f1586b2..06c90df 100755 +index f1586b2..cb487c0 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -130,7 +130,7 @@ __qa_source() { @@ -25,7 +25,7 @@ index f1586b2..06c90df 100755 retval=$? set +e [[ $shopts != $(shopt) ]] && -@@ -537,6 +537,106 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then +@@ -537,6 +537,135 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then unset BIN_PATH BIN BODY FUNC_SRC fi @@ -74,14 +74,31 @@ index f1586b2..06c90df 100755 + type $1 + echo "WANTED: \$@" + echo "or use: \"\\\$@\"" -+ # use bash history, but not the user's real one ++ # use bash history, but not the 'user's real one + HISTFILE=~/.bash_history -+ # for copy&paste function body lines containing: local -+ alias local=declare + # for copy&paste function body lines containing: ! + set +H ++ # Support the 'local' keyword outside any shell function ++ # for copy&paste of function body lines: Remember these ++ # "local" variable names for filtering from return-env. ++ __ebuildshell_local_vars= ++ __ebuildshell_local() { ++ local __ebuildshell_local_attr= ++ while [[ \${1} == -* ]]; do ++ __ebuildshell_local_attr+=" \${1}" ++ shift ++ done ++ __ebuildshell_local_vars+=" \${1%%=*} " ++ # Need to declare into the global shell namespace, ++ # as we are in some shell function here apparently. ++ declare -g \${__ebuildshell_local_attr} "\$@" ++ } ++ # within some function, BASH_LINENO is set, and we use real 'local' ++ alias local='\$( (( \${#BASH_LINENO} > 0 )) && echo local || echo __ebuildshell_local)' + # at exit, dump the current environment + trap " ++ unalias local ++ unset -f __ebuildshell_local + rm -f '${__ebuildshell_tmpf}.return-'* + ( + ( @@ -93,13 +110,14 @@ index f1586b2..06c90df 100755 + ( + # We may have more readonly variables now, but we + # need to filter variables that are readonly already. -+ 2>"${__ebuildshell_tmpf}.return-rovars" \ -+ '${PORTAGE_PYTHON:-/tools/haubi/gentoo/s01en24/usr/bin/python}' \ ++ 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 \ -+ --export-into-global-scope \ -+ '${__ebuildshell_bash_i_vars} ${__ebuildshell_ro_ebuild_vars}' \\ ++ --report-readonly-variables \\ ++ --preserve-readonly-attribute \\ ++ '${__ebuildshell_bash_i_vars} ++ ${__ebuildshell_ro_ebuild_vars} ++ '\" \${__ebuildshell_local_vars}\" \\ + || die 'filter-bash-environment.py failed' + ) + ) > '${__ebuildshell_tmpf}.return-env' @@ -120,12 +138,23 @@ index f1586b2..06c90df 100755 + # The environment- and exit-status handling after leaving the ebuildshell + # prompt is expected to be identical as without the ebuildshell prompt. + local __ebuildshell_status=$? ++ ++ # Defining a variable without using the the local keyword makes this ++ # variable visible to the 'global' shell namespace. But 'declare -p' ++ # does not show the -g flag, so we need to add that one for all ++ # variables that have been visible to the EXIT trap above. ++ local __ebuildshell_orig_expand_aliases=$(shopt -p expand_aliases) ++ alias declare='declare -g' ++ shopt -s expand_aliases + source "${__ebuildshell_tmpf}.return-env" ++ unalias declare ++ ${__ebuildshell_orig_expand_aliases} + # Portage does whitelist readonly variables. If an ebuild defines + # more readonly variables, their readonly attribute is removed. + # If we ever want to preserve additional readonly variables across + # phases, their names are in "${__ebuildshell_tmpf}.return-rovars". + rm -f "${__ebuildshell_tmpf}."{ebuild,return}-{env,rovars} ++ + return ${__ebuildshell_status} +} + @@ -133,20 +162,19 @@ index f1586b2..06c90df 100755 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 a4cdc54..a710e93 100755 +index a4cdc54..5ed2584 100755 --- a/bin/filter-bash-environment.py +++ b/bin/filter-bash-environment.py -@@ -14,7 +14,8 @@ func_end_re = re.compile(r'^\}$') +@@ -14,7 +14,7 @@ func_end_re = re.compile(r'^\}$') var_assign_re = re.compile(r'(^|^declare\s+-\S+\s+|^declare\s+|^export\s+)([^=\s]+)=("|\')?.*$') close_quote_re = re.compile(r'(\\"|"|\')\s*$') -readonly_re = re.compile(r'^declare\s+-(\S*)r(\S*)\s+') +readonly_re = re.compile(r'^declare\s+-(\S*)r(\S*)\s+([^=\s]+)') -+export_re = re.compile(r'^declare\s+-(\S*x\S*)\s+') # declare without assignment var_declare_re = re.compile(r'^declare(\s+-\S+)?\s+([^=\s]+)\s*$') -@@ -29,7 +30,7 @@ def have_end_quote(quote, line): +@@ -29,7 +29,7 @@ def have_end_quote(quote, line): return close_quote_match is not None and \ close_quote_match.group(1) == quote @@ -155,7 +183,7 @@ index a4cdc54..a710e93 100755 readonly_match = readonly_re.match(line) if readonly_match is not None: declare_opts = '' -@@ -37,14 +38,29 @@ def filter_declare_readonly_opt(line): +@@ -37,14 +37,19 @@ def filter_declare_readonly_opt(line): group = readonly_match.group(i) if group is not None: declare_opts += group @@ -175,41 +203,29 @@ index a4cdc54..a710e93 100755 return line -def filter_bash_environment(pattern, file_in, file_out): -+def add_global_export_opt(line, options): -+ export_match = export_re.match(line) -+ if export_match is not None: -+ declare_opts = export_match.group(1) -+ if 'g' not in declare_opts and '--export-into-global-scope' in options: -+ declare_opts += 'g' -+ line = 'declare -%s %s' % \ -+ (declare_opts, line[export_match.end():]) -+ return line -+ +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 -@@ -77,7 +93,8 @@ def filter_bash_environment(pattern, file_in, file_out): +@@ -77,7 +82,7 @@ def filter_bash_environment(pattern, file_in, file_out): 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) -+ line = add_global_export_opt(line, options) file_out.write(line.replace("\1", "")) continue else: -@@ -87,7 +104,8 @@ def filter_bash_environment(pattern, file_in, file_out): +@@ -87,7 +92,7 @@ def filter_bash_environment(pattern, file_in, file_out): filter_this = pattern.match(declare_match.group(2)) \ is not None if not filter_this: - line = filter_declare_readonly_opt(line) + line = filter_declare_readonly_opt(line, options) -+ line = add_global_export_opt(line, options) file_out.write(line) continue -@@ -124,13 +142,28 @@ if __name__ == "__main__": +@@ -124,13 +129,26 @@ if __name__ == "__main__": "while leaving bash function definitions and here-documents " + \ "intact. The PATTERN is a space separated list of variable names" + \ " and it supports python regular expression syntax." @@ -227,8 +243,6 @@ index a4cdc54..a710e93 100755 + "Write names of readonly variables to stderr.", + '--preserve-readonly-attribute': + "Preserve the '-r' flag in 'declare -r'.", -+ '--export-into-global-scope': -+ "Add the '-g' flag to 'declare -x'.", + } + options = {} + for arg in sys.argv[1:]: @@ -245,7 +259,7 @@ index a4cdc54..a710e93 100755 if len(args) != 1: sys.stderr.write(usage + "\n") -@@ -154,5 +187,5 @@ if __name__ == "__main__": +@@ -154,5 +172,5 @@ if __name__ == "__main__": var_pattern = "^(%s)$" % "|".join(var_pattern) filter_bash_environment( diff --git a/sys-apps/portage/portage-2.2.28-r1.ebuild b/sys-apps/portage/portage-2.2.28-r1.ebuild deleted file mode 100644 index 672b9daff2..0000000000 --- a/sys-apps/portage/portage-2.2.28-r1.ebuild +++ /dev/null @@ -1,259 +0,0 @@ -# Copyright 1999-2016 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -EAPI=5 - -PYTHON_COMPAT=( - pypy - python3_3 python3_4 python3_5 - python2_7 -) -PYTHON_REQ_USE='bzip2(+)' - -inherit eutils distutils-r1 multilib - -DESCRIPTION="Portage package manager used in Gentoo Prefix" -HOMEPAGE="http://prefix.gentoo.org/" -LICENSE="GPL-2" -KEYWORDS="~ppc-aix ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" -SLOT="0" -IUSE="build doc epydoc +ipc linguas_ru selinux xattr prefix-chaining" - -DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') ) - >=sys-devel/make-3.82 - >=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 ) - epydoc? ( >=dev-python/epydoc-2.0[$(python_gen_usedep 'python2*')] )" -# Require sandbox-2.2 for bug #288863. -# For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's -# quite slow, so it's not considered in the dependencies as an alternative to -# to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so -# for now, don't pull in xattr deps for other kernels. -# For whirlpool hash, require python[ssl] (bug #425046). -# For compgen, require bash[readline] (bug #445576). -RDEPEND=" - >=app-arch/tar-1.27 - dev-lang/python-exec:2 - !build? ( - >=sys-apps/sed-4.0.5 - app-shells/bash:0[readline] - >=app-admin/eselect-1.2 - ) - elibc_FreeBSD? ( !prefix? ( sys-freebsd/freebsd-bin ) ) - elibc_glibc? ( !prefix? ( >=sys-apps/sandbox-2.2 ) ) - elibc_uclibc? ( !prefix? ( >=sys-apps/sandbox-2.2 ) ) - kernel_linux? ( >=app-misc/pax-utils-0.1.17 ) - kernel_SunOS? ( >=app-misc/pax-utils-0.1.17 ) - kernel_FreeBSD? ( >=app-misc/pax-utils-0.1.17 ) - kernel_Darwin? ( >=app-misc/pax-utils-0.1.18 ) - kernel_HPUX? ( !hppa-hpux? ( >=app-misc/pax-utils-0.1.19 ) ) - kernel_AIX? ( >=sys-apps/aix-miscutils-0.1.1634 ) - selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] ) - xattr? ( kernel_linux? ( - >=sys-apps/install-xattr-0.3 - $(python_gen_cond_dep 'dev-python/pyxattr[${PYTHON_USEDEP}]' \ - python2_7 pypy) - ) ) - !prefix? ( !> cnf/make.globals \ - || die "failed to append to make.globals" - fi - - if [[ -n ${EPREFIX} ]] ; then - # PREFIX LOCAL: only hack const_autotool - local extrapath="/usr/bin:/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 - # lazy check, but works for now - if [[ ${PORTAGE_ROOT_USER} == "root" ]] ; then - # we need this for e.g. mtree on FreeBSD (and Darwin) which is in - # /usr/sbin - extrapath="/usr/sbin:/usr/bin:/sbin:/bin" - fi - local defaultpath="${EPREFIX}/usr/sbin:${EPREFIX}/usr/bin:${EPREFIX}/sbin:${EPREFIX}/bin" - # 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|@DEFAULT_PATH@|${defaultpath}|" \ - -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 deal 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 -print0) - # 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.${ARCH}".diff ]; then - patch make.conf "make.conf.${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 epydoc && targets+=( epydoc ) - - 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 ) - use epydoc && targets+=( install_epydoc ) - - # install docs - if [[ ${targets[@]} ]]; then - esetup.py "${targets[@]}" - fi - - # 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() { - # comment out sanity test until it is fixed to work - # with the new PORTAGE_PYM_PATH - #if [[ $ROOT == / ]] ; then - ## Run some minimal tests as a sanity check. - #local test_runner=$(find "${ED}" -name runTests) - #if [[ -n $test_runner && -x $test_runner ]] ; then - #einfo "Running preinst sanity tests..." - #"$test_runner" || die "preinst sanity tests failed" - #fi - #fi - - # 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 -} diff --git a/sys-apps/portage/portage-2.2.28-r2.ebuild b/sys-apps/portage/portage-2.2.28-r2.ebuild new file mode 100644 index 0000000000..672b9daff2 --- /dev/null +++ b/sys-apps/portage/portage-2.2.28-r2.ebuild @@ -0,0 +1,259 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 + +PYTHON_COMPAT=( + pypy + python3_3 python3_4 python3_5 + python2_7 +) +PYTHON_REQ_USE='bzip2(+)' + +inherit eutils distutils-r1 multilib + +DESCRIPTION="Portage package manager used in Gentoo Prefix" +HOMEPAGE="http://prefix.gentoo.org/" +LICENSE="GPL-2" +KEYWORDS="~ppc-aix ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" +SLOT="0" +IUSE="build doc epydoc +ipc linguas_ru selinux xattr prefix-chaining" + +DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') ) + >=sys-devel/make-3.82 + >=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 ) + epydoc? ( >=dev-python/epydoc-2.0[$(python_gen_usedep 'python2*')] )" +# Require sandbox-2.2 for bug #288863. +# For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's +# quite slow, so it's not considered in the dependencies as an alternative to +# to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so +# for now, don't pull in xattr deps for other kernels. +# For whirlpool hash, require python[ssl] (bug #425046). +# For compgen, require bash[readline] (bug #445576). +RDEPEND=" + >=app-arch/tar-1.27 + dev-lang/python-exec:2 + !build? ( + >=sys-apps/sed-4.0.5 + app-shells/bash:0[readline] + >=app-admin/eselect-1.2 + ) + elibc_FreeBSD? ( !prefix? ( sys-freebsd/freebsd-bin ) ) + elibc_glibc? ( !prefix? ( >=sys-apps/sandbox-2.2 ) ) + elibc_uclibc? ( !prefix? ( >=sys-apps/sandbox-2.2 ) ) + kernel_linux? ( >=app-misc/pax-utils-0.1.17 ) + kernel_SunOS? ( >=app-misc/pax-utils-0.1.17 ) + kernel_FreeBSD? ( >=app-misc/pax-utils-0.1.17 ) + kernel_Darwin? ( >=app-misc/pax-utils-0.1.18 ) + kernel_HPUX? ( !hppa-hpux? ( >=app-misc/pax-utils-0.1.19 ) ) + kernel_AIX? ( >=sys-apps/aix-miscutils-0.1.1634 ) + selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] ) + xattr? ( kernel_linux? ( + >=sys-apps/install-xattr-0.3 + $(python_gen_cond_dep 'dev-python/pyxattr[${PYTHON_USEDEP}]' \ + python2_7 pypy) + ) ) + !prefix? ( !> cnf/make.globals \ + || die "failed to append to make.globals" + fi + + if [[ -n ${EPREFIX} ]] ; then + # PREFIX LOCAL: only hack const_autotool + local extrapath="/usr/bin:/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 + # lazy check, but works for now + if [[ ${PORTAGE_ROOT_USER} == "root" ]] ; then + # we need this for e.g. mtree on FreeBSD (and Darwin) which is in + # /usr/sbin + extrapath="/usr/sbin:/usr/bin:/sbin:/bin" + fi + local defaultpath="${EPREFIX}/usr/sbin:${EPREFIX}/usr/bin:${EPREFIX}/sbin:${EPREFIX}/bin" + # 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|@DEFAULT_PATH@|${defaultpath}|" \ + -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 deal 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 -print0) + # 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.${ARCH}".diff ]; then + patch make.conf "make.conf.${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 epydoc && targets+=( epydoc ) + + 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 ) + use epydoc && targets+=( install_epydoc ) + + # install docs + if [[ ${targets[@]} ]]; then + esetup.py "${targets[@]}" + fi + + # 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() { + # comment out sanity test until it is fixed to work + # with the new PORTAGE_PYM_PATH + #if [[ $ROOT == / ]] ; then + ## Run some minimal tests as a sanity check. + #local test_runner=$(find "${ED}" -name runTests) + #if [[ -n $test_runner && -x $test_runner ]] ; then + #einfo "Running preinst sanity tests..." + #"$test_runner" || die "preinst sanity tests failed" + #fi + #fi + + # 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 +} -- cgit v1.2.3-65-gdbad