Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: bin/
Date: Wed, 14 Aug 2019 02:08:35
Message-Id: 1565748164.17ecafa949c87a6f2a2d2c98c7de18ed06f08f2f.zmedico@gentoo
1 commit: 17ecafa949c87a6f2a2d2c98c7de18ed06f08f2f
2 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
3 AuthorDate: Mon Aug 12 20:20:16 2019 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 14 02:02:44 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=17ecafa9
7
8 unpack: Unconditionally die if an unpacker returns an error.
9
10 As specified by PMS: "If unpacking a supported file format fails,
11 unpack shall abort the build process."
12 https://projects.gentoo.org/pms/7/pms.html#x1-13500012.3.15:
13
14 This partially reverts commit 525e69351d45621c34a9326fcbc11ca592cb6539,
15 as far as unpack() is concerned.
16
17 Bug: https://bugs.gentoo.org/691776
18 Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
19 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
20
21 bin/isolated-functions.sh | 13 ++-----
22 bin/phase-helpers.sh | 87 +++++++++++++----------------------------------
23 2 files changed, 27 insertions(+), 73 deletions(-)
24
25 diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
26 index e4e769a04..893c02f9b 100644
27 --- a/bin/isolated-functions.sh
28 +++ b/bin/isolated-functions.sh
29 @@ -1,5 +1,5 @@
30 #!/bin/bash
31 -# Copyright 1999-2018 Gentoo Foundation
32 +# Copyright 1999-2019 Gentoo Authors
33 # Distributed under the terms of the GNU General Public License v2
34
35 source "${PORTAGE_BIN_PATH}/eapi.sh" || exit 1
36 @@ -38,18 +38,11 @@ __assert_sigpipe_ok() {
37 local x pipestatus=${PIPESTATUS[*]}
38 for x in $pipestatus ; do
39 # Allow SIGPIPE through (128 + 13)
40 - if [[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]]
41 - then
42 - __helpers_die "$@"
43 - return 1
44 - fi
45 + [[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && die "$@"
46 done
47
48 # Require normal success for the last process (tar).
49 - if [[ $x -ne 0 ]]; then
50 - __helpers_die "$@"
51 - return 1
52 - fi
53 + [[ $x -eq 0 ]] || die "$@"
54 }
55
56 shopt -s extdebug
57
58 diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
59 index 02633125f..15fe8c682 100644
60 --- a/bin/phase-helpers.sh
61 +++ b/bin/phase-helpers.sh
62 @@ -1,5 +1,5 @@
63 #!/bin/bash
64 -# Copyright 1999-2018 Gentoo Foundation
65 +# Copyright 1999-2019 Gentoo Authors
66 # Distributed under the terms of the GNU General Public License v2
67
68 if ___eapi_has_DESTTREE_INSDESTTREE; then
69 @@ -347,10 +347,7 @@ unpack() {
70 die "Relative paths to unpack() must be prefixed with './' in EAPI ${EAPI}"
71 fi
72 fi
73 - if [[ ! -s ${srcdir}${x} ]]; then
74 - __helpers_die "unpack: ${x} does not exist"
75 - return 1
76 - fi
77 + [[ ! -s ${srcdir}${x} ]] && die "${x} does not exist"
78
79 __unpack_tar() {
80 if [[ ${y_insensitive} == tar ]] ; then
81 @@ -361,18 +358,15 @@ unpack() {
82 "supported with EAPI '${EAPI}'. Instead use 'tar'."
83 fi
84 $1 -c -- "$srcdir$x" | tar xof -
85 - __assert_sigpipe_ok "$myfail" || return 1
86 + __assert_sigpipe_ok "$myfail"
87 else
88 local cwd_dest=${x##*/}
89 cwd_dest=${cwd_dest%.*}
90 - if ! $1 -c -- "${srcdir}${x}" > "${cwd_dest}"; then
91 - __helpers_die "$myfail"
92 - return 1
93 - fi
94 + $1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail"
95 fi
96 }
97
98 - myfail="unpack: failure unpacking ${x}"
99 + myfail="failure unpacking ${x}"
100 case "${suffix_insensitive}" in
101 tar)
102 if ___eapi_unpack_is_case_sensitive && \
103 @@ -381,10 +375,7 @@ unpack() {
104 "suffix '${suffix}' which is unofficially supported" \
105 "with EAPI '${EAPI}'. Instead use 'tar'."
106 fi
107 - if ! tar xof "$srcdir$x"; then
108 - __helpers_die "$myfail"
109 - return 1
110 - fi
111 + tar xof "$srcdir$x" || die "$myfail"
112 ;;
113 tgz)
114 if ___eapi_unpack_is_case_sensitive && \
115 @@ -393,10 +384,7 @@ unpack() {
116 "suffix '${suffix}' which is unofficially supported" \
117 "with EAPI '${EAPI}'. Instead use 'tgz'."
118 fi
119 - if ! tar xozf "$srcdir$x"; then
120 - __helpers_die "$myfail"
121 - return 1
122 - fi
123 + tar xozf "$srcdir$x" || die "$myfail"
124 ;;
125 tbz|tbz2)
126 if ___eapi_unpack_is_case_sensitive && \
127 @@ -406,7 +394,7 @@ unpack() {
128 "with EAPI '${EAPI}'. Instead use 'tbz' or 'tbz2'."
129 fi
130 ${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcdir$x" | tar xof -
131 - __assert_sigpipe_ok "$myfail" || return 1
132 + __assert_sigpipe_ok "$myfail"
133 ;;
134 zip|jar)
135 if ___eapi_unpack_is_case_sensitive && \
136 @@ -418,10 +406,8 @@ unpack() {
137 fi
138 # unzip will interactively prompt under some error conditions,
139 # as reported in bug #336285
140 - if ! unzip -qo "${srcdir}${x}"; then
141 - __helpers_die "$myfail"
142 - return 1
143 - fi < <(set +x ; while true ; do echo n || break ; done)
144 + ( set +x ; while true ; do echo n || break ; done ) | \
145 + unzip -qo "${srcdir}${x}" || die "$myfail"
146 ;;
147 gz|z)
148 if ___eapi_unpack_is_case_sensitive && \
149 @@ -430,7 +416,7 @@ unpack() {
150 "suffix '${suffix}' which is unofficially supported" \
151 "with EAPI '${EAPI}'. Instead use 'gz', 'z', or 'Z'."
152 fi
153 - __unpack_tar "gzip -d" || return 1
154 + __unpack_tar "gzip -d"
155 ;;
156 bz2|bz)
157 if ___eapi_unpack_is_case_sensitive && \
158 @@ -439,8 +425,7 @@ unpack() {
159 "suffix '${suffix}' which is unofficially supported" \
160 "with EAPI '${EAPI}'. Instead use 'bz' or 'bz2'."
161 fi
162 - __unpack_tar "${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d}" \
163 - || return 1
164 + __unpack_tar "${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d}"
165 ;;
166 7z)
167 local my_output
168 @@ -457,10 +442,7 @@ unpack() {
169 "suffix '${suffix}' which is unofficially supported" \
170 "with EAPI '${EAPI}'. Instead use 'rar' or 'RAR'."
171 fi
172 - if ! unrar x -idq -o+ "${srcdir}${x}"; then
173 - __helpers_die "$myfail"
174 - return 1
175 - fi
176 + unrar x -idq -o+ "${srcdir}${x}" || die "$myfail"
177 ;;
178 lha|lzh)
179 if ___eapi_unpack_is_case_sensitive && \
180 @@ -470,10 +452,7 @@ unpack() {
181 "with EAPI '${EAPI}'." \
182 "Instead use 'LHA', 'LHa', 'lha', or 'lzh'."
183 fi
184 - if ! lha xfq "${srcdir}${x}"; then
185 - __helpers_die "$myfail"
186 - return 1
187 - fi
188 + lha xfq "${srcdir}${x}" || die "$myfail"
189 ;;
190 a)
191 if ___eapi_unpack_is_case_sensitive && \
192 @@ -482,10 +461,7 @@ unpack() {
193 "suffix '${suffix}' which is unofficially supported" \
194 "with EAPI '${EAPI}'. Instead use 'a'."
195 fi
196 - if ! ar x "${srcdir}${x}"; then
197 - __helpers_die "$myfail"
198 - return 1
199 - fi
200 + ar x "${srcdir}${x}" || die "$myfail"
201 ;;
202 deb)
203 if ___eapi_unpack_is_case_sensitive && \
204 @@ -508,32 +484,20 @@ unpack() {
205 # deb2targz always extracts into the same directory as
206 # the source file, so create a symlink in the current
207 # working directory if necessary.
208 - if ! ln -sf "$srcdir$x" "$y"; then
209 - __helpers_die "$myfail"
210 - return 1
211 - fi
212 + ln -sf "$srcdir$x" "$y" || die "$myfail"
213 created_symlink=1
214 fi
215 - if ! deb2targz "$y"; then
216 - __helpers_die "$myfail"
217 - return 1
218 - fi
219 + deb2targz "$y" || die "$myfail"
220 if [ $created_symlink = 1 ] ; then
221 # Clean up the symlink so the ebuild
222 # doesn't inadvertently install it.
223 rm -f "$y"
224 fi
225 - if ! mv -f "${y%.deb}".tar.gz data.tar.gz; then
226 - if ! mv -f "${y%.deb}".tar.xz data.tar.xz; then
227 - __helpers_die "$myfail"
228 - return 1
229 - fi
230 - fi
231 + mv -f "${y%.deb}".tar.gz data.tar.gz \
232 + || mv -f "${y%.deb}".tar.xz data.tar.xz \
233 + || die "$myfail"
234 else
235 - if ! ar x "$srcdir$x"; then
236 - __helpers_die "$myfail"
237 - return 1
238 - fi
239 + ar x "$srcdir$x" || die "$myfail"
240 fi
241 ;;
242 lzma)
243 @@ -543,7 +507,7 @@ unpack() {
244 "suffix '${suffix}' which is unofficially supported" \
245 "with EAPI '${EAPI}'. Instead use 'lzma'."
246 fi
247 - __unpack_tar "lzma -d" || return 1
248 + __unpack_tar "lzma -d"
249 ;;
250 xz)
251 if ___eapi_unpack_is_case_sensitive && \
252 @@ -553,7 +517,7 @@ unpack() {
253 "with EAPI '${EAPI}'. Instead use 'xz'."
254 fi
255 if ___eapi_unpack_supports_xz; then
256 - __unpack_tar "xz -d" || return 1
257 + __unpack_tar "xz -d"
258 else
259 __vecho "unpack ${x}: file format not recognized. Ignoring."
260 fi
261 @@ -566,10 +530,7 @@ unpack() {
262 "with EAPI '${EAPI}'. Instead use 'txz'."
263 fi
264 if ___eapi_unpack_supports_txz; then
265 - if ! tar xof "$srcdir$x"; then
266 - __helpers_die "$myfail"
267 - return 1
268 - fi
269 + tar xof "$srcdir$x" || die "$myfail"
270 else
271 __vecho "unpack ${x}: file format not recognized. Ignoring."
272 fi