Skip to content

Commit 02b49ac

Browse files
author
Mrunal Patel
authored
Merge pull request #479 from wking/per-arch-tarballs
rootfs-*.tar.gz: Add per-arch tarballs (currently for amd64 and 386)
2 parents 11703a7 + c3c8c02 commit 02b49ac

File tree

7 files changed

+82
-31
lines changed

7 files changed

+82
-31
lines changed

contrib/rootfs-builder/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.gz

contrib/rootfs-builder/Makefile

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
rootfs.tar.gz: rootfs/bin/echo
2-
tar -czf $@ -C rootfs .
1+
ARCHES ?= amd64
32

4-
rootfs/bin/busybox: downloads/stage3-amd64-current.tar.bz2 rootfs-files
3+
all: $(ARCHES:%=rootfs-%.tar.gz)
4+
5+
rootfs-%.tar.gz: rootfs/%/bin/echo
6+
tar -czf $@ -C rootfs/$* .
7+
8+
.PRECIOUS: rootfs/%/bin/busybox
9+
rootfs/%/bin/busybox: downloads/stage3-%-current.tar.bz2 rootfs-files
510
gpg --verify $<.DIGESTS.asc
611
(cd downloads && \
7-
grep -A1 '^# SHA512 HASH' stage3-amd64-current.tar.bz2.DIGESTS.asc | \
12+
grep -A1 '^# SHA512 HASH' stage3-$*-current.tar.bz2.DIGESTS.asc | \
813
grep -v '^--' | \
914
sha512sum -c)
10-
sudo rm -rf rootfs
11-
sudo mkdir rootfs
12-
sudo tar -xvf downloads/stage3-amd64-current.tar.bz2 -C rootfs \
15+
sudo rm -rf rootfs/$*
16+
sudo mkdir -p rootfs/$*
17+
sudo tar -xvf downloads/stage3-$*-current.tar.bz2 -C rootfs/$* \
1318
--no-recursion --wildcards $$(< rootfs-files)
1419
sudo touch $@
1520

16-
rootfs/bin/echo: rootfs/bin/busybox
17-
sudo sh -c 'for COMMAND in $$($< --list); do \
18-
ln -rs $< "rootfs/bin/$${COMMAND}"; \
21+
.PRECIOUS: rootfs/%/bin/echo
22+
rootfs/%/bin/echo: rootfs/%/bin/busybox
23+
sudo sh -c 'COMMANDS=$$($< --list) || exit 1; for COMMAND in $${COMMANDS}; do \
24+
test -L "rootfs/$*/bin/$${COMMAND}" || ln -rs $< "rootfs/$*/bin/$${COMMAND}" || exit; \
1925
done'
2026

21-
downloads/stage3-amd64-current.tar.bz2: get-stage3.sh
22-
./$<
23-
touch downloads/stage3-amd64-*.tar.bz2
27+
downloads/stage3-%-current.tar.bz2: get-stage3.sh
28+
STAGE3_ARCH=$* ./$<
29+
touch downloads/stage3-$*-*.tar.bz2
2430

