Skip to content

Commit 3f64e51

Browse files
authored
Merge pull request #598 from wking/rootfs-builder-compression
contrib/rootfs-builder: Support timestamps and xz compression
2 parents 36e9b37 + a7f94a2 commit 3f64e51

File tree

5 files changed

+69
-19
lines changed

5 files changed

+69
-19
lines changed

contrib/rootfs-builder/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ 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

2121
.PRECIOUS: rootfs/%/bin/echo
2222
rootfs/%/bin/echo: rootfs/%/bin/busybox
23-
sudo sh -c 'COMMANDS=$$($< --list) || exit 1; for COMMAND in $${COMMANDS}; do \
23+
sudo sh -c 'COMMANDS=$$($< --list | grep -v "^busybox$$") || exit 1; for COMMAND in $${COMMANDS}; do \
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: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Download the current Gentoo stage3
44
#
5-
# Copyright (C) 2014-2015 W. Trevor King <[email protected]>
5+
# Copyright (C) 2014-2018 W. Trevor King <[email protected]>
66
#
77
# Licensed under the Apache License, Version 2.0 (the "License");
88
# you may not use this file except in compliance with the License.
@@ -16,8 +16,36 @@
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
1818

19+
die()
20+
{
21+
echo "$1"
22+
exit 1
23+
}
24+
1925
MIRROR="${MIRROR:-http://distfiles.gentoo.org/}"
20-
STAGE3_ARCH="${STAGE3_ARCH:-amd64}"
26+
if test -n "${STAGE3}"
27+
then
28+
if test -n "${STAGE3_ARCH}"
29+
then
30+
die 'if you set STAGE3, you do not need to set STAGE3_ARCH'
31+
fi
32+
if test -n "${DATE}"
33+
then
34+
die 'if you set STAGE3, you do not need to set DATE'
35+
fi
36+
STAGE3_ARCH=$(echo "${STAGE3}" | sed -n 's/stage3-\([^-]*\)-.*/\1/p')
37+
if test -z "${STAGE3_ARCH}"
38+
then
39+
die "could not calculate STAGE3_ARCH from ${STAGE3}"
40+
fi
41+
DATE=$(echo "${STAGE3}" | sed -n "s/stage3-${STAGE3_ARCH}-\([0-9TZ]*\)[.]tar[.].*/\1/p")
42+
if test -z "${DATE}"
43+
then
44+
die "could not calculate DATE from ${STAGE3}"
45+
fi
46+
else
47+
STAGE3_ARCH="${STAGE3_ARCH:-amd64}"
48+
fi
2149

2250
if test -z "${BASE_ARCH}"
2351
then
@@ -38,19 +66,35 @@ then
3866
fi
3967

4068
BASE_ARCH_URL="${BASE_ARCH_URL:-${MIRROR}releases/${BASE_ARCH}/autobuilds/}"
41-
LATEST=$(wget -O - "${BASE_ARCH_URL}latest-stage3.txt")
42-
DATE=$(echo "${LATEST}" | sed -n "s|/stage3-${STAGE3_ARCH}-[0-9]*[.]tar[.]bz2.*||p")
69+
70+
if test -z "${STAGE3}"
71+
then
72+
LATEST=$(wget -O - "${BASE_ARCH_URL}latest-stage3.txt")
73+
if test -z "${DATE}"
74+
then
75+
DATE=$(echo "${LATEST}" | sed -n "s|/stage3-${STAGE3_ARCH}-[0-9TZ]*[.]tar.*||p")
76+
if test -z "${DATE}"
77+
then
78+
die "could not calculate DATE from ${BASE_ARCH_URL}latest-stage3.txt"
79+
fi
80+
fi
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
87+
fi
88+
4389
ARCH_URL="${ARCH_URL:-${BASE_ARCH_URL}${DATE}/}"
44-
STAGE3="${STAGE3:-stage3-${STAGE3_ARCH}-${DATE}.tar.bz2}"
4590
STAGE3_CONTENTS="${STAGE3_CONTENTS:-${STAGE3}.CONTENTS}"
4691
STAGE3_DIGESTS="${STAGE3_DIGESTS:-${STAGE3}.DIGESTS.asc}"
4792

48-
die()
49-
{
50-
echo "$1"
51-
exit 1
52-
}
53-
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
5498
for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do
5599
if [ ! -f "downloads/${FILE}" ]; then
56100
wget -O "downloads/${FILE}" "${ARCH_URL}${FILE}"
@@ -60,12 +104,15 @@ for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do
60104
fi
61105
fi
62106

63-
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/")
64112
(
65113
cd downloads &&
66114
rm -f "${CURRENT}" &&
67115
ln -s "${FILE}" "${CURRENT}" ||
68116
die "failed to link ${CURRENT} -> ${FILE}"
69117
)
70118
done
71-
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
./bin/busybox
2+
./dev
23
./etc/group
34
./etc/passwd
5+
./proc
6+
./sys

rootfs-386.tar.gz

101 KB
Binary file not shown.

rootfs-amd64.tar.gz

60.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)