Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

Commit 907046b

Browse files
committed
initial commit
0 parents  commit 907046b

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# rkt-builder
2+
3+
This repository holds scripts and releases for the rkt-in-rkt builder ACI.
4+
5+
## Usage
6+
7+
### Building a new rkt-in-rkt builder ACI
8+
9+
To build the builder ACI image, first update the version variable `IMG_VERSION` in `acbuild.sh`, and execute:
10+
11+
$ sudo ./acbuild.sh
12+
13+
The rkt project key must be used to sign the generated image. `$RKTSUBKEYID` is the key ID of the rkt Yubikey. Connect the key and run `gpg2 --card-status` to get the ID.
14+
15+
The public key for GPG signing can be found at [CoreOS Application Signing Key](https://coreos.com/security/app-signing-key) and is assumed as trusted.
16+
17+
$ gpg2 -u $RKTSUBKEYID'!' --armor --output rkt-builder.aci.asc --detach-sign rkt-builder.aci
18+
19+
Commit any changes to `acbuild.sh`, and push them.
20+
21+
Add a signed tag:
22+
23+
$ GIT_COMMITTER_NAME="CoreOS Application Signing Key" GIT_COMMITTER_EMAIL="security@coreos.com" git tag -u $RKTSUBKEYID'!' -s v1.0.0 -m "rkt-builder v1.0.0"`
24+
25+
Push the tag to GitHub:
26+
27+
$ git push --tags
28+
29+
### Building rkt-in-rkt
30+
31+
$ git clone github.com/coreos/rkt
32+
$ cd rkt
33+
$ sudo rkt run \
34+
--volume src-dir,kind=host,source="$(pwd)" \
35+
--volume build-dir,kind=host,source="$(pwd)/release-build" \
36+
--interactive \
37+
coreos.com/rkt/builder:v1.0.0
38+
39+
## Overview
40+
41+
This repository consists of two scripts:
42+
43+
- `acbuild.sh`: This script builds the rkt-in-rkt builder ACI.
44+
- `build.sh`: This script is added to the rkt-in-rkt builder ACI as `/scripts/build.sh`, and is defined as the entrypoint.
45+
46+
The built rkt-in-rkt ACI declares the following volumes:
47+
48+
- `src-dir`: Points to the directory holding the rkt source code.
49+
- `build-dir`: Points to the output directory where the build artifacts are being placed.

acbuild.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
if [[ $EUID -ne 0 ]]; then
5+
echo "This script must be run as root" 1>&2
6+
exit 1
7+
fi
8+
9+
IMG_NAME="coreos.com/rkt/builder"
10+
VERSION="1.0.0"
11+
ARCH=amd64
12+
OS=linux
13+
14+
FLAGS=${FLAGS:-""}
15+
ACI_FILE=rkt-builder-"${VERSION}"-"${OS}"-"${ARCH}".aci
16+
BUILDDIR=/opt/build-rkt
17+
SRC_DIR=/opt/rkt
18+
ACI_GOPATH=/go
19+
20+
DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev libsystemd-dev gnupg"
21+
22+
function acbuildend() {
23+
export EXIT=$?;
24+
acbuild --debug end && rm -rf rootfs && exit $EXIT;
25+
}
26+
27+
echo "Generating debian sid tree"
28+
29+
mkdir rootfs
30+
debootstrap --force-check-gpg --variant=minbase --components=main --include="${DEBIAN_SID_DEPS}" sid rootfs http://httpredir.debian.org/debian/
31+
rm -rf rootfs/var/cache/apt/archives/*
32+
33+
echo "Version: v${VERSION}"
34+
echo "Building ${ACI_FILE}"
35+
36+
acbuild begin ./rootfs
37+
trap acbuildend EXIT
38+
39+
acbuild $FLAGS set-name $IMG_NAME
40+
acbuild $FLAGS label add version v$VERSION
41+
acbuild $FLAGS set-user 0
42+
acbuild $FLAGS set-group 0
43+
acbuild $FLAGS environment add OS_VERSION sid
44+
acbuild $FLAGS environment add GOPATH $ACI_GOPATH
45+
acbuild $FLAGS environment add BUILDDIR $BUILDDIR
46+
acbuild $FLAGS environment add SRC_DIR $SRC_DIR
47+
acbuild $FLAGS mount add build-dir $BUILDDIR
48+
acbuild $FLAGS mount add src-dir $SRC_DIR
49+
acbuild $FLAGS set-working-dir $SRC_DIR
50+
acbuild $FLAGS copy-to-dir build.sh /scripts
51+
acbuild $FLAGS run /bin/mkdir -- -p $ACI_GOPATH
52+
acbuild $FLAGS run /bin/sh -- -c "GOPATH=${ACI_GOPATH} go get github.com/appc/spec/actool"
53+
acbuild $FLAGS set-exec /bin/bash /scripts/build.sh
54+
acbuild write --overwrite $ACI_FILE

build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
./autogen.sh
6+
./configure \
7+
--enable-tpm=no \
8+
--with-stage1-default-images-directory=/usr/lib/rkt/stage1-images \
9+
--with-stage1-default-location=/usr/lib/rkt/stage1-images/stage1-coreos.aci
10+
make manpages
11+
make bash-completion
12+
make -j4

0 commit comments

Comments
 (0)