2531
clean:
2632
rm -f downloads/*

contrib/rootfs-builder/README.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
1-
Building `rootfs.tar.gz`
2-
------------------------
1+
# Building `rootfs-*.tar.gz`
32

4-
The root filesystem tarball is based on [Gentoo][]'s [amd64
5-
stage3][stage3-amd64] (which we check for a valid [GnuPG
3+
The root filesystem tarball is based on [Gentoo][]'s stage3s (e.g. the
4+
[amd64 stage3][stage3-amd64]). We check for a valid [GnuPG
65
signature][gentoo-signatures]), copying a [minimal
76
subset](rootfs-files) to the root filesytem, and adding symlinks for
8-
all BusyBox commands. To rebuild the tarball based on a newer stage3,
9-
just run:
7+
all BusyBox commands. To rebuild the tarball based on a newer stage3,
8+
run:
109

1110
```
1211
$ touch get-stage3.sh
13-
$ make rootfs.tar.gz
12+
$ make rootfs-amd64.tar.gz
1413
```
1514

16-
### Getting Gentoo's Release Engineering public key
15+
## Platform tarballs
1716

18-
If `make rootfs.tar.gz` gives an error like:
17+
The extraction requires a local machine capable of executing the
18+
extracted BusyBox. Extraction assumes amd64, but if your local
19+
machine is a different platform, set `ARCHES`. For example:
20+
21+
```
22+
$ make ARCHES='i486 i686 amd64'
23+
```
24+
25+
The architecture identifiers can be found by browsing Gentoo's
26+
[releases][] for `autobuilds/latest-stage3-{arch}.txt`. Examples
27+
include:
28+
29+
* `amd64` (the default)
30+
* `arm64`
31+
* `arm7a`
32+
* `i486`
33+
* `i686`
34+
* `ppc64-64ul`
35+
36+
and many more.
37+
38+
## Getting Gentoo's Release Engineering public key
39+
40+
If `make rootfs-….tar.gz` gives an error like:
1941

2042
```
2143
gpg --verify downloads/stage3-amd64-current.tar.bz2.DIGESTS.asc
@@ -32,6 +54,7 @@ $ gpg --keyserver pool.sks-keyservers.net --recv-keys 2D182910
3254
```
3355

3456
[Gentoo]: https://www.gentoo.org/
35-
[stage3-amd64]: http://distfiles.gentoo.org/releases/amd64/autobuilds/
3657
[gentoo-signatures]: https://www.gentoo.org/downloads/signatures/
3758
[recv-keys]: https://www.gnupg.org/documentation/manuals/gnupg/Operational-GPG-Commands.html
59+
[releases]: http://distfiles.gentoo.org/releases/
60+
[stage3-amd64]: http://distfiles.gentoo.org/releases/amd64/autobuilds/

contrib/rootfs-builder/get-stage3.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,31 @@
1717
# limitations under the License.
1818

1919
MIRROR="${MIRROR:-http://distfiles.gentoo.org/}"
20-
BASE_ARCH_URL="${BASE_ARCH_URL:-${MIRROR}releases/amd64/autobuilds/}"
20+
STAGE3_ARCH="${STAGE3_ARCH:-amd64}"
21+
22+
if test -z "${BASE_ARCH}"
23+
then
24+
case "${STAGE3_ARCH}" in
25+
arm*)
26+
BASE_ARCH=arm
27+
;;
28+
i[46]86)
29+
BASE_ARCH=x86
30+
;;
31+
ppc*)
32+
BASE_ARCH=ppc
33+
;;
34+
*)
35+
BASE_ARCH="${STAGE3_ARCH}"
36+
;;
37+
esac
38+
fi
39+
40+
BASE_ARCH_URL="${BASE_ARCH_URL:-${MIRROR}releases/${BASE_ARCH}/autobuilds/}"
2141
LATEST=$(wget -O - "${BASE_ARCH_URL}latest-stage3.txt")
22-
DATE=$(echo "${LATEST}" | sed -n 's|/stage3-amd64-[0-9]*[.]tar[.]bz2.*||p')
42+
DATE=$(echo "${LATEST}" | sed -n "s|/stage3-${STAGE3_ARCH}-[0-9]*[.]tar[.]bz2.*||p")
2343
ARCH_URL="${ARCH_URL:-${BASE_ARCH_URL}${DATE}/}"
24-
STAGE3="${STAGE3:-stage3-amd64-${DATE}.tar.bz2}"
44+
STAGE3="${STAGE3:-stage3-${STAGE3_ARCH}-${DATE}.tar.bz2}"
2545
STAGE3_CONTENTS="${STAGE3_CONTENTS:-${STAGE3}.CONTENTS}"
2646
STAGE3_DIGESTS="${STAGE3_DIGESTS:-${STAGE3}.DIGESTS.asc}"
2747

rootfs-386.tar.gz

936 KB
Binary file not shown.
File renamed without changes.

validation/validation_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"os/exec"
88
"path/filepath"
9+
"runtime"
910
"testing"
1011

1112
"github.com/mrunalp/fileutils"
@@ -18,13 +19,13 @@ import (
1819
)
1920

2021
var (
21-
runtime = "runc"
22+
runtimeCommand = "runc"
2223
)
2324

2425
func init() {
2526
runtimeInEnv := os.Getenv("RUNTIME")
2627
if runtimeInEnv != "" {
27-
runtime = runtimeInEnv
28+
runtimeCommand = runtimeInEnv
2829
}
2930
}
3031

@@ -36,7 +37,7 @@ func prepareBundle() (string, error) {
3637
}
3738

3839
// Untar the root fs
39-
untarCmd := exec.Command("tar", "-xf", "../rootfs.tar.gz", "-C", bundleDir)
40+
untarCmd := exec.Command("tar", "-xf", fmt.Sprintf("../rootfs-%s.tar.gz", runtime.GOARCH), "-C", bundleDir)
4041
_, err = untarCmd.CombinedOutput()
4142
if err != nil {
4243
os.RemoveAll(bundleDir)
@@ -58,7 +59,7 @@ func runtimeInsideValidate(g *generate.Generator) error {
5859
if err != nil {
5960
return err
6061
}
61-
r, err := NewRuntime(runtime, bundleDir)
62+
r, err := NewRuntime(runtimeCommand, bundleDir)
6263
if err != nil {
6364
os.RemoveAll(bundleDir)
6465
return err
@@ -102,7 +103,7 @@ func TestValidateCreate(t *testing.T) {
102103
bundleDir, err := prepareBundle()
103104
assert.Nil(t, err)
104105

105-
r, err := NewRuntime(runtime, bundleDir)
106+
r, err := NewRuntime(runtimeCommand, bundleDir)
106107
assert.Nil(t, err)
107108
defer r.Clean(true)
108109

0 commit comments

Comments
 (0)