From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QiMSo-00072j-SS for garchives@archives.gentoo.org; Sun, 17 Jul 2011 08:12:37 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DCE4021C0F0; Sun, 17 Jul 2011 08:12:24 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 76A4621C0F0 for ; Sun, 17 Jul 2011 08:12:24 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B51292AC004 for ; Sun, 17 Jul 2011 08:12:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 26ABA8003D for ; Sun, 17 Jul 2011 08:12:23 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: Subject: [gentoo-commits] proj/portage:prefix commit in: / X-VCS-Repository: proj/portage X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: b128cd7bd251a176ff08f84503fc6764a33311f1 Date: Sun, 17 Jul 2011 08:12:23 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 12a95951b62f1f221b974ed5eb025ba9 commit: b128cd7bd251a176ff08f84503fc6764a33311f1 Author: Fabian Groffen gentoo org> AuthorDate: Sun Jul 17 08:11:06 2011 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun Jul 17 08:11:06 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Db128cd7b Merge remote-tracking branch 'overlays-gentoo-org/master' into prefix Conflicts: bin/binhost-snapshot bin/ebuild-helpers/doman bin/ebuild-helpers/prepall bin/ebuild-helpers/prepallman bin/ebuild-helpers/prepinfo bin/ebuild-helpers/prepman bin/ebuild-helpers/prepstrip bin/ebuild.sh bin/filter-bash-environment.py bin/misc-functions.sh pym/_emerge/Binpkg.py pym/_emerge/main.py pym/portage/elog/mod_save.py pym/portage/elog/mod_save_summary.py pym/portage/package/ebuild/prepare_build_dirs.py bin/binhost-snapshot | 6 +- bin/ebuild-helpers/doman | 8 +- bin/ebuild-helpers/prepall | 6 +- bin/ebuild-helpers/prepallman | 4 +- bin/ebuild-helpers/prepinfo | 4 +- bin/ebuild-helpers/prepman | 4 +- bin/ebuild-helpers/prepstrip | 24 ++-- bin/ebuild.sh | 128 +++++++++-----= ---- bin/egencache | 41 +++--- bin/emerge-webrsync | 4 +- bin/filter-bash-environment.py | 12 +- bin/isolated-functions.sh | 23 ++- bin/misc-functions.sh | 36 +++--- bin/portageq | 3 +- bin/repoman | 15 +- cnf/logrotate.d/elog-save-summary | 3 +- man/ebuild.5 | 8 +- man/make.conf.5 | 6 +- pym/_emerge/AbstractEbuildProcess.py | 10 +- pym/_emerge/Binpkg.py | 28 ++-- pym/_emerge/BinpkgVerifier.py | 8 +- pym/_emerge/EbuildBuild.py | 31 ++++- pym/_emerge/EbuildFetcher.py | 144 ++++++++++++++= ++---- pym/_emerge/EbuildMetadataPhase.py | 4 +- pym/_emerge/EbuildPhase.py | 38 +++--- pym/_emerge/JobStatusDisplay.py | 8 +- pym/_emerge/Scheduler.py | 6 +- pym/_emerge/UseFlagDisplay.py | 7 +- pym/_emerge/actions.py | 26 +++- pym/_emerge/depgraph.py | 103 +++++++++----- pym/_emerge/emergelog.py | 18 ++- pym/_emerge/is_valid_package_atom.py | 18 ++- pym/_emerge/main.py | 8 +- pym/_emerge/resolver/circular_dependency.py | 48 +++---- pym/_emerge/resolver/output_helpers.py | 4 +- pym/_emerge/resolver/slot_collision.py | 44 +++++- pym/portage/__init__.py | 37 +----- pym/portage/_ensure_encodings.py | 132 --------------= ---- pym/portage/cache/flat_hash.py | 19 ++- pym/portage/cache/flat_list.py | 18 ++- pym/portage/checksum.py | 9 +- pym/portage/const.py | 1 + pym/portage/cvstree.py | 6 +- pym/portage/dbapi/_MergeProcess.py | 6 +- pym/portage/dbapi/bintree.py | 5 +- pym/portage/dbapi/cpv_expand.py | 6 +- pym/portage/dbapi/porttree.py | 5 +- pym/portage/dbapi/vartree.py | 39 +++--- pym/portage/dispatch_conf.py | 6 +- pym/portage/elog/messages.py | 7 +- pym/portage/elog/mod_save.py | 40 ++++-- pym/portage/elog/mod_save_summary.py | 48 +++++-- pym/portage/env/loaders.py | 6 +- pym/portage/glsa.py | 8 +- pym/portage/manifest.py | 11 +- pym/portage/news.py | 6 +- pym/portage/output.py | 10 +- .../package/ebuild/_config/LocationsManager.py | 6 +- .../package/ebuild/_config/special_env_vars.py | 3 +- pym/portage/package/ebuild/_ipc/QueryCommand.py | 11 +- .../package/ebuild/deprecated_profile_check.py | 6 +- pym/portage/package/ebuild/digestcheck.py | 18 ++- pym/portage/package/ebuild/doebuild.py | 47 ++++--- pym/portage/package/ebuild/fetch.py | 10 +- pym/portage/package/ebuild/prepare_build_dirs.py | 55 +++++++- pym/portage/repository/config.py | 10 +- pym/portage/tests/ebuild/test_spawn.py | 6 +- .../test_lazy_import_portage_baseline.py | 2 +- pym/portage/tests/resolver/test_slot_collisions.py | 18 +++ pym/portage/update.py | 12 +- pym/portage/util/ExtractKernelVersion.py | 6 +- pym/portage/util/__init__.py | 39 ++++-- pym/portage/util/env_update.py | 4 +- pym/repoman/checks.py | 34 ++++- pym/repoman/errors.py | 2 + pym/repoman/utilities.py | 6 +- 76 files changed, 908 insertions(+), 700 deletions(-) diff --cc bin/binhost-snapshot index 662b027,9d2697d..54d2102 --- a/bin/binhost-snapshot +++ b/bin/binhost-snapshot @@@ -1,8 -1,8 +1,8 @@@ -#!/usr/bin/python +#!@PREFIX_PORTAGE_PYTHON@ - # Copyright 2010 Gentoo Foundation + # Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 - import codecs + import io import optparse import os import sys diff --cc bin/ebuild-helpers/doman index cfe8a8f,4561bef..e947e0d --- a/bin/ebuild-helpers/doman +++ b/bin/ebuild-helpers/doman @@@ -1,8 -1,8 +1,8 @@@ -#!/bin/bash +#!@PORTAGE_BASH@ - # Copyright 1999-2010 Gentoo Foundation + # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.s= h +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh =20 if [[ $# -lt 1 ]] ; then helpers_die "${0##*/}: at least one argument needed" diff --cc bin/ebuild-helpers/prepall index f9164c1,701ecba..a765756 --- a/bin/ebuild-helpers/prepall +++ b/bin/ebuild-helpers/prepall @@@ -1,17 -1,15 +1,17 @@@ -#!/bin/bash +#!@PORTAGE_BASH@ - # Copyright 1999-2007 Gentoo Foundation + # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.s= h +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh + +[[ -d ${ED} ]] || exit 0 =20 - if hasq chflags $FEATURES ; then + if has chflags $FEATURES ; then # Save all the file flags for restoration at the end of prepall. - mtree -c -p "${D}" -k flags > "${T}/bsdflags.mtree" + mtree -c -p "${ED}" -k flags > "${T}/bsdflags.mtree" # Remove all the file flags so that prepall can do anything necessary. - chflags -R noschg,nouchg,nosappnd,nouappnd "${D}" - chflags -R nosunlnk,nouunlnk "${D}" 2>/dev/null + chflags -R noschg,nouchg,nosappnd,nouappnd "${ED}" + chflags -R nosunlnk,nouunlnk "${ED}" 2>/dev/null fi =20 prepallman @@@ -19,7 -17,7 +19,7 @@@ prepallinf =20 prepallstrip =20 - if hasq chflags $FEATURES ; then + if has chflags $FEATURES ; then # Restore all the file flags that were saved at the beginning of prepa= ll. - mtree -U -e -p "${D}" -k flags < "${T}/bsdflags.mtree" &> /dev/null + mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> /dev/null fi diff --cc bin/ebuild-helpers/prepallman index 20880fb,e50de6d..19437dd --- a/bin/ebuild-helpers/prepallman +++ b/bin/ebuild-helpers/prepallman @@@ -1,11 -1,11 +1,11 @@@ -#!/bin/bash +#!@PORTAGE_BASH@ - # Copyright 1999-2010 Gentoo Foundation + # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.s= h +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh =20 # replaced by controllable compression in EAPI 4 - hasq "${EAPI}" 0 1 2 3 || exit 0 + has "${EAPI}" 0 1 2 3 || exit 0 =20 ret=3D0 =20 diff --cc bin/ebuild-helpers/prepinfo index 94e67f0,691fd13..c350fba --- a/bin/ebuild-helpers/prepinfo +++ b/bin/ebuild-helpers/prepinfo @@@ -1,16 -1,16 +1,16 @@@ -#!/bin/bash +#!@PORTAGE_BASH@ - # Copyright 1999-2010 Gentoo Foundation + # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.s= h +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh =20 if [[ -z $1 ]] ; then - infodir=3D"/usr/share/info" + infodir=3D"${EPREFIX}/usr/share/info" else - if [[ -d ${D}$1/share/info ]] ; then - infodir=3D"$1/share/info" + if [[ -d ${ED}$1/share/info ]] ; then + infodir=3D"${EPREFIX}$1/share/info" else - infodir=3D"$1/info" + infodir=3D"${EPREFIX}$1/info" fi fi =20 diff --cc bin/ebuild-helpers/prepman index 231f9ae,c9add8a..f8c670f --- a/bin/ebuild-helpers/prepman +++ b/bin/ebuild-helpers/prepman @@@ -1,13 -1,13 +1,13 @@@ -#!/bin/bash +#!@PORTAGE_BASH@ - # Copyright 1999-2010 Gentoo Foundation + # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.s= h +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh =20 if [[ -z $1 ]] ; then=20 - mandir=3D"${D}usr/share/man" + mandir=3D"${ED}usr/share/man" else - mandir=3D"${D}$1/man" + mandir=3D"${ED}$1/man" fi =20 if [[ ! -d ${mandir} ]] ; then diff --cc bin/ebuild-helpers/prepstrip index 320e332,d25259d..9c5d9da --- a/bin/ebuild-helpers/prepstrip +++ b/bin/ebuild-helpers/prepstrip @@@ -1,8 -1,8 +1,8 @@@ -#!/bin/bash +#!@PORTAGE_BASH@ - # Copyright 1999-2007 Gentoo Foundation + # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.s= h +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh =20 banner=3Dfalse SKIP_STRIP=3Dfalse @@@ -23,9 -23,9 +23,9 @@@ type -P -- ${OBJCOPY} > /dev/null || OB # of the section when it has the ALLOC flag set on it ... export SAFE_STRIP_FLAGS=3D"--strip-unneeded" export PORTAGE_STRIP_FLAGS=3D${PORTAGE_STRIP_FLAGS-${SAFE_STRIP_FLAGS} = -R .comment} -prepstrip_sources_dir=3D/usr/src/debug/${CATEGORY}/${PF} +prepstrip_sources_dir=3D"${EPREFIX}"/usr/src/debug/${CATEGORY}/${PF} =20 - if hasq installsources ${FEATURES} && ! type -P debugedit >/dev/null ; = then + if has installsources ${FEATURES} && ! type -P debugedit >/dev/null ; t= hen ewarn "FEATURES=3Dinstallsources is enabled but the debugedit binary c= ould not" ewarn "be found. This feature will not work unless debugedit is instal= led!" fi @@@ -53,10 -53,10 +53,10 @@@ save_elf_sources()=20 } =20 save_elf_debug() { - hasq splitdebug ${FEATURES} || return 0 + has splitdebug ${FEATURES} || return 0 =20 local x=3D$1 - local y=3D"${D}usr/lib/debug/${x:${#D}}.debug" + local y=3D"${ED}usr/lib/debug/${x:${#D}}.debug" =20 # dont save debug info twice [[ ${x} =3D=3D *".debug" ]] && return 0 diff --cc bin/ebuild.sh index a0b7b15,4aef413..eaf96ea --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@@ -2137,13 -2124,13 +2139,13 @@@ if ! has "$EBUILD_PHASE" clean cleanrm= =20 x=3DLIBDIR_${DEFAULT_ABI} [[ -n $DEFAULT_ABI && -n ${!x} ]] && x=3D${!x} || x=3Dlib =20 - if hasq distcc $FEATURES ; then + if has distcc $FEATURES ; then - PATH=3D"/usr/$x/distcc/bin:$PATH" + PATH=3D"${EPREFIX}/usr/$x/distcc/bin:$PATH" [[ -n $DISTCC_LOG ]] && addwrite "${DISTCC_LOG%/*}" fi =20 - if hasq ccache $FEATURES ; then + if has ccache $FEATURES ; then - PATH=3D"/usr/$x/ccache/bin:$PATH" + PATH=3D"${EPREFIX}/usr/$x/ccache/bin:$PATH" =20 if [[ -n $CCACHE_DIR ]] ; then addread "$CCACHE_DIR" diff --cc bin/filter-bash-environment.py index 126e480,b9aec96..9cb42c1 --- a/bin/filter-bash-environment.py +++ b/bin/filter-bash-environment.py @@@ -1,5 -1,5 +1,5 @@@ -#!/usr/bin/python +#!@PREFIX_PORTAGE_PYTHON@ - # Copyright 1999-2007 Gentoo Foundation + # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 import codecs diff --cc bin/misc-functions.sh index 5b4ff8a,8c191ff..eb2235d mode 100644,100755..100644 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@@ -177,41 -175,7 +177,41 @@@ install_qa_check()=20 sleep 1 done =20 + # anything outside the prefix should be caught by the Prefix QA + # check, so if there's nothing in ED, we skip searching for QA + # checks there, the specific QA funcs can hence rely on ED existing + if [[ -d ${ED} ]] ; then + case ${CHOST} in + *-darwin*) + # Mach-O platforms (NeXT, Darwin, OSX) + install_qa_check_macho + ;; + *-interix*|*-winnt*) + # PECOFF platforms (Windows/Interix) + install_qa_check_pecoff + ;; + *-aix*) + # XCOFF platforms (AIX) + install_qa_check_xcoff + ;; + *) + # because this is the majority: ELF platforms (Linux, + # Solaris, *BSD, IRIX, etc.) + install_qa_check_elf + ;; + esac + fi + + # this is basically here such that the diff with trunk remains just + # offsetted and not out of order + install_qa_check_misc + + # Prefix specific checks + [[ -n ${EPREFIX} ]] && install_qa_check_prefix +} + +install_qa_check_elf() { - if type -P scanelf > /dev/null && ! hasq binchecks ${RESTRICT}; then + if type -P scanelf > /dev/null && ! has binchecks ${RESTRICT}; then local qa_var insecure_rpath=3D0 tmp_quiet=3D${PORTAGE_QUIET} local x =20 @@@ -736,10 -692,10 +736,10 @@@ install_qa_check_misc()=20 fi =20 # Portage regenerates this on the installed system. - rm -f "${D}"/usr/share/info/dir{,.gz,.bz2} + rm -f "${ED}"/usr/share/info/dir{,.gz,.bz2} =20 - if hasq multilib-strict ${FEATURES} && \ + if has multilib-strict ${FEATURES} && \ - [[ -x /usr/bin/file && -x /usr/bin/find ]] && \ + [[ -x ${EPREFIX}/usr/bin/file && -x ${EPREFIX}/usr/bin/find ]] && \ [[ -n ${MULTILIB_STRICT_DIRS} && -n ${MULTILIB_STRICT_DENY} ]] then local abort=3Dno dir file firstrun=3Dyes @@@ -771,490 -727,6 +771,490 @@@ fi } =20 +install_qa_check_prefix() { + if [[ -d ${ED}/${D} ]] ; then + find "${ED}/${D}" | \ + while read i ; do + eqawarn "QA Notice: /${i##${ED}/${D}} installed in \${ED}/\${D}" + done + die "Aborting due to QA concerns: files installed in ${ED}/${D}" + fi + + if [[ -d ${ED}/${EPREFIX} ]] ; then + find "${ED}/${EPREFIX}/" | \ + while read i ; do + eqawarn "QA Notice: ${i#${D}} double prefix" + done + die "Aborting due to QA concerns: double prefix files installed" + fi + + if [[ -d ${D} ]] ; then + INSTALLTOD=3D$(find ${D%/} | egrep -v "^${ED}" | sed -e "s|^${D%/}||"= | awk '{if (length($0) <=3D length("'"${EPREFIX}"'")) { if (substr("'"${= EPREFIX}"'", 1, length($0)) !=3D $0) {print $0;} } else if (substr($0, 1,= length("'"${EPREFIX}"'")) !=3D "'"${EPREFIX}"'") {print $0;} }')=20 + if [[ -n ${INSTALLTOD} ]] ; then + eqawarn "QA Notice: the following files are outside of the prefix:" + eqawarn "${INSTALLTOD}" + die "Aborting due to QA concerns: there are files installed outside = the prefix" + fi + fi + + # all further checks rely on ${ED} existing + [[ -d ${ED} ]] || return + + # this does not really belong here, but it's closely tied to + # the code below; many runscripts generate positives here, and we + # know they don't work (bug #196294) so as long as that one + # remains an issue, simply remove them as they won't work + # anyway, avoid etc/init.d/functions.sh from being thrown away + if [[ ( -d "${ED}"/etc/conf.d || -d "${ED}"/etc/init.d ) && ! -f "${ED= }"/etc/init.d/functions.sh ]] ; then + ewarn "removed /etc/init.d and /etc/conf.d directories until bug #196= 294 has been resolved" + rm -Rf "${ED}"/etc/{conf,init}.d + fi + + # check shebangs, bug #282539 + rm -f "${T}"/non-prefix-shebangs-errs + local WHITELIST=3D" /usr/bin/env " + # this is hell expensive, but how else? + find "${ED}" -executable \! -type d -print0 \ + | xargs -0 grep -H -n -m1 "^#!" \ + | while read f ; + do + local fn=3D${f%%:*} + local pos=3D${f#*:} ; pos=3D${pos%:*} + local line=3D${f##*:} + # shebang always appears on the first line ;) + [[ ${pos} !=3D 1 ]] && continue + local oldIFS=3D${IFS} + IFS=3D$'\r'$'\n'$'\t'" " + line=3D( ${line#"#!"} ) + IFS=3D${oldIFS} + [[ ${WHITELIST} =3D=3D *" ${line[0]} "* ]] && continue + local fp=3D${fn#${D}} ; fp=3D/${fp%/*} + # line[0] can be an absolutised path, bug #342929 + local eprefix=3D$(canonicalize ${EPREFIX}) + local rf=3D${fn} + # in case we deal with a symlink, make sure we don't replace it + # with a real file (sed -i does that) + if [[ -L ${fn} ]] ; then + rf=3D$(readlink ${fn}) + [[ ${rf} !=3D /* ]] && rf=3D${fn%/*}/${rf} + # ignore symlinks pointing to outside prefix + # as seen in sys-devel/native-cctools + [[ ${rf} !=3D ${EPREFIX}/* && $(canonicalize "${rf}") !=3D ${eprefix= }/* ]] && continue + fi + # does the shebang start with ${EPREFIX}, and does it exist? + if [[ ${line[0]} =3D=3D ${EPREFIX}/* || ${line[0]} =3D=3D ${eprefix}/= * ]] ; then + if [[ ! -e ${ROOT%/}${line[0]} && ! -e ${D%/}${line[0]} ]] ; then + # hmm, refers explicitly to $EPREFIX, but doesn't exist, + # if it's in PATH that's wrong in any case + if [[ ":${PATH}:" =3D=3D *":${fp}:"* ]] ; then + echo "${fn#${D}}:${line[0]} (explicit EPREFIX but target not found= )" \ + >> "${T}"/non-prefix-shebangs-errs + else + eqawarn "${fn#${D}} has explicit EPREFIX in shebang but target not= found (${line[0]})" + fi + fi + continue + fi + # unprefixed shebang, is the script directly in $PATH? + if [[ ":${PATH}:" =3D=3D *":${fp}:"* ]] ; then + if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then + # is it unprefixed, but we can just fix it because a + # prefixed variant exists + eqawarn "prefixing shebang of ${fn#${D}}" + # statement is made idempotent on purpose, because + # symlinks may point to the same target, and hence the + # same real file may be sedded multiple times since we + # read the shebangs in one go upfront for performance + # reasons + sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${= rf}" + continue + else + # this is definitely wrong: script in $PATH and invalid shebang + echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but= interpreter ${line[0]} not found)" \ + >> "${T}"/non-prefix-shebangs-errs + fi + else + # unprefixed/invalid shebang, but outside $PATH, this may be + # intended (e.g. config.guess) so remain silent by default - hasq stricter ${FEATURES} && \ ++ has stricter ${FEATURES} && \ + eqawarn "invalid shebang in ${fn#${D}}: ${line[0]}" + fi + done + if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then + eqawarn "QA Notice: the following files use invalid (possible non-pre= fixed) shebangs:" + while read line ; do + eqawarn " ${line}" + done < "${T}"/non-prefix-shebangs-errs + rm -f "${T}"/non-prefix-shebangs-errs + die "Aborting due to QA concerns: invalid shebangs found" + fi +} + +install_qa_check_macho() { - if ! hasq binchecks ${RESTRICT} ; then ++ if ! has binchecks ${RESTRICT} ; then + # on Darwin, dynamic libraries are called .dylibs instead of + # .sos. In addition the version component is before the + # extension, not after it. Check for this, and *only* warn + # about it. Some packages do ship .so files on Darwin and make + # it work (ugly!). + rm -f "${T}/mach-o.check" + find ${ED%/} -name "*.so" -or -name "*.so.*" | \ + while read i ; do + [[ $(file $i) =3D=3D *"Mach-O"* ]] && \ + echo "${i#${D}}" >> "${T}/mach-o.check" + done + if [[ -f ${T}/mach-o.check ]] ; then + f=3D$(< "${T}/mach-o.check") + vecho -ne '\a\n' + eqawarn "QA Notice: Found .so dynamic libraries on Darwin:" + eqawarn " ${f//$'\n'/\n }" + fi + rm -f "${T}/mach-o.check" + + # The naming for dynamic libraries is different on Darwin; the + # version component is before the extention, instead of after + # it, as with .sos. Again, make this a warning only. + rm -f "${T}/mach-o.check" + find ${ED%/} -name "*.dylib.*" | \ + while read i ; do + echo "${i#${D}}" >> "${T}/mach-o.check" + done + if [[ -f "${T}/mach-o.check" ]] ; then + f=3D$(< "${T}/mach-o.check") + vecho -ne '\a\n' + eqawarn "QA Notice: Found wrongly named dynamic libraries on Darwin:= " + eqawarn " ${f// /\n }" + fi + rm -f "${T}/mach-o.check" + fi + + # While we generate the NEEDED files, check that we don't get kernel + # traps at runtime because of broken install_names on Darwin. + rm -f "${T}"/.install_name_check_failed + scanmacho -qyRF '%a;%p;%S;%n' "${D}" | { while IFS=3D read l ; do + arch=3D${l%%;*}; l=3D${l#*;} + obj=3D"/${l%%;*}"; l=3D${l#*;} + install_name=3D${l%%;*}; l=3D${l#*;} + needed=3D${l%%;*}; l=3D${l#*;} + + # See if the self-reference install_name points to an existing + # and to be installed file. This usually is a symlink for the + # major version. + if [[ ! -e ${D}${install_name} ]] ; then + eqawarn "QA Notice: invalid self-reference install_name ${install_na= me} in ${obj}" + # remember we are in an implicit subshell, that's + # why we touch a file here ... ideally we should be + # able to die correctly/nicely here + touch "${T}"/.install_name_check_failed + fi + + # this is ugly, paths with spaces won't work + reevaluate=3D0 + for lib in ${needed//,/ } ; do + if [[ ${lib} =3D=3D ${D}* ]] ; then + eqawarn "QA Notice: install_name references \${D}: ${lib} in ${obj}= " + touch "${T}"/.install_name_check_failed + elif [[ ${lib} =3D=3D ${S}* ]] ; then + eqawarn "QA Notice: install_name references \${S}: ${lib} in ${obj}= " + touch "${T}"/.install_name_check_failed + elif [[ ! -e ${lib} && ! -e ${D}${lib} && ${lib} !=3D "@executable_p= ath/"* && ${lib} !=3D "@loader_path/"* ]] ; then + # try to "repair" this if possible, happens because of + # gen_usr_ldscript tactics + s=3D${lib%usr/*}${lib##*/usr/} + if [[ -e ${D}${s} ]] ; then + ewarn "correcting install_name from ${lib} to ${s} in ${obj}" + install_name_tool -change \ + "${lib}" "${s}" "${D}${obj}" + reevaluate=3D1 + else + eqawarn "QA Notice: invalid reference to ${lib} in ${obj}" + # remember we are in an implicit subshell, that's + # why we touch a file here ... ideally we should be + # able to die correctly/nicely here + touch "${T}"/.install_name_check_failed + fi + fi + done + if [[ ${reevaluate} =3D=3D 1 ]]; then + # install_name(s) have been changed, refresh data so we + # store the correct meta data + l=3D$(scanmacho -qyF '%a;%p;%S;%n' ${D}${obj}) + arch=3D${l%%;*}; l=3D${l#*;} + obj=3D"/${l%%;*}"; l=3D${l#*;} + install_name=3D${l%%;*}; l=3D${l#*;} + needed=3D${l%%;*}; l=3D${l#*;} + fi + + # backwards compatability + echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED + # what we use + echo "${arch};${obj};${install_name};${needed}" >> "${PORTAGE_BUILDDI= R}"/build-info/NEEDED.MACHO.3 + done } + if [[ -f ${T}/.install_name_check_failed ]] ; then + # secret switch "allow_broken_install_names" to get + # around this and install broken crap (not a good idea) - hasq allow_broken_install_names ${FEATURES} || \ ++ has allow_broken_install_names ${FEATURES} || \ + die "invalid install_name found, your application or library will cr= ash at runtime" + fi +} + +install_qa_check_pecoff() { + local _pfx_scan=3D"readpecoff ${CHOST}" + + # this one uses readpecoff, which supports multiple prefix platforms! + # this is absolutely _not_ optimized for speed, and there may be plent= y + # of possibilities by introducing one or the other cache! - if ! hasq binchecks ${RESTRICT}; then ++ if ! has binchecks ${RESTRICT}; then + # copied and adapted from the above scanelf code. + local qa_var insecure_rpath=3D0 tmp_quiet=3D${PORTAGE_QUIET} + local f x + + # display warnings when using stricter because we die afterwards + if has stricter ${FEATURES} ; then + unset PORTAGE_QUIET + fi + + local _exec_find_opt=3D"-executable" + [[ ${CHOST} =3D=3D *-winnt* ]] && _exec_find_opt=3D'-name *.dll -o -n= ame *.exe' + + # Make sure we disallow insecure RUNPATH/RPATH's + # Don't want paths that point to the tree where the package was built + # (older, broken libtools would do this). Also check for null paths + # because the loader will search $PWD when it finds null paths. + + f=3D$( + find "${ED}" -type f '(' ${_exec_find_opt} ')' -print0 | xargs -0 ${= _pfx_scan} | \ + while IFS=3D";" read arch obj soname rpath needed ; do \ + echo "${rpath}" | grep -E "(${PORTAGE_BUILDDIR}|: |::|^:|^ )" > /dev= /null 2>&1 \ + && echo "${obj}"; done; + ) + # Reject set*id binaries with $ORIGIN in RPATH #260331 + x=3D$( + find "${ED}" -type f '(' -perm -u+s -o -perm -g+s ')' -print0 | \ + xargs -0 ${_pfx_scan} | while IFS=3D";" read arch obj soname rpath n= eeded; do \ + echo "${rpath}" | grep '$ORIGIN' > /dev/null 2>&1 && echo "${obj}"; = done; + ) + if [[ -n ${f}${x} ]] ; then + vecho -ne '\a\n' + eqawarn "QA Notice: The following files contain insecure RUNPATH's" + eqawarn " Please file a bug about this at http://bugs.gentoo.org/" + eqawarn " with the maintaining herd of the package." + eqawarn "${f}${f:+${x:+\n}}${x}" + vecho -ne '\a\n' + if [[ -n ${x} ]] || has stricter ${FEATURES} ; then + insecure_rpath=3D1 + else + eqawarn "cannot automatically fix runpaths on interix platforms!" + fi + fi + + rm -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED + rm -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED.PECOFF.1 + + # Save NEEDED information after removing self-contained providers + find "${ED}" -type f '(' ${_exec_find_opt} ')' -print0 | xargs -0 ${_= pfx_scan} | { while IFS=3D';' read arch obj soname rpath needed; do + # need to strip image dir from object name. + obj=3D"/${obj#${D}}" + if [ -z "${rpath}" -o -n "${rpath//*ORIGIN*}" ]; then + # object doesn't contain $ORIGIN in its runpath attribute + echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED + echo "${arch};${obj};${soname};${rpath};${needed}" >> "${PORTAGE_BU= ILDDIR}"/build-info/NEEDED.PECOFF.1 + else + dir=3D${obj%/*} + # replace $ORIGIN with the dirname of the current object for the lo= okup + opath=3D$(echo :${rpath}: | sed -e "s#.*:\(.*\)\$ORIGIN\(.*\):.*#\1= ${dir}\2#") + sneeded=3D$(echo ${needed} | tr , ' ') + rneeded=3D"" + for lib in ${sneeded}; do + found=3D0 + for path in ${opath//:/ }; do + [ -e "${ED}/${path}/${lib}" ] && found=3D1 && break + done + [ "${found}" -eq 0 ] && rneeded=3D"${rneeded},${lib}" + done + rneeded=3D${rneeded:1} + if [ -n "${rneeded}" ]; then + echo "${obj} ${rneeded}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDE= D + echo "${arch};${obj};${soname};${rpath};${rneeded}" >> "${PORTAGE_= BUILDDIR}"/build-info/NEEDED.PECOFF.1 + fi + fi + done } + =09 + if [[ ${insecure_rpath} -eq 1 ]] ; then + die "Aborting due to serious QA concerns with RUNPATH/RPATH" + elif [[ -n ${die_msg} ]] && has stricter ${FEATURES} ; then + die "Aborting due to QA concerns: ${die_msg}" + fi + + local _so_ext=3D'.so*' + + case "${CHOST}" in + *-winnt*) _so_ext=3D".dll" ;; # no "*" intentionally! + esac + + # Run some sanity checks on shared libraries + for d in "${ED}"lib* "${ED}"usr/lib* ; do + [[ -d "${d}" ]] || continue + f=3D$(find "${d}" -name "lib*${_so_ext}" -print0 | \ + xargs -0 ${_pfx_scan} | while IFS=3D";" read arch obj soname rpath = needed; \ + do [[ -z "${soname}" ]] && echo "${obj}"; done) + if [[ -n ${f} ]] ; then + vecho -ne '\a\n' + eqawarn "QA Notice: The following shared libraries lack a SONAME" + eqawarn "${f}" + vecho -ne '\a\n' + sleep 1 + fi + + f=3D$(find "${d}" -name "lib*${_so_ext}" -print0 | \ + xargs -0 ${_pfx_scan} | while IFS=3D";" read arch obj soname rpath = needed; \ + do [[ -z "${needed}" ]] && echo "${obj}"; done) + if [[ -n ${f} ]] ; then + vecho -ne '\a\n' + eqawarn "QA Notice: The following shared libraries lack NEEDED entr= ies" + eqawarn "${f}" + vecho -ne '\a\n' + sleep 1 + fi + done + + PORTAGE_QUIET=3D${tmp_quiet} + fi +} + +install_qa_check_xcoff() { - if ! hasq binchecks ${RESTRICT}; then ++ if ! has binchecks ${RESTRICT}; then + local tmp_quiet=3D${PORTAGE_QUIET} + local queryline deplib + local insecure_rpath_list=3D undefined_symbols_list=3D + + # display warnings when using stricter because we die afterwards + if has stricter ${FEATURES} ; then + unset PORTAGE_QUIET + fi + + rm -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1 + + local neededfd + for neededfd in {3..1024} none; do ( : <&${neededfd} ) 2>/dev/null ||= break; done + [[ ${neededfd} !=3D none ]] || die "cannot find free file descriptor = handle" + + eval "exec ${neededfd}>\"${PORTAGE_BUILDDIR}\"/build-info/NEEDED.XCOF= F.1" || die "cannot open ${PORTAGE_BUILDDIR}/build-info/NEEDED.XCOFF.1" + + ( # work around a problem in /usr/bin/dump (used by aixdll-query) + # dumping core when path names get too long. + cd "${ED}" >/dev/null && + find . -not -type d -exec \ + aixdll-query '{}' FILE MEMBER FLAGS FORMAT RUNPATH DEPLIBS ';' + ) > "${T}"/needed 2>/dev/null + + # Symlinking shared archive libraries is not a good idea on aix, + # as there is nothing like "soname" on pure filesystem level. + # So we create a copy instead of the symlink. + local prev_FILE=3D + local FILE MEMBER FLAGS FORMAT RUNPATH DEPLIBS + while read queryline + do + FILE=3D MEMBER=3D FLAGS=3D FORMAT=3D RUNPATH=3D DEPLIBS=3D + eval ${queryline} + FILE=3D${FILE#./} + + if [[ ${prev_FILE} !=3D ${FILE} ]]; then + if [[ " ${FLAGS} " =3D=3D *" SHROBJ "* && -h ${ED}${FILE} ]]; then + prev_FILE=3D${FILE} + local target=3D$(readlink "${ED}${FILE}") + if [[ ${target} =3D=3D /* ]]; then + target=3D${D}${target} + else + target=3D${FILE%/*}/${target} + fi + rm -f "${ED}${FILE}" || die "cannot prune ${FILE}" + cp -f "${ED}${target}" "${ED}${FILE}" || die "cannot copy ${target= } to ${FILE}" + fi + fi + done <"${T}"/needed + + prev_FILE=3D + while read queryline + do + FILE=3D MEMBER=3D FLAGS=3D FORMAT=3D RUNPATH=3D DEPLIBS=3D + eval ${queryline} + FILE=3D${FILE#./} + + if [[ -n ${MEMBER} && ${prev_FILE} !=3D ${FILE} ]]; then + # Save NEEDED information for each archive library stub + # even if it is static only: the already installed archive + # may contain shared objects to be preserved. + echo "${FORMAT##* }${FORMAT%%-*};${EPREFIX}/${FILE};${FILE##*/};;" = >&${neededfd} + fi + prev_FILE=3D${FILE} + + # shared objects have both EXEC and SHROBJ flags, + # while executables have EXEC flag only. + [[ " ${FLAGS} " =3D=3D *" EXEC "* ]] || continue + + # Make sure we disallow insecure RUNPATH's + # Don't want paths that point to the tree where the package was buil= t + # (older, broken libtools would do this). Also check for null paths + # because the loader will search $PWD when it finds null paths. + # And we really want absolute paths only. + if [[ -n $(echo ":${RUNPATH}:" | grep -E "(${PORTAGE_BUILDDIR}|::|:[= ^/])") ]]; then + insecure_rpath_list=3D"${insecure_rpath_list}\n${FILE}${MEMBER:+[${= MEMBER}]}" + fi + + local needed=3D + [[ -n ${MEMBER} ]] && needed=3D${FILE##*/} + for deplib in ${DEPLIBS}; do + eval deplib=3D${deplib} + if [[ ${deplib} =3D=3D '.' || ${deplib} =3D=3D '..' ]]; then + # Although we do have runtime linking, we don't want undefined sym= bols. + # AIX does indicate this by needing either '.' or '..' + undefined_symbols_list=3D"${undefined_symbols_list}\n${FILE}" + else + needed=3D"${needed}${needed:+,}${deplib}" + fi + done + + FILE=3D${EPREFIX}/${FILE} + + [[ -n ${MEMBER} ]] && MEMBER=3D"[${MEMBER}]" + # Save NEEDED information + echo "${FORMAT##* }${FORMAT%%-*};${FILE}${MEMBER};${FILE##*/}${MEMBE= R};${RUNPATH};${needed}" >&${neededfd} + done <"${T}"/needed + + eval "exec ${neededfd}>&-" || die "cannot close handle to ${PORTAGE_B= UILDDIR}/build-info/NEEDED.XCOFF.1" + + if [[ -n ${undefined_symbols_list} ]]; then + vecho -ne '\a\n' + eqawarn "QA Notice: The following files contain undefined symbols." + eqawarn " Please file a bug about this at http://bugs.gentoo.org/" + eqawarn " with 'prefix' as the maintaining herd of the package." + eqawarn "${undefined_symbols_list}" + vecho -ne '\a\n' + fi + + if [[ -n ${insecure_rpath_list} ]] ; then + vecho -ne '\a\n' + eqawarn "QA Notice: The following files contain insecure RUNPATH's" + eqawarn " Please file a bug about this at http://bugs.gentoo.org/" + eqawarn " with 'prefix' as the maintaining herd of the package." + eqawarn "${insecure_rpath_list}" + vecho -ne '\a\n' + if has stricter ${FEATURES} ; then + insecure_rpath=3D1 + fi + fi + + if [[ ${insecure_rpath} -eq 1 ]] ; then + die "Aborting due to serious QA concerns with RUNPATH/RPATH" + elif [[ -n ${die_msg} ]] && has stricter ${FEATURES} ; then + die "Aborting due to QA concerns: ${die_msg}" + fi + + PORTAGE_QUIET=3D${tmp_quiet} + fi +} + =20 install_mask() { local root=3D"$1" @@@ -1280,204 -752,6 +1280,204 @@@ set -${shopts} } =20 +preinst_aix() { - if [[ ${CHOST} !=3D *-aix* ]] || hasq binchecks ${RESTRICT}; then ++ if [[ ${CHOST} !=3D *-aix* ]] || has binchecks ${RESTRICT}; then + return 0 + fi + local ar strip + if type ${CHOST}-ar >/dev/null 2>&1 && type ${CHOST}-strip >/dev/null = 2>&1; then + ar=3D${CHOST}-ar + strip=3D${CHOST}-strip + elif [[ ${CBUILD} =3D=3D "${CHOST}" ]] && type ar >/dev/null 2>&1 && t= ype strip >/dev/null 2>&1; then + ar=3Dar + strip=3Dstrip + elif [[ -x /usr/ccs/bin/ar && -x /usr/ccs/bin/strip ]]; then + ar=3D/usr/ccs/bin/ar + strip=3D/usr/ccs/bin/strip + else + die "cannot find where to use 'ar' and 'strip' from" + fi + local archives_members=3D archives=3D() chmod400files=3D() + local archive_member soname runpath needed archive contentmember + while read archive_member; do + archive_member=3D${archive_member#*;${EPREFIX}/} # drop "^type;EPREFI= X/" + soname=3D${archive_member#*;} + runpath=3D${soname#*;} + needed=3D${runpath#*;} + soname=3D${soname%%;*} + runpath=3D${runpath%%;*} + archive_member=3D${archive_member%%;*} # drop ";soname;runpath;needed= $" + archive=3D${archive_member%[*} + if [[ ${archive_member} !=3D *'['*']' ]]; then + if [[ "${soname};${runpath};${needed}" =3D=3D "${archive##*/};;" && = -e ${EROOT}${archive} ]]; then + # most likely is an archive stub that already exists, + # may have to preserve members being a shared object. + archives[${#archives[@]}]=3D${archive} + fi + continue + fi + archives_members=3D"${archives_members}:(${archive_member}):" + contentmember=3D"${archive%/*}/.${archive##*/}${archive_member#${arch= ive}}" + # portage does os.lstat() on merged files every now + # and then, so keep stamp-files for archive members + # around to get the preserve-libs feature working. + { echo "Please leave this file alone, it is an important helper" + echo "for portage to implement the 'preserve-libs' feature on AIX."=20 + } > "${ED}${contentmember}" || die "cannot create ${contentmember}" + chmod400files[${#chmod400files[@]}]=3D${ED}${contentmember} + done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1 + [[ ${#chmod400files[@]} =3D=3D 0 ]] || + chmod 0400 "${chmod400files[@]}" || die "cannot chmod ${chmod400files[= @]}" + + local preservemembers libmetadir prunedirs=3D() + local FILE MEMBER FLAGS + for archive in "${archives[@]}"; do + preservemembers=3D + while read line; do + [[ -n ${line} ]] || continue + FILE=3D MEMBER=3D FLAGS=3D + eval ${line} + [[ ${FILE} =3D=3D ${EROOT}${archive} ]] || + die "invalid result of aixdll-query for ${EROOT}${archive}" + [[ -n ${MEMBER} && " ${FLAGS} " =3D=3D *" SHROBJ "* ]] || continue + [[ ${archives_members} =3D=3D *":(${archive}[${MEMBER}]):"* ]] && co= ntinue + preservemembers=3D"${preservemembers} ${MEMBER}" + done <<-EOF + $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS) + EOF + [[ -n ${preservemembers} ]] || continue + einfo "preserving (on spec) ${archive}[${preservemembers# }]" + libmetadir=3D${ED}${archive%/*}/.${archive##*/} + mkdir "${libmetadir}" || die "cannot create ${libmetadir}" + pushd "${libmetadir}" >/dev/null || die "cannot cd to ${libmetadir}" + ${ar} -X32_64 -x "${EROOT}${archive}" ${preservemembers} || die "cann= ot unpack ${EROOT}${archive}" + chmod u+w ${preservemembers} || die "cannot chmod${preservemembers}" + ${strip} -X32_64 -e ${preservemembers} || die "cannot strip${preserve= members}" + ${ar} -X32_64 -q "${ED}${archive}" ${preservemembers} || die "cannot = update ${archive}" + eend $? + popd >/dev/null || die "cannot leave ${libmetadir}" + prunedirs[${#prunedirs[@]}]=3D${libmetadir} + done + [[ ${#prunedirs[@]} =3D=3D 0 ]] || + rm -rf "${prunedirs[@]}" || die "cannot prune ${prunedirs[@]}" + return 0 +} + +postinst_aix() { - if [[ ${CHOST} !=3D *-aix* ]] || hasq binchecks ${RESTRICT}; then ++ if [[ ${CHOST} !=3D *-aix* ]] || has binchecks ${RESTRICT}; then + return 0 + fi + local MY_PR=3D${PR%r0} + local ar strip + if type ${CHOST}-ar >/dev/null 2>&1 && type ${CHOST}-strip >/dev/null = 2>&1; then + ar=3D${CHOST}-ar + strip=3D${CHOST}-strip + elif [[ ${CBUILD} =3D=3D "${CHOST}" ]] && type ar >/dev/null 2>&1 && t= ype strip >/dev/null 2>&1; then + ar=3Dar + strip=3Dstrip + elif [[ -x /usr/ccs/bin/ar && -x /usr/ccs/bin/strip ]]; then + ar=3D/usr/ccs/bin/ar + strip=3D/usr/ccs/bin/strip + else + die "cannot find where to use 'ar' and 'strip' from" + fi + local archives_members=3D archives=3D() activearchives=3D + local archive_member soname runpath needed + while read archive_member; do + archive_member=3D${archive_member#*;${EPREFIX}/} # drop "^type;EPREFI= X/" + soname=3D${archive_member#*;} + runpath=3D${soname#*;} + needed=3D${runpath#*;} + soname=3D${soname%%;*} + runpath=3D${runpath%%;*} + archive_member=3D${archive_member%%;*} # drop ";soname;runpath;needed= $" + [[ ${archive_member} =3D=3D *'['*']' ]] && continue + [[ "${soname};${runpath};${needed}" =3D=3D "${archive_member##*/};;" = ]] || continue + # most likely is an archive stub, we might have to + # drop members being preserved shared objects. + archives[${#archives[@]}]=3D${archive_member} + activearchives=3D"${activearchives}:(${archive_member}):" + done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1 + + local type allcontentmembers=3D oldarchives=3D() + local contentmember + while read type contentmember; do + [[ ${type} =3D=3D 'obj' ]] || continue + contentmember=3D${contentmember% *} # drop " timestamp$" + contentmember=3D${contentmember% *} # drop " hash$" + [[ ${contentmember##*/} =3D=3D *'['*']' ]] || continue + contentmember=3D${contentmember#${EPREFIX}/} + allcontentmembers=3D"${allcontentmembers}:(${contentmember}):" + contentmember=3D${contentmember%[*} + contentmember=3D${contentmember%/.*}/${contentmember##*/.} + [[ ${activearchives} =3D=3D *":(${contentmember}):"* ]] && continue + oldarchives[${#oldarchives[@]}]=3D${contentmember} + done < "${EPREFIX}/var/db/pkg/${CATEGORY}/${P}${MY_PR:+-}${MY_PR}/CONT= ENTS" + + local archive line delmembers + local FILE MEMBER FLAGS + for archive in "${archives[@]}"; do + [[ -r ${EROOT}${archive} && -w ${EROOT}${archive} ]] || + chmod a+r,u+w "${EROOT}${archive}" || die "cannot chmod ${EROOT}${arc= hive}" + delmembers=3D + while read line; do + [[ -n ${line} ]] || continue + FILE=3D MEMBER=3D FLAGS=3D + eval ${line} + [[ ${FILE} =3D=3D "${EROOT}${archive}" ]] || + die "invalid result '${FILE}' of aixdll-query, expected '${EROOT}${a= rchive}'" + [[ -n ${MEMBER} && " ${FLAGS} " =3D=3D *" SHROBJ "* ]] || continue + [[ ${allcontentmembers} =3D=3D *":(${archive%/*}/.${archive##*/}[${M= EMBER}]):"* ]] && continue + delmembers=3D"${delmembers} ${MEMBER}" + done <<-EOF + $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS) + EOF + [[ -n ${delmembers} ]] || continue + einfo "dropping ${archive}[${delmembers# }]" + rm -f "${EROOT}${archive}".new || die "cannot prune ${EROOT}${archive= }.new" + cp "${EROOT}${archive}" "${EROOT}${archive}".new || die "cannot backu= p ${archive}" + ${ar} -X32_64 -z -o -d "${EROOT}${archive}".new ${delmembers} || die = "cannot remove${delmembers} from ${archive}.new" + mv -f "${EROOT}${archive}".new "${EROOT}${archive}" || die "cannot pu= t ${EROOT}${archive} in place" + eend $? + done + local libmetadir keepmembers prunedirs=3D() + for archive in "${oldarchives[@]}"; do + [[ -r ${EROOT}${archive} && -w ${EROOT}${archive} ]] || + chmod a+r,u+w "${EROOT}${archive}" || die "cannot chmod ${EROOT}${arc= hive}" + keepmembers=3D + while read line; do + FILE=3D MEMBER=3D FLAGS=3D + eval ${line} + [[ ${FILE} =3D=3D "${EROOT}${archive}" ]] || + die "invalid result of aixdll-query for ${EROOT}${archive}" + [[ -n ${MEMBER} && " ${FLAGS} " =3D=3D *" SHROBJ "* ]] || continue + [[ ${allcontentmembers} =3D=3D *":(${archive%/*}/.${archive##*/}[${M= EMBER}]):"* ]] || continue + keepmembers=3D"${keepmembers} ${MEMBER}" + done <<-EOF + $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS) + EOF + + if [[ -n ${keepmembers} ]]; then + einfo "preserving (extra)${keepmembers}" + libmetadir=3D${EROOT}${archive%/*}/.${archive##*/} + [[ ! -e ${libmetadir} ]] || rm -rf "${libmetadir}" || die "cannot pr= une ${libmetadir}" + mkdir "${libmetadir}" || die "cannot create ${libmetadir}" + pushd "${libmetadir}" >/dev/null || die "cannot cd to ${libmetadir}" + ${ar} -X32_64 -x "${EROOT}${archive}" ${keepmembers} || die "cannot = unpack ${archive}" + ${strip} -X32_64 -e ${keepmembers} || die "cannot strip ${keepmember= s}" + rm -f "${EROOT}${archive}.new" || die "cannot prune ${EROOT}${archiv= e}.new" + ${ar} -X32_64 -q "${EROOT}${archive}.new" ${keepmembers} || die "can= not create ${EROOT}${archive}.new" + mv -f "${EROOT}${archive}.new" "${EROOT}${archive}" || die "cannot p= ut ${EROOT}${archive} in place" + popd > /dev/null || die "cannot leave ${libmetadir}" + prunedirs[${#prunedirs[@]}]=3D${libmetadir} + eend $? + fi + done + [[ ${#prunedirs[@]} =3D=3D 0 ]] || + rm -rf "${prunedirs[@]}" || die "cannot prune ${prunedirs[@]}" + return 0 +} + preinst_mask() { if [ -z "${D}" ]; then eerror "${FUNCNAME}: D is unset" @@@ -1491,8 -765,8 +1491,8 @@@ # remove man pages, info pages, docs if requested local f for f in man info doc; do - if hasq no${f} $FEATURES; then + if has no${f} $FEATURES; then - INSTALL_MASK=3D"${INSTALL_MASK} /usr/share/${f}" + INSTALL_MASK=3D"${INSTALL_MASK} ${EPREFIX}/usr/share/${f}" fi done =20 @@@ -1545,9 -819,9 +1545,9 @@@ preinst_suid_scan()=20 return 1 fi # total suid control. - if hasq suidctl $FEATURES; then + if has suidctl $FEATURES; then local i sfconf x - sfconf=3D${PORTAGE_CONFIGROOT}etc/portage/suidctl.conf + sfconf=3D${PORTAGE_CONFIGROOT}${EPREFIX#/}/etc/portage/suidctl.conf # sandbox prevents us from writing directly # to files outside of the sandbox, but this # can easly be bypassed using the addwrite() function diff --cc pym/_emerge/Binpkg.py index eded78b,bc6511e..6c944e2 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@@ -15,17 -14,11 +15,12 @@@ from portage.util import writems import portage from portage import os from portage import _encodings + from portage import _unicode_decode from portage import _unicode_encode - import codecs - import sys - if os.environ.__contains__("PORTAGE_PYTHONPATH"): - sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"]) - else: - sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.pat= h.realpath(__file__))), "pym")) - import portage + import io import logging from portage.output import colorize +from portage.const import EPREFIX =20 class Binpkg(CompositeTask): =20 diff --cc pym/_emerge/actions.py index 24dd4d7,f6c2721..049b10f --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@@ -25,10 -21,10 +21,10 @@@ from itertools import chai =20 import portage from portage import os - from portage import digraph + from portage import subprocess_getstatusoutput from portage import _unicode_decode from portage.cache.cache_errors import CacheError -from portage.const import GLOBAL_CONFIG_PATH, NEWS_LIB_PATH +from portage.const import GLOBAL_CONFIG_PATH, NEWS_LIB_PATH, EPREFIX from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_SET_CONFIG from portage.dbapi.dep_expand import dep_expand from portage.dbapi._expand_new_virt import expand_new_virt diff --cc pym/_emerge/emergelog.py index 20cec9f,d6ef1b4..629dae8 --- a/pym/_emerge/emergelog.py +++ b/pym/_emerge/emergelog.py @@@ -18,8 -18,12 +19,12 @@@ from portage.const import EPREFI # dblink.merge() and we don't want that to trigger log writes # unless it's really called via emerge. _disable =3D True -_emerge_log_dir =3D '/var/log' +_emerge_log_dir =3D EPREFIX + '/var/log' =20 + # Coerce to unicode, in order to prevent TypeError when writing + # raw bytes to TextIOWrapper with python2. + _log_fmt =3D _unicode_decode("%.0f: %s\n") +=20 def emergelog(xterm_titles, mystr, short_msg=3DNone): =20 if _disable: diff --cc pym/_emerge/main.py index 7a9fa9c,42ce810..b97e72b --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@@ -163,7 -158,9 +159,9 @@@ def chk_updated_info_files(root, infodi raise del e processed_count +=3D 1 - myso=3Dsubprocess_getstatusoutput("LANG=3DC LANGUAGE=3DC "+EPREFIX= +"/usr/bin/install-info --dir-file=3D"+inforoot+"/dir "+inforoot+"/"+x)[1= ] + myso =3D portage.subprocess_getstatusoutput( - "LANG=3DC LANGUAGE=3DC /usr/bin/install-info " + - "--dir-file=3D%s/dir %s/%s" % (inforoot, inforoot, x))[1] ++ "LANG=3DC LANGUAGE=3DC %s/usr/bin/install-info " + ++ "--dir-file=3D%s/dir %s/%s" % (EPREFIX, inforoot, inforoot, x))[1= ] existsstr=3D"already exists, for file `" if myso!=3D"": if re.search(existsstr,myso): diff --cc pym/portage/dbapi/vartree.py index 3ed96e9,9efc47f..e57df13 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@@ -37,10 -34,9 +37,9 @@@ portage.proxy.lazyimport.lazyimport(glo ) =20 from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, \ - PORTAGE_PACKAGE_ATOM, PRIVATE_PATH, VDB_PATH + PORTAGE_PACKAGE_ATOM, PRIVATE_PATH, VDB_PATH, EPREFIX, EPREFIX_LSTRIP,= BASH_BINARY from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_PRESERVE_LIBS from portage.dbapi import dbapi - from portage.dep import _slot_separator from portage.exception import CommandNotFound, \ InvalidData, InvalidLocation, InvalidPackageName, \ FileNotFound, PermissionDenied, UnsupportedAPIException diff --cc pym/portage/elog/mod_save.py index f6a577e,9350a6e..d1c9bb8 --- a/pym/portage/elog/mod_save.py +++ b/pym/portage/elog/mod_save.py @@@ -8,18 -8,24 +8,25 @@@ from portage import o from portage import _encodings from portage import _unicode_decode from portage import _unicode_encode - from portage.data import portage_uid, portage_gid - from portage.util import ensure_dirs - from portage.const import EPREFIX + from portage.data import portage_gid, portage_uid + from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdi= rs + from portage.util import ensure_dirs, normalize_path ++from portage.const import EPREFIX_LSTRIP =20 def process(mysettings, key, logentries, fulltext): - path =3D key.replace("/", ":") =20 - if mysettings["PORT_LOGDIR"] !=3D "": - elogdir =3D os.path.join(mysettings["PORT_LOGDIR"], "elog") + if mysettings.get("PORT_LOGDIR"): + logdir =3D normalize_path(mysettings["PORT_LOGDIR"]) else: - elogdir =3D os.path.join(EPREFIX, "var", "log", "portage", "elog") - ensure_dirs(elogdir, uid=3Dportage_uid, gid=3Dportage_gid, mode=3D0o27= 70) - logdir =3D os.path.join(os.sep, "var", "log", "portage") ++ logdir =3D os.path.join(os.sep, EPREFIX_LSTRIP, "var", "log", "portag= e") +=20 + if not os.path.isdir(logdir): + # Only initialize group/mode if the directory doesn't + # exist, so that we don't override permissions if they + # were previously set by the administrator. + # NOTE: These permissions should be compatible with our + # default logrotate config as discussed in bug 374287. + ensure_dirs(logdir, uid=3Dportage_uid, gid=3Dportage_gid, mode=3D0o27= 70) =20 cat =3D mysettings['CATEGORY'] pf =3D mysettings['PF'] diff --cc pym/portage/elog/mod_save_summary.py index 5d99a7e,4adc6f3..b0ea4a1 --- a/pym/portage/elog/mod_save_summary.py +++ b/pym/portage/elog/mod_save_summary.py @@@ -8,17 -8,27 +8,28 @@@ from portage import o from portage import _encodings from portage import _unicode_decode from portage import _unicode_encode - from portage.data import portage_uid, portage_gid + from portage.data import portage_gid, portage_uid from portage.localization import _ - from portage.util import ensure_dirs, apply_permissions + from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdi= rs + from portage.util import apply_permissions, ensure_dirs, normalize_path +from portage.const import EPREFIX_LSTRIP =20 def process(mysettings, key, logentries, fulltext): - if mysettings["PORT_LOGDIR"] !=3D "": - elogdir =3D os.path.join(mysettings["PORT_LOGDIR"], "elog") + if mysettings.get("PORT_LOGDIR"): + logdir =3D normalize_path(mysettings["PORT_LOGDIR"]) else: - elogdir =3D os.path.join("/", EPREFIX_LSTRIP, "var", "log", "portage"= , "elog") - ensure_dirs(elogdir, uid=3Dportage_uid, gid=3Dportage_gid, mode=3D0o27= 70) - logdir =3D os.path.join(os.sep, "var", "log", "portage") ++ logdir =3D os.path.join(os.sep, EPREFIX_LSTRIP, "var", "log", "portag= e") +=20 + if not os.path.isdir(logdir): + # Only initialize group/mode if the directory doesn't + # exist, so that we don't override permissions if they + # were previously set by the administrator. + # NOTE: These permissions should be compatible with our + # default logrotate config as discussed in bug 374287. + ensure_dirs(logdir, uid=3Dportage_uid, gid=3Dportage_gid, mode=3D0o27= 70) +=20 + elogdir =3D os.path.join(logdir, "elog") + _ensure_log_subdirs(logdir, elogdir) =20 # TODO: Locking elogfilename =3D elogdir+"/summary.log" diff --cc pym/portage/package/ebuild/fetch.py index b2cc2a3,2ae1fe8..388c209 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@@ -29,10 -29,9 +29,10 @@@ from portage import OrderedDict, os, se from portage.checksum import hashfunc_map, perform_md5, verify_all from portage.const import BASH_BINARY, CUSTOM_MIRRORS_FILE, \ GLOBAL_CONFIG_PATH +from portage.const import rootgid from portage.data import portage_gid, portage_uid, secpass, userpriv_gr= oups from portage.exception import FileNotFound, OperationNotPermitted, \ - PermissionDenied, PortageException, TryAgain + PortageException, TryAgain from portage.localization import _ from portage.locks import lockfile, unlockfile from portage.manifest import Manifest diff --cc pym/portage/package/ebuild/prepare_build_dirs.py index 053ebcc,616dc2e..16ba052 --- a/pym/portage/package/ebuild/prepare_build_dirs.py +++ b/pym/portage/package/ebuild/prepare_build_dirs.py @@@ -16,8 -16,7 +16,8 @@@ from portage.exception import Directory from portage.localization import _ from portage.output import colorize from portage.util import apply_recursive_permissions, \ - apply_secpass_permissions, ensure_dirs, writemsg + apply_secpass_permissions, ensure_dirs, normalize_path, writemsg +from portage.const import EPREFIX =20 def prepare_build_dirs(myroot=3DNone, settings=3DNone, cleanup=3DFalse)= : """ diff --cc pym/portage/util/env_update.py index 4587a2c,eb8a0d9..2650f15 --- a/pym/portage/util/env_update.py +++ b/pym/portage/util/env_update.py @@@ -124,19 -123,9 +124,19 @@@ def env_update(makelinks=3D1, target_root they won't be overwritten by this dict.update call.""" env.update(myconfig) =20 + if EPREFIX =3D=3D '': + dolinkingstuff(target_root, specials, prelink_capable, + makelinks, contents, prev_mtimes, env) + writeshellprofile(target_root, env) + +def dolinkingstuff(target_root, specials, prelink_capable, makelinks, + contents, prev_mtimes, env): + # updating this stuff will never work in an offset, other than ROOT + # (e.g. not in Prefix), hence the EPREFIX is not taken into account + # here since this code should never be triggered on an offset install ldsoconf_path =3D os.path.join(target_root, "etc", "ld.so.conf") try: - myld =3D codecs.open(_unicode_encode(ldsoconf_path, + myld =3D io.open(_unicode_encode(ldsoconf_path, encoding=3D_encodings['fs'], errors=3D'strict'), mode=3D'r', encoding=3D_encodings['content'], errors=3D'replace') myldlines=3Dmyld.readlines()