Skip to content

Commit be8811c

Browse files
committed
contrib/rootfs-builder: Support xz (and other) compression formats
I'm not sure when the change happened (sometime since ff5e578, contrib/rootfs-builder: Support multiple architectures, 2017-09-20, #479), but Gentoo is now using xz compression for some amd64 stages: $ curl http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3.txt # Latest as of Fri, 09 Mar 2018 15:00:02 +0000 # ts=1520607602 20180308T214502Z/stage3-amd64-20180308T214502Z.tar.xz 188851072 20180308T214502Z/hardened/stage3-amd64-hardened-20180308T214502Z.tar.xz 174759140 20180308T214502Z/hardened/stage3-amd64-hardened+nomultilib-20180308T214502Z.tar.xz 167639136 20180301T214503Z/hardened/stage3-amd64-hardened-selinux-20180301T214503Z.tar.xz 187319664 20180308T214502Z/stage3-amd64-nomultilib-20180308T214502Z.tar.xz 181866296 20180303/systemd/stage3-amd64-systemd-20180303.tar.bz2 281873162 20180225/uclibc/stage3-amd64-uclibc-hardened-20180225.tar.bz2 57147392 20180225/uclibc/stage3-amd64-uclibc-vanilla-20180225.tar.bz2 144490332 20180308T214502Z/stage3-x32-20180308T214502Z.tar.xz 205285160 20180308T214502Z/hardened/stage4-amd64-hardened+minimal-20180308T214502Z.tar.bz2 261776436 20180308T214502Z/hardened/stage4-amd64-hardened+minimal-nomultilib-20180308T214502Z.tar.bz2 251821245 20180308T214502Z/stage4-amd64-minimal-20180308T214502Z.tar.bz2 280918565 20180308T214502Z/stage4-amd64-minimal-nomultilib-20180308T214502Z.tar.bz2 268835860 20180303/systemd/stage4-amd64-systemd-20180303.tar.bz2 622067712 This commit adapts to that change, allowing us to continue to pull the vanilla stage3-amd64-20180308T214502Z.tar.xz. Signed-off-by: W. Trevor King <[email protected]>
1 parent eea2bc9 commit be8811c

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

contrib/rootfs-builder/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ rootfs-%.tar.gz: rootfs/%/bin/echo
66
tar -czf $@ -C rootfs/$* .
77

88
.PRECIOUS: rootfs/%/bin/busybox
9-
rootfs/%/bin/busybox: downloads/stage3-%-current.tar.bz2 rootfs-files
9+
rootfs/%/bin/busybox: downloads/stage3-%-current.tar rootfs-files
1010
gpg --verify $<.DIGESTS.asc
1111
(cd downloads && \
12-
grep -A1 '^# SHA512 HASH' stage3-$*-current.tar.bz2.DIGESTS.asc | \
12+
grep -A1 '^# SHA512 HASH' stage3-$*-current.tar.DIGESTS.asc | \
1313
grep -v '^--' | \
1414
sha512sum -c)
1515
sudo rm -rf rootfs/$*
1616
sudo mkdir -p rootfs/$*
17-
sudo tar -xvf downloads/stage3-$*-current.tar.bz2 -C rootfs/$* \
17+
sudo tar -xvf downloads/stage3-$*-current.tar -C rootfs/$* \
1818
--no-recursion --wildcards $$(< rootfs-files)
1919
sudo touch $@
2020

@@ -24,9 +24,9 @@ rootfs/%/bin/echo: rootfs/%/bin/busybox
2424
test -L "rootfs/$*/bin/$${COMMAND}" || ln -rs $< "rootfs/$*/bin/$${COMMAND}" || exit; \
2525
done'
2626

27-
downloads/stage3-%-current.tar.bz2: get-stage3.sh
27+
downloads/stage3-%-current.tar: get-stage3.sh
2828
STAGE3_ARCH=$* ./$<
29-
touch downloads/stage3-$*-*.tar.bz2
29+
touch downloads/stage3-$*-*.tar
3030

3131
clean:
3232
rm -f downloads/*

contrib/rootfs-builder/get-stage3.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,23 @@ then
7878
die "could not calculate DATE from ${BASE_ARCH_URL}latest-stage3.txt"
7979
fi
8080
fi
81-
STAGE3="${STAGE3:-stage3-${STAGE3_ARCH}-${DATE}.tar.bz2}"
81+
82+
STAGE3=$(echo "${LATEST}" | sed -n "s|${DATE}/\(stage3-${STAGE3_ARCH}-${DATE}[.]tar[.][^ ]*\) .*|\1|p")
83+
if test -z "${STAGE3}"
84+
then
85+
die "could not calculate STAGE3 from ${BASE_ARCH_URL}latest-stage3.txt"
86+
fi
8287
fi
8388

8489
ARCH_URL="${ARCH_URL:-${BASE_ARCH_URL}${DATE}/}"
8590
STAGE3_CONTENTS="${STAGE3_CONTENTS:-${STAGE3}.CONTENTS}"
8691
STAGE3_DIGESTS="${STAGE3_DIGESTS:-${STAGE3}.DIGESTS.asc}"
8792

93+
COMPRESSION=$(echo "${STAGE3}" | sed -n 's/^.*[.]\([^.]*\)$/\1/p')
94+
if test -z "${COMPRESSION}"
95+
then
96+
die "could not calculate COMPRESSION from ${STAGE3}"
97+
fi
8898
for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do
8999
if [ ! -f "downloads/${FILE}" ]; then
90100
wget -O "downloads/${FILE}" "${ARCH_URL}${FILE}"
@@ -94,12 +104,15 @@ for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do
94104
fi
95105
fi
96106

97-
CURRENT=$(echo "${FILE}" | sed "s/${DATE}/current/")
107+
FILE_NOCOMPRESSION=$(echo "${FILE}" | sed "s/[.]${COMPRESSION}//")
108+
if [ "${FILE_NOCOMPRESSION}" = "${FILE}" ]; then
109+
die "unable to remove .${COMPRESSION} from ${FILE}"
110+
fi
111+
CURRENT=$(echo "${FILE_NOCOMPRESSION}" | sed "s/${DATE}/current/")
98112
(
99113
cd downloads &&
100114
rm -f "${CURRENT}" &&
101115
ln -s "${FILE}" "${CURRENT}" ||
102116
die "failed to link ${CURRENT} -> ${FILE}"
103117
)
104118
done
105-

0 commit comments

Comments
 (0)