Gentoo Archives: gentoo-alt

From: Fabian Groffen <grobian@g.o>
To: gentoo-alt@l.g.o
Subject: Re: [gentoo-alt] [PATCH] script/bootstrap-prefix.sh: check PIPESTATUS on unpack
Date: Sat, 19 Feb 2022 16:09:47
Message-Id: YhEWQPOysru8rQKr@gentoo.org
In Reply to: [gentoo-alt] [PATCH] script/bootstrap-prefix.sh: check PIPESTATUS on unpack by Anna Vyalkova
1 Hi!
2
3 This looks like both an improvement as well as a fix.
4
5 Applied as 52e3a39449 and pushed, thanks!
6
7 Fabian
8
9 On 19-02-2022 20:34:21 +0500, Anna Vyalkova wrote:
10 > Both programs need to exit with status 0.
11 >
12 > Signed-off-by: Anna Vyalkova <cyber+gentoo@×××××.in>
13 > ---
14 > I encountered a situation when bzip2 failed but tar didn't return error
15 > code. This patch fixes it.
16 >
17 > Tested with stage1 (can't get past it).
18 >
19 > scripts/bootstrap-prefix.sh | 51 +++++++++++++++++++++----------------
20 > 1 file changed, 29 insertions(+), 22 deletions(-)
21 >
22 > diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
23 > index 76383c0210..b8ad960e6d 100755
24 > --- a/scripts/bootstrap-prefix.sh
25 > +++ b/scripts/bootstrap-prefix.sh
26 > @@ -602,8 +602,8 @@ do_tree() {
27 > fi
28 > einfo "Unpacking, this may take a while"
29 > estatus "stage1: unpacking Portage tree"
30 > - bzip2 -dc ${DISTDIR}/$2 | \
31 > - tar -xf - -C ${PORTDIR} --strip-components=1 || return 1
32 > + bzip2 -dc ${DISTDIR}/$2 | tar -xf - -C ${PORTDIR} --strip-components=1
33 > + [[ ${PIPESTATUS[*]} == '0 0' ]] || return 1
34 > touch ${PORTDIR}/.unpacked
35 > fi
36 > }
37 > @@ -692,7 +692,8 @@ bootstrap_portage() {
38 > rm -rf "${S}" >& /dev/null
39 > mkdir -p "${S}" >& /dev/null
40 > cd "${S}"
41 > - bzip2 -dc "${DISTDIR}/${A}" | tar -xf - || return 1
42 > + bzip2 -dc "${DISTDIR}/${A}" | tar -xf -
43 > + [[ ${PIPESTATUS[*]} == '0 0' ]] || return 1
44 > S="${S}/prefix-portage-${PV}"
45 > cd "${S}"
46 >
47 > @@ -787,7 +788,8 @@ bootstrap_simple() {
48 > bz2) decomp=bzip2 ;;
49 > gz|"") decomp=gzip ;;
50 > esac
51 > - ${decomp} -dc "${DISTDIR}"/${A} | tar -xf - || return 1
52 > + ${decomp} -dc "${DISTDIR}"/${A} | tar -xf -
53 > + [[ ${PIPESTATUS[*]} == '0 0' ]] || return 1
54 > S="${S}"/${PN}-${PV}
55 > cd "${S}"
56 >
57 > @@ -842,18 +844,21 @@ bootstrap_gnu() {
58 > rm -rf "${S}"
59 > mkdir -p "${S}"
60 > cd "${S}"
61 > - if [[ ${t} == "tar.gz" ]] ; then
62 > - gzip -dc "${DISTDIR}"/${URL##*/} | tar -xf - || continue
63 > - elif [[ ${t} == "tar.xz" ]] ; then
64 > - xz -dc "${DISTDIR}"/${URL##*/} | tar -xf - || continue
65 > - elif [[ ${t} == "tar.bz2" ]] ; then
66 > - bzip2 -dc "${DISTDIR}"/${URL##*/} | tar -xf - || continue
67 > - elif [[ ${t} == "tar" ]] ; then
68 > - tar -xf "${DISTDIR}"/${A} || continue
69 > - else
70 > - einfo "unhandled extension: $t"
71 > - return 1
72 > - fi
73 > + case ${t} in
74 > + tar.xz) decomp=xz ;;
75 > + tar.bz2) decomp=bzip2 ;;
76 > + tar.gz) decomp=gzip ;;
77 > + tar)
78 > + tar -xf "${DISTDIR}"/${A} || continue
79 > + break
80 > + ;;
81 > + *)
82 > + einfo "unhandled extension: $t"
83 > + return 1
84 > + ;;
85 > + esac
86 > + ${decomp} -dc "${DISTDIR}"/${URL##*/} | tar -xf -
87 > + [[ ${PIPESTATUS[*]} == '0 0' ]] || continue
88 > break
89 > done
90 > S="${S}"/${PN}-${PV}
91 > @@ -1202,7 +1207,8 @@ bootstrap_cmake_core() {
92 > rm -rf "${S}"
93 > mkdir -p "${S}"
94 > cd "${S}"
95 > - gzip -dc "${DISTDIR}"/${A} | tar -xf - || return 1
96 > + gzip -dc "${DISTDIR}"/${A} | tar -xf -
97 > + [[ ${PIPESTATUS[*]} == '0 0' ]] || return 1
98 > S="${S}"/cmake-${PV}
99 > cd "${S}"
100 >
101 > @@ -1253,11 +1259,12 @@ bootstrap_zlib_core() {
102 > rm -rf "${S}"
103 > mkdir -p "${S}"
104 > cd "${S}"
105 > - if [[ ${A} == *.tar.gz ]] ; then
106 > - gzip -dc "${DISTDIR}"/${A} | tar -xf - || return 1
107 > - else
108 > - bzip2 -dc "${DISTDIR}"/${A} | tar -xf - || return 1
109 > - fi
110 > + case ${A} in
111 > + *.tar.gz) decomp=gzip ;;
112 > + *) decomp=bzip2 ;;
113 > + esac
114 > + ${decomp} -dc "${DISTDIR}"/${A} | tar -xf -
115 > + [[ ${PIPESTATUS[*]} == '0 0' ]] || return 1
116 > S="${S}"/zlib-${PV}
117 > cd "${S}"
118 >
119 > --
120 > 2.35.1
121 >
122 >
123
124 --
125 Fabian Groffen
126 Gentoo on a different level

Attachments

File name MIME type
signature.asc application/pgp-signature