Skip to content

Commit deb0332

Browse files
committed
arm64 support
1 parent e4f37e8 commit deb0332

11 files changed

+331
-37
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
build
2+
.kvm-images
23
.installed-requirements
4+
.installed-qemu
35
namibase/nami-linux-x64.tar.gz

.travis.yml

Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,77 @@
11
language: bash
2-
sudo: required
3-
script: bash shellcheck && sudo bash buildall
4-
dist: xenial
2+
dist: focal
3+
virt: vm
4+
group: edge
5+
os: linux
56
services:
67
- docker
7-
before_install:
8-
- docker version
9-
# Fix for Ubuntu Xenial apt-daily.service triggering
10-
# https://unix.stackexchange.com/questions/315502/how-to-disable-apt-daily-service-on-ubuntu-cloud-vm-image
11-
- |
12-
while sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1; do
13-
sleep 1
14-
done
15-
- sudo apt-get -qq update
16-
- sudo apt-get install -y debian-archive-keyring debootstrap shellcheck
17-
deploy:
18-
provider: script
19-
script: bash pushall
20-
skip_cleanup: true
21-
on:
22-
branch: master
8+
9+
.build_job: &build_job
10+
stage: build
11+
before_install:
12+
- docker version
13+
# Fix for Ubuntu Xenial apt-daily.service triggering
14+
# https://unix.stackexchange.com/questions/315502/how-to-disable-apt-daily-service-on-ubuntu-cloud-vm-image
15+
- |
16+
while sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1; do
17+
sleep 1
18+
done
19+
- sudo rm /usr/local/bin/jq
20+
install:
21+
- sudo make .installed-requirements
22+
script: sudo bash buildone $DIST $PLATFORM
23+
after_success:
24+
- 'if [[ "$TRAVIS_BRANCH" == "master" && "$DIST" == "buster" ]] ; then sudo docker tag "bitnami/minideb:$DIST-$PLATFORM" "$BASENAME:latest-$PLATFORM" ; fi'
25+
- 'if [[ "$TRAVIS_BRANCH" == "master" ]] ; then sudo bash pushone $DIST $PLATFORM ; fi'
26+
- 'if [[ "$TRAVIS_BRANCH" == "master" && "$DIST" == "buster" ]] ; then sudo bash pushone latest $PLATFORM ; fi'
27+
28+
jobs:
29+
include:
30+
- stage: shellcheck
31+
install:
32+
- sudo apt-get -qq update
33+
- sudo apt-get install -y shellcheck
34+
script: bash shellcheck
35+
- <<: *build_job
36+
arch: amd64
37+
env:
38+
- DIST=jessie PLATFORM=amd64
39+
- <<: *build_job
40+
arch: amd64
41+
env:
42+
- DIST=stretch PLATFORM=amd64
43+
- <<: *build_job
44+
arch: amd64
45+
env:
46+
- DIST=buster PLATFORM=amd64
47+
- <<: *build_job
48+
arch: arm64-graviton2
49+
env:
50+
- DIST=stretch PLATFORM=arm64
51+
- <<: *build_job
52+
arch: arm64-graviton2
53+
env:
54+
- DIST=buster PLATFORM=arm64
55+
- stage: deploy
56+
if: branch = master AND type = push
57+
env:
58+
- DISTS="stretch buster latest"
59+
before_install: mkdir $HOME/.docker
60+
install: 'echo "{ \"experimental\": \"enabled\" }" > $HOME/.docker/config.json'
61+
script:
62+
- |
63+
if [ -n "${DOCKER_PASSWORD:-}" ]; then
64+
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
65+
fi
66+
67+
# Create and merge a PR to update minideb-extras
68+
CIRCLE_CI_FUNCTIONS_URL=${CIRCLE_CI_FUNCTIONS_URL:-https://raw.githubusercontent.com/bitnami/test-infra/master/circle/functions}
69+
source <(curl -sSL "$CIRCLE_CI_FUNCTIONS_URL")
70+
for DIST in $DISTS; do
71+
sudo docker manifest create bitnami/minideb:$DIST bitnami/minideb:$DIST-amd64 bitnami/minideb:$DIST-arm64
72+
sudo docker manifest push bitnami/minideb:$DIST
73+
74+
# Use '.RepoDigests 0' for getting Dockerhub repo digest as it was the first pushed
75+
DIST_REPO_DIGEST=$(docker image inspect --format '{{index .RepoDigests 0}}' "${BASENAME}:${DIST}")
76+
update_minideb_derived "https://github.com/bitnami/minideb-runtimes" "$DIST" "$DIST_REPO_DIGEST"
77+
done

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ clean:
1212
clobber: clean
1313
@${RM} .installed-requirements
1414

15+
.installed-qemu:
16+
@echo "Installing QEMU and required packages..."
17+
@./install-qemu.sh
18+
@touch $@
19+
1520
.installed-requirements:
1621
@echo "Installing required packages..."
1722
@./pre-build.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ We provide a Makefile to help you build Minideb locally. It should be run on a D
5353
$ sudo make
5454
```
5555
56-
To build an individual release (stretch, jessie or unstable)
56+
To build an individual release (stretch, buster or unstable)
5757
```
5858
$ sudo make stretch
5959
```

buildall

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,32 @@ set -e
66
set -u
77
set -o pipefail
88

9+
arch=${1:-"amd64 arm64"}
10+
911
dist="jessie
1012
stretch
1113
buster
1214
"
1315
dist_with_snapshot="buster"
1416

15-
for i in $dist; do
16-
./buildone "$i"
17+
for a in $arch; do
18+
for i in $dist; do
19+
if [[ "$a" != "amd64" && "$i" == "jessie" ]]; then
20+
continue
21+
fi
22+
23+
./buildone "$i" "$a"
24+
done
1725
done
1826

1927
snapshot_id=$(./snapshot_id)
2028
if [ -n "$snapshot_id" ]; then
29+
for a in $arch; do
2130
for i in $dist_with_snapshot; do
22-
./buildone_snapshot "$i" "$snapshot_id"
31+
./buildone_snapshot "$i" "$snapshot_id" "$a"
2332
done
2433

25-
mkdir -p build
26-
echo "$snapshot_id" > build/snapshot_id
34+
mkdir -p "build/$a"
35+
echo "$snapshot_id" > "build/$a/snapshot_id"
36+
done
2737
fi

buildone

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ log() {
4343

4444
build() {
4545
DIST=$1
46+
PLATFORM=${2:-amd64}
4647

47-
debian_snapshot_id=${2:-}
48+
debian_snapshot_id=${3:-}
4849
if [ -n "$debian_snapshot_id" ]; then
4950
TAG="${DIST}-snapshot-${debian_snapshot_id}"
5051
else
@@ -64,7 +65,7 @@ build() {
6465
log "Building $BASENAME:$TAG"
6566
log "============================================"
6667
./mkimage "build/$TAG.tar" "$DIST" "${debian_snapshot_id:-}"
67-
built_image_id=$(./import "build/$TAG.tar" "$target_ts")
68+
built_image_id=$(./import "build/$TAG.tar" "$target_ts" "$PLATFORM")
6869
log "============================================"
6970
log "Running tests for $BASENAME:$TAG"
7071
log "============================================"
@@ -73,7 +74,7 @@ build() {
7374
log "Rebuilding $BASENAME:$TAG to test reproducibility"
7475
log "============================================"
7576
./mkimage "build/${TAG}-repro.tar" "$DIST" "${debian_snapshot_id:-}"
76-
repro_image_id=$(./import "build/${TAG}-repro.tar" "$target_ts")
77+
repro_image_id=$(./import "build/${TAG}-repro.tar" "$target_ts" "$PLATFORM")
7778
if [ "$repro_image_id" != "$built_image_id" ]; then
7879
log "$BASENAME:$TAG differs after a rebuild. Examine $built_image_id and $repro_image_id"
7980
log "to find the differences and fix the build to be reproducible again."
@@ -89,19 +90,19 @@ build() {
8990
./dockerdiff "$pulled_image_id" "$built_image_id" || true
9091
# Re-import with the current timestamp so that the image shows
9192
# as new
92-
built_image_id="$(./import "build/$TAG.tar" "$current_ts")"
93+
built_image_id="$(./import "build/$TAG.tar" "$current_ts" "$PLATFORM")"
9394
else
9495
log "Image didn't change"
9596
return
9697
fi
9798
fi
98-
docker tag "$built_image_id" "$BASENAME:$TAG"
99-
log "Tagged $built_image_id as $BASENAME:$TAG"
99+
docker tag "$built_image_id" "$BASENAME:$TAG-$PLATFORM"
100+
log "Tagged $built_image_id as $BASENAME:$TAG-$PLATFORM"
100101
}
101102

102103
if [ -z "$1" ]; then
103104
echo "You must specify the dist to build"
104105
exit 1
105106
fi
106107

107-
build "${1}" "${2:-}"
108+
build "$@"

buildone_snapshot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ set -o pipefail
66

77
dist=${1:?dist arg is required}
88
snapshot_id=${2:-$(./snapshot_id)}
9+
platform=${3:-amd64}
910

10-
./buildone "$dist" "$snapshot_id"
11+
./buildone "$dist" "$platform" "$snapshot_id"

import

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ set -e
1212
set -u
1313
set -o pipefail
1414

15-
CONF_TEMPLATE='{"architecture":"amd64","comment":"from Bitnami with love","config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":["/bin/bash"],"Image":"","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null},"container_config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":null,"Image":"","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null},"created":"%TIMESTAMP%","docker_version":"1.13.0","history":[{"created":"%TIMESTAMP%","comment":"from Bitnami with love"}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:%LAYERSUM%"]}}'
16-
MANIFEST_TEMPLATE='[{"Config":"%CONF_SHA%.json","RepoTags":null,"Layers":["%LAYERSUM%/layer.tar"]}]'
17-
1815
SOURCE=${1:?Specify the tarball to import}
1916
TIMESTAMP=${2:?Specify the timestamp to use}
17+
PLATFORM=${3:?Specify the target platform}
18+
19+
CONF_TEMPLATE='{"architecture":"%PLATFORM%","comment":"from Bitnami with love","config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":["/bin/bash"],"Image":"","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null},"container_config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":null,"Image":"","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null},"created":"%TIMESTAMP%","docker_version":"1.13.0","history":[{"created":"%TIMESTAMP%","comment":"from Bitnami with love"}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:%LAYERSUM%"]}}'
20+
MANIFEST_TEMPLATE='[{"Config":"%CONF_SHA%.json","RepoTags":null,"Layers":["%LAYERSUM%/layer.tar"]}]'
2021

2122
import() {
2223
local TDIR="$(mktemp -d)"
2324
local LAYERSUM="$(sha256sum $SOURCE | awk '{print $1}')"
2425
mkdir $TDIR/$LAYERSUM
2526
cp $SOURCE $TDIR/$LAYERSUM/layer.tar
2627
echo -n '1.0' > $TDIR/$LAYERSUM/VERSION
27-
local CONF="$(echo -n "$CONF_TEMPLATE" | sed -e "s/%TIMESTAMP%/$TIMESTAMP/g" -e "s/%LAYERSUM%/$LAYERSUM/g")"
28+
local CONF="$(echo -n "$CONF_TEMPLATE" | sed -e "s/%PLATFORM%/$PLATFORM/g" -e "s/%TIMESTAMP%/$TIMESTAMP/g" -e "s/%LAYERSUM%/$LAYERSUM/g")"
2829
local CONF_SHA="$(echo -n "$CONF" | sha256sum | awk '{print $1}')"
2930
echo -n "$CONF" > "$TDIR/${CONF_SHA}.json"
3031
local MANIFEST="$(echo -n "$MANIFEST_TEMPLATE" | sed -e "s/%CONF_SHA%/$CONF_SHA/g" -e "s/%LAYERSUM%/$LAYERSUM/g")"

install-qemu.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
do_sudo() {
6+
if [[ "0" == "$(id --user)" ]]; then
7+
"$@"
8+
else
9+
sudo "$@"
10+
fi
11+
}
12+
13+
while do_sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1; do
14+
sleep 1
15+
done
16+
17+
do_sudo apt-get update
18+
do_sudo apt-get install -y qemu-kvm libvirt-bin qemu-utils genisoimage virtinst curl rsync qemu-system-x86 qemu-system-arm cloud-image-utils
19+

pushone

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
DIST=${1:?Specify the distrubution name}
8+
PLATFORM=${2:-amd64}
9+
10+
BASENAME=bitnami/minideb
11+
GCR_BASENAME=gcr.io/bitnami-containers/minideb
12+
QUAY_BASENAME=quay.io/bitnami/minideb
13+
14+
if [ -n "${DOCKER_PASSWORD:-}" ]; then
15+
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
16+
fi
17+
18+
if [ -n "${QUAY_PASSWORD:-}" ]; then
19+
docker login -u "$QUAY_USERNAME" -p "$QUAY_PASSWORD" quay.io
20+
fi
21+
22+
if [ -n "${GCR_KEY:-}" ]; then
23+
gcloud auth activate-service-account "$GCR_EMAIL" --key-file <(echo "$GCR_KEY")
24+
fi
25+
26+
ENABLE_DOCKER_CONTENT_TRUST=0
27+
if [ -n "${DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE:-}" ] && [ -n "${DOCKER_CONTENT_TRUST_REPOSITORY_KEY:-}" ]; then
28+
tmpdir=$(mktemp -d)
29+
(cd "${tmpdir}" && bash -c 'echo -n "${DOCKER_CONTENT_TRUST_REPOSITORY_KEY}" | base64 -d > key')
30+
chmod 400 "${tmpdir}/key"
31+
docker trust key load "${tmpdir}/key"
32+
rm -rf "${tmpdir}"
33+
export ENABLE_DOCKER_CONTENT_TRUST=1
34+
fi
35+
36+
push() {
37+
local dist="$1"
38+
DOCKER_CONTENT_TRUST=${ENABLE_DOCKER_CONTENT_TRUST} docker push "${BASENAME}:${dist}"
39+
docker push "${QUAY_BASENAME}:${dist}"
40+
gcloud docker -- push "${GCR_BASENAME}:${dist}"
41+
}
42+
43+
docker tag "${BASENAME}:${DIST}" "${QUAY_BASENAME}:${DIST}-${PLATFORM}"
44+
docker tag "${BASENAME}:${DIST}" "${GCR_BASENAME}:${DIST}-${PLATFORM}"
45+
push "$DIST-${PLATFORM}"
46+

0 commit comments

Comments
 (0)