Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contrib/rootfs-builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.gz
32 changes: 19 additions & 13 deletions contrib/rootfs-builder/Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
rootfs.tar.gz: rootfs/bin/echo
tar -czf $@ -C rootfs .
ARCHES ?= amd64

rootfs/bin/busybox: downloads/stage3-amd64-current.tar.bz2 rootfs-files
all: $(ARCHES:%=rootfs-%.tar.gz)

rootfs-%.tar.gz: rootfs/%/bin/echo
tar -czf $@ -C rootfs/$* .

.PRECIOUS: rootfs/%/bin/busybox
rootfs/%/bin/busybox: downloads/stage3-%-current.tar.bz2 rootfs-files
gpg --verify $<.DIGESTS.asc
(cd downloads && \
grep -A1 '^# SHA512 HASH' stage3-amd64-current.tar.bz2.DIGESTS.asc | \
grep -A1 '^# SHA512 HASH' stage3-$*-current.tar.bz2.DIGESTS.asc | \
grep -v '^--' | \
sha512sum -c)
sudo rm -rf rootfs
sudo mkdir rootfs
sudo tar -xvf downloads/stage3-amd64-current.tar.bz2 -C rootfs \
sudo rm -rf rootfs/$*
sudo mkdir -p rootfs/$*
sudo tar -xvf downloads/stage3-$*-current.tar.bz2 -C rootfs/$* \
--no-recursion --wildcards $$(< rootfs-files)
sudo touch $@

rootfs/bin/echo: rootfs/bin/busybox
sudo sh -c 'for COMMAND in $$($< --list); do \
ln -rs $< "rootfs/bin/$${COMMAND}"; \
.PRECIOUS: rootfs/%/bin/echo
rootfs/%/bin/echo: rootfs/%/bin/busybox
sudo sh -c 'COMMANDS=$$($< --list) || exit 1; for COMMAND in $${COMMANDS}; do \
test -L "rootfs/$*/bin/$${COMMAND}" || ln -rs $< "rootfs/$*/bin/$${COMMAND}" || exit; \
done'

downloads/stage3-amd64-current.tar.bz2: get-stage3.sh
./$<
touch downloads/stage3-amd64-*.tar.bz2
downloads/stage3-%-current.tar.bz2: get-stage3.sh
STAGE3_ARCH=$* ./$<
touch downloads/stage3-$*-*.tar.bz2

clean:
rm -f downloads/*
Expand Down
43 changes: 33 additions & 10 deletions contrib/rootfs-builder/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
Building `rootfs.tar.gz`
------------------------
# Building `rootfs-*.tar.gz`

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

```
$ touch get-stage3.sh
$ make rootfs.tar.gz
$ make rootfs-amd64.tar.gz
```

### Getting Gentoo's Release Engineering public key
## Platform tarballs

If `make rootfs.tar.gz` gives an error like:
The extraction requires a local machine capable of executing the
extracted BusyBox. Extraction assumes amd64, but if your local
machine is a different platform, set `ARCHES`. For example:

```
$ make ARCHES='i486 i686 amd64'
```

The architecture identifiers can be found by browsing Gentoo's
[releases][] for `autobuilds/latest-stage3-{arch}.txt`. Examples
include:

* `amd64` (the default)
* `arm64`
* `arm7a`
* `i486`
* `i686`
* `ppc64-64ul`

and many more.

## Getting Gentoo's Release Engineering public key

If `make rootfs-….tar.gz` gives an error like:

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

[Gentoo]: https://www.gentoo.org/
[stage3-amd64]: http://distfiles.gentoo.org/releases/amd64/autobuilds/
[gentoo-signatures]: https://www.gentoo.org/downloads/signatures/
[recv-keys]: https://www.gnupg.org/documentation/manuals/gnupg/Operational-GPG-Commands.html
[releases]: http://distfiles.gentoo.org/releases/
[stage3-amd64]: http://distfiles.gentoo.org/releases/amd64/autobuilds/
26 changes: 23 additions & 3 deletions contrib/rootfs-builder/get-stage3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,31 @@
# limitations under the License.

MIRROR="${MIRROR:-http://distfiles.gentoo.org/}"
BASE_ARCH_URL="${BASE_ARCH_URL:-${MIRROR}releases/amd64/autobuilds/}"
STAGE3_ARCH="${STAGE3_ARCH:-amd64}"

if test -z "${BASE_ARCH}"
then
case "${STAGE3_ARCH}" in
arm*)
BASE_ARCH=arm
;;
i[46]86)
BASE_ARCH=x86
;;
ppc*)
BASE_ARCH=ppc
;;
*)
BASE_ARCH="${STAGE3_ARCH}"
;;
esac
fi

BASE_ARCH_URL="${BASE_ARCH_URL:-${MIRROR}releases/${BASE_ARCH}/autobuilds/}"
LATEST=$(wget -O - "${BASE_ARCH_URL}latest-stage3.txt")
DATE=$(echo "${LATEST}" | sed -n 's|/stage3-amd64-[0-9]*[.]tar[.]bz2.*||p')
DATE=$(echo "${LATEST}" | sed -n "s|/stage3-${STAGE3_ARCH}-[0-9]*[.]tar[.]bz2.*||p")
ARCH_URL="${ARCH_URL:-${BASE_ARCH_URL}${DATE}/}"
STAGE3="${STAGE3:-stage3-amd64-${DATE}.tar.bz2}"
STAGE3="${STAGE3:-stage3-${STAGE3_ARCH}-${DATE}.tar.bz2}"
STAGE3_CONTENTS="${STAGE3_CONTENTS:-${STAGE3}.CONTENTS}"
STAGE3_DIGESTS="${STAGE3_DIGESTS:-${STAGE3}.DIGESTS.asc}"

Expand Down
Binary file added rootfs-386.tar.gz
Binary file not shown.
File renamed without changes.
11 changes: 6 additions & 5 deletions validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"

"github.com/mrunalp/fileutils"
Expand All @@ -18,13 +19,13 @@ import (
)

var (
runtime = "runc"
runtimeCommand = "runc"
)

func init() {
runtimeInEnv := os.Getenv("RUNTIME")
if runtimeInEnv != "" {
runtime = runtimeInEnv
runtimeCommand = runtimeInEnv
}
}

Expand All @@ -36,7 +37,7 @@ func prepareBundle() (string, error) {
}

// Untar the root fs
untarCmd := exec.Command("tar", "-xf", "../rootfs.tar.gz", "-C", bundleDir)
untarCmd := exec.Command("tar", "-xf", fmt.Sprintf("../rootfs-%s.tar.gz", runtime.GOARCH), "-C", bundleDir)
_, err = untarCmd.CombinedOutput()
if err != nil {
os.RemoveAll(bundleDir)
Expand All @@ -58,7 +59,7 @@ func runtimeInsideValidate(g *generate.Generator) error {
if err != nil {
return err
}
r, err := NewRuntime(runtime, bundleDir)
r, err := NewRuntime(runtimeCommand, bundleDir)
if err != nil {
os.RemoveAll(bundleDir)
return err
Expand Down Expand Up @@ -102,7 +103,7 @@ func TestValidateCreate(t *testing.T) {
bundleDir, err := prepareBundle()
assert.Nil(t, err)

r, err := NewRuntime(runtime, bundleDir)
r, err := NewRuntime(runtimeCommand, bundleDir)
assert.Nil(t, err)
defer r.Clean(true)

Expand Down