1 |
commit: 889853171246ab1063bb5015caf41a41761f5424 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Nov 2 01:47:56 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Nov 2 01:47:56 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=88985317 |
7 |
|
8 |
Merge install_qa_check_prefix from prefix branch. |
9 |
|
10 |
--- |
11 |
bin/misc-functions.sh | 124 +++++++++++++++++++++++++++++++++++++++++++++++++ |
12 |
1 files changed, 124 insertions(+), 0 deletions(-) |
13 |
|
14 |
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh |
15 |
index 55d9663..80cd0f8 100755 |
16 |
--- a/bin/misc-functions.sh |
17 |
+++ b/bin/misc-functions.sh |
18 |
@@ -154,6 +154,12 @@ install_qa_check() { |
19 |
ecompressdir --dequeue |
20 |
ecompress --dequeue |
21 |
|
22 |
+ local ed=${ED} |
23 |
+ case "$EAPI" in 0|1|2) ed=${D} ;; esac |
24 |
+ |
25 |
+ # Prefix specific checks |
26 |
+ [[ ${ed} != ${D} ]] && install_qa_check_prefix |
27 |
+ |
28 |
f= |
29 |
for x in etc/app-defaults usr/man usr/info usr/X11R6 usr/doc usr/locale ; do |
30 |
[[ -d $D/$x ]] && f+=" $x\n" |
31 |
@@ -731,6 +737,124 @@ install_qa_check() { |
32 |
fi |
33 |
} |
34 |
|
35 |
+install_qa_check_prefix() { |
36 |
+ if [[ -d ${ED}/${D} ]] ; then |
37 |
+ find "${ED}/${D}" | \ |
38 |
+ while read i ; do |
39 |
+ eqawarn "QA Notice: /${i##${ED}/${D}} installed in \${ED}/\${D}" |
40 |
+ done |
41 |
+ die "Aborting due to QA concerns: files installed in ${ED}/${D}" |
42 |
+ fi |
43 |
+ |
44 |
+ if [[ -d ${ED}/${EPREFIX} ]] ; then |
45 |
+ find "${ED}/${EPREFIX}/" | \ |
46 |
+ while read i ; do |
47 |
+ eqawarn "QA Notice: ${i#${D}} double prefix" |
48 |
+ done |
49 |
+ die "Aborting due to QA concerns: double prefix files installed" |
50 |
+ fi |
51 |
+ |
52 |
+ if [[ -d ${D} ]] ; then |
53 |
+ 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;} }') |
54 |
+ if [[ -n ${INSTALLTOD} ]] ; then |
55 |
+ eqawarn "QA Notice: the following files are outside of the prefix:" |
56 |
+ eqawarn "${INSTALLTOD}" |
57 |
+ die "Aborting due to QA concerns: there are files installed outside the prefix" |
58 |
+ fi |
59 |
+ fi |
60 |
+ |
61 |
+ # all further checks rely on ${ED} existing |
62 |
+ [[ -d ${ED} ]] || return |
63 |
+ |
64 |
+ # this does not really belong here, but it's closely tied to |
65 |
+ # the code below; many runscripts generate positives here, and we |
66 |
+ # know they don't work (bug #196294) so as long as that one |
67 |
+ # remains an issue, simply remove them as they won't work |
68 |
+ # anyway, avoid etc/init.d/functions.sh from being thrown away |
69 |
+ if [[ ( -d "${ED}"/etc/conf.d || -d "${ED}"/etc/init.d ) && ! -f "${ED}"/etc/init.d/functions.sh ]] ; then |
70 |
+ ewarn "removed /etc/init.d and /etc/conf.d directories until bug #196294 has been resolved" |
71 |
+ rm -Rf "${ED}"/etc/{conf,init}.d |
72 |
+ fi |
73 |
+ |
74 |
+ # check shebangs, bug #282539 |
75 |
+ rm -f "${T}"/non-prefix-shebangs-errs |
76 |
+ local WHITELIST=" /usr/bin/env " |
77 |
+ # this is hell expensive, but how else? |
78 |
+ find "${ED}" -executable \! -type d -print0 \ |
79 |
+ | xargs -0 grep -H -n -m1 "^#!" \ |
80 |
+ | while read f ; |
81 |
+ do |
82 |
+ local fn=${f%%:*} |
83 |
+ local pos=${f#*:} ; pos=${pos%:*} |
84 |
+ local line=${f##*:} |
85 |
+ # shebang always appears on the first line ;) |
86 |
+ [[ ${pos} != 1 ]] && continue |
87 |
+ local oldIFS=${IFS} |
88 |
+ IFS=$'\r'$'\n'$'\t'" " |
89 |
+ line=( ${line#"#!"} ) |
90 |
+ IFS=${oldIFS} |
91 |
+ [[ ${WHITELIST} == *" ${line[0]} "* ]] && continue |
92 |
+ local fp=${fn#${D}} ; fp=/${fp%/*} |
93 |
+ # line[0] can be an absolutised path, bug #342929 |
94 |
+ local eprefix=$(canonicalize ${EPREFIX}) |
95 |
+ local rf=${fn} |
96 |
+ # in case we deal with a symlink, make sure we don't replace it |
97 |
+ # with a real file (sed -i does that) |
98 |
+ if [[ -L ${fn} ]] ; then |
99 |
+ rf=$(readlink ${fn}) |
100 |
+ [[ ${rf} != /* ]] && rf=${fn%/*}/${rf} |
101 |
+ # ignore symlinks pointing to outside prefix |
102 |
+ # as seen in sys-devel/native-cctools |
103 |
+ [[ $(canonicalize "/${rf#${D}}") != ${eprefix}/* ]] && continue |
104 |
+ fi |
105 |
+ # does the shebang start with ${EPREFIX}, and does it exist? |
106 |
+ if [[ ${line[0]} == ${EPREFIX}/* || ${line[0]} == ${eprefix}/* ]] ; then |
107 |
+ if [[ ! -e ${ROOT%/}${line[0]} && ! -e ${D%/}${line[0]} ]] ; then |
108 |
+ # hmm, refers explicitly to $EPREFIX, but doesn't exist, |
109 |
+ # if it's in PATH that's wrong in any case |
110 |
+ if [[ ":${PATH}:" == *":${fp}:"* ]] ; then |
111 |
+ echo "${fn#${D}}:${line[0]} (explicit EPREFIX but target not found)" \ |
112 |
+ >> "${T}"/non-prefix-shebangs-errs |
113 |
+ else |
114 |
+ eqawarn "${fn#${D}} has explicit EPREFIX in shebang but target not found (${line[0]})" |
115 |
+ fi |
116 |
+ fi |
117 |
+ continue |
118 |
+ fi |
119 |
+ # unprefixed shebang, is the script directly in $PATH? |
120 |
+ if [[ ":${PATH}:" == *":${fp}:"* ]] ; then |
121 |
+ if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then |
122 |
+ # is it unprefixed, but we can just fix it because a |
123 |
+ # prefixed variant exists |
124 |
+ eqawarn "prefixing shebang of ${fn#${D}}" |
125 |
+ # statement is made idempotent on purpose, because |
126 |
+ # symlinks may point to the same target, and hence the |
127 |
+ # same real file may be sedded multiple times since we |
128 |
+ # read the shebangs in one go upfront for performance |
129 |
+ # reasons |
130 |
+ sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${rf}" |
131 |
+ continue |
132 |
+ else |
133 |
+ # this is definitely wrong: script in $PATH and invalid shebang |
134 |
+ echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but interpreter ${line[0]} not found)" \ |
135 |
+ >> "${T}"/non-prefix-shebangs-errs |
136 |
+ fi |
137 |
+ else |
138 |
+ # unprefixed/invalid shebang, but outside $PATH, this may be |
139 |
+ # intended (e.g. config.guess) so remain silent by default |
140 |
+ has stricter ${FEATURES} && \ |
141 |
+ eqawarn "invalid shebang in ${fn#${D}}: ${line[0]}" |
142 |
+ fi |
143 |
+ done |
144 |
+ if [[ -e "${T}"/non-prefix-shebangs-errs ]] ; then |
145 |
+ eqawarn "QA Notice: the following files use invalid (possible non-prefixed) shebangs:" |
146 |
+ while read line ; do |
147 |
+ eqawarn " ${line}" |
148 |
+ done < "${T}"/non-prefix-shebangs-errs |
149 |
+ rm -f "${T}"/non-prefix-shebangs-errs |
150 |
+ die "Aborting due to QA concerns: invalid shebangs found" |
151 |
+ fi |
152 |
+} |
153 |
|
154 |
install_mask() { |
155 |
local root="$1" |