public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:prefix commit in: bin/install-qa-check.d/
Date: Sun, 23 Dec 2018 11:23:49 +0000 (UTC)	[thread overview]
Message-ID: <1545564159.99383de9bc96c7b4549afb9992dcbde308dc4dd1.grobian@gentoo> (raw)

commit:     99383de9bc96c7b4549afb9992dcbde308dc4dd1
Author:     Michael Haubenwallner <haubi <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 16:30:35 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Dec 23 11:22:39 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=99383de9

install-qa-check.d/05prefix(D,ED,ROOT,EROOT): support EAPI 7

Also, need to canonicalize EPREFIX only once.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 bin/install-qa-check.d/05prefix | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/bin/install-qa-check.d/05prefix b/bin/install-qa-check.d/05prefix
index 32561e263..f702b77f0 100644
--- a/bin/install-qa-check.d/05prefix
+++ b/bin/install-qa-check.d/05prefix
@@ -3,24 +3,24 @@
 install_qa_check_prefix() {
 	[[ ${ED} == ${D} ]] && return
 
-	if [[ -d ${ED}/${D} ]] ; then
-		find "${ED}/${D}" | \
+	if [[ -d ${ED%/}${D%/} ]] ; then
+		find "${ED%/}${D%/}/" | \
 		while read i ; do
-			eqawarn "QA Notice: /${i##${ED}/${D}} installed in \${ED}/\${D}"
+			eqawarn "QA Notice: /${i#${ED%/}${D%/}/} installed in \${ED}\${D}"
 		done
-		die "Aborting due to QA concerns: files installed in ${ED}/${D}"
+		die "Aborting due to QA concerns: files installed in ${ED%/}${D%/}/"
 	fi
 
-	if [[ -d ${ED}/${EPREFIX} ]] ; then
-		find "${ED}/${EPREFIX}/" | \
+	if [[ -d ${ED%/}${EPREFIX} ]] ; then
+		find "${ED%/}${EPREFIX}/" | \
 		while read i ; do
-			eqawarn "QA Notice: ${i#${D}} double prefix"
+			eqawarn "QA Notice: ${i#${D%/}/} double prefix"
 		done
 		die "Aborting due to QA concerns: double prefix files installed"
 	fi
 
-	if [[ -d ${D} ]] ; then
-		INSTALLTOD=$(find ${D%/} | egrep -v "^${ED}" | sed -e "s|^${D%/}||" | awk '{if (length($0) <= length("'"${EPREFIX}"'")) { if (substr("'"${EPREFIX}"'", 1, length($0)) != $0) {print $0;} } else if (substr($0, 1, length("'"${EPREFIX}"'")) != "'"${EPREFIX}"'") {print $0;} }')
+	if [[ -d ${D%/}/ ]] ; then
+		INSTALLTOD=$(find ${D%/} | egrep -v "^${ED%/}/" | sed -e "s|^${D%/}||" | awk '{if (length($0) <= length("'"${EPREFIX}"'")) { if (substr("'"${EPREFIX}"'", 1, length($0)) != $0) {print $0;} } else if (substr($0, 1, length("'"${EPREFIX}"'")) != "'"${EPREFIX}"'") {print $0;} }')
 		if [[ -n ${INSTALLTOD} ]] ; then
 			eqawarn "QA Notice: the following files are outside of the prefix:"
 			eqawarn "${INSTALLTOD}"
@@ -34,8 +34,10 @@ install_qa_check_prefix() {
 	# check shebangs, bug #282539
 	rm -f "${T}"/non-prefix-shebangs-errs
 	local WHITELIST=" /usr/bin/env "
+	# shebang can be an absolutised path, bug #342929
+	local eprefix=$(canonicalize ${EPREFIX})
 	# this is hell expensive, but how else?
-	find "${ED}" -executable \! -type d -print0 \
+	find "${ED%/}/" -executable \! -type d -print0 \
 			| xargs -0 grep -H -n -m1 "^#!" \
 			| while read f ;
 	do
@@ -49,9 +51,7 @@ install_qa_check_prefix() {
 		line=( ${line#"#!"} )
 		IFS=${oldIFS}
 		[[ ${WHITELIST} == *" ${line[0]} "* ]] && continue
-		local fp=${fn#${D}} ; fp=/${fp%/*}
-		# line[0] can be an absolutised path, bug #342929
-		local eprefix=$(canonicalize ${EPREFIX})
+		local fp=${fn#${D%/}/} ; fp=/${fp%/*}
 		local rf=${fn}
 		# in case we deal with a symlink, make sure we don't replace it
 		# with a real file (sed -i does that)
@@ -60,7 +60,7 @@ install_qa_check_prefix() {
 			[[ ${rf} != /* ]] && rf=${fn%/*}/${rf}
 			# ignore symlinks pointing to outside prefix
 			# as seen in sys-devel/native-cctools
-			[[ $(canonicalize "/${rf#${D}}") != ${eprefix}/* ]] && continue
+			[[ $(canonicalize "/${rf#${D%/}/}") != ${eprefix}/* ]] && continue
 		fi
 		# does the shebang start with ${EPREFIX}, and does it exist?
 		if [[ ${line[0]} == ${EPREFIX}/* || ${line[0]} == ${eprefix}/* ]] ; then
@@ -68,10 +68,10 @@ install_qa_check_prefix() {
 				# hmm, refers explicitly to $EPREFIX, but doesn't exist,
 				# if it's in PATH that's wrong in any case
 				if [[ ":${PATH}:" == *":${fp}:"* ]] ; then
-					echo "${fn#${D}}:${line[0]} (explicit EPREFIX but target not found)" \
+					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]})"
+					eqawarn "${fn#${D%/}/} has explicit EPREFIX in shebang but target not found (${line[0]})"
 				fi
 			fi
 			continue
@@ -79,10 +79,10 @@ install_qa_check_prefix() {
 		# unprefixed shebang, is the script directly in $PATH or an init
 		# script?
 		if [[ ":${PATH}:${EPREFIX}/etc/init.d:" == *":${fp}:"* ]] ; then
-			if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; 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}}"
+				eqawarn "eprefixing 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
@@ -92,14 +92,14 @@ install_qa_check_prefix() {
 				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)" \
+				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]}"
+				eqawarn "invalid shebang in ${fn#${D%/}/}: ${line[0]}"
 		fi
 	done
 	if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then


             reply	other threads:[~2018-12-23 11:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-23 11:23 Fabian Groffen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-26 19:36 [gentoo-commits] proj/portage:prefix commit in: bin/install-qa-check.d/ Fabian Groffen
2021-01-15 18:35 Fabian Groffen
2018-12-23 11:23 Fabian Groffen
2016-02-18 19:16 Fabian Groffen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1545564159.99383de9bc96c7b4549afb9992dcbde308dc4dd1.grobian@gentoo \
    --to=grobian@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox