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 1RLPw7-0004bv-0g for garchives@archives.gentoo.org; Wed, 02 Nov 2011 01:48:15 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C715B21C0B3; Wed, 2 Nov 2011 01:48:06 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8469B21C0B3 for ; Wed, 2 Nov 2011 01:48:06 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E70751B4016 for ; Wed, 2 Nov 2011 01:48:05 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 3945E80042 for ; Wed, 2 Nov 2011 01:48:05 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <889853171246ab1063bb5015caf41a41761f5424.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/misc-functions.sh X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 889853171246ab1063bb5015caf41a41761f5424 Date: Wed, 2 Nov 2011 01:48:05 +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: 5e1215dc-666a-4927-861d-a6ed4bdea446 X-Archives-Hash: 757e4e2100a5672c61bb1dfa8b503d31 commit: 889853171246ab1063bb5015caf41a41761f5424 Author: Zac Medico gentoo org> AuthorDate: Wed Nov 2 01:47:56 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Nov 2 01:47:56 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D88985317 Merge install_qa_check_prefix from prefix branch. --- bin/misc-functions.sh | 124 +++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 124 insertions(+), 0 deletions(-) diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 55d9663..80cd0f8 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -154,6 +154,12 @@ install_qa_check() { ecompressdir --dequeue ecompress --dequeue =20 + local ed=3D${ED} + case "$EAPI" in 0|1|2) ed=3D${D} ;; esac + + # Prefix specific checks + [[ ${ed} !=3D ${D} ]] && install_qa_check_prefix + f=3D for x in etc/app-defaults usr/man usr/info usr/X11R6 usr/doc usr/locale= ; do [[ -d $D/$x ]] && f+=3D" $x\n" @@ -731,6 +737,124 @@ install_qa_check() { 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("'"${E= PREFIX}"'", 1, length($0)) !=3D $0) {print $0;} } else if (substr($0, 1, = length("'"${EPREFIX}"'")) !=3D "'"${EPREFIX}"'") {print $0;} }') + 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 t= he 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 #1962= 94 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 + [[ $(canonicalize "/${rf#${D}}") !=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]}':' "${r= f}" + 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 + 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-pref= ixed) 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 +} =20 install_mask() { local root=3D"$1"