Skip to content

Commit c09e400

Browse files
authored
Merge pull request #48 from threefoldtech/development-zos-v2-autobuild
Autobuild kernel via GitHub action and freeze some versions
2 parents 78840d1 + 7a53901 commit c09e400

File tree

13 files changed

+198
-111
lines changed

13 files changed

+198
-111
lines changed

.github/workflows/kernel.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Kernel
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
tags-ignore:
7+
- v*
8+
9+
jobs:
10+
kernel:
11+
name: 'Zero-OS Kernel Image'
12+
runs-on: ubuntu-18.04
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v1
16+
17+
- name: Extract branch name
18+
shell: bash
19+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
20+
id: runbranch
21+
22+
- name: 'Install: go'
23+
uses: actions/setup-go@v1
24+
with:
25+
go-version: 1.14
26+
id: go
27+
28+
- name: 'Install: rust'
29+
uses: actions-rs/toolchain@v1
30+
with:
31+
toolchain: stable
32+
target: x86_64-unknown-linux-musl
33+
default: true
34+
35+
- name: 'Install: requirements'
36+
run: |
37+
sudo bash ./autobuild/tf-build-deps-clean.sh
38+
39+
- name: 'Fetch: sources'
40+
run: |
41+
export INTERACTIVE="false"
42+
sudo --preserve-env=PATH bash initramfs.sh --download
43+
44+
- name: 'Fetch: extensions'
45+
run: |
46+
cd extensions
47+
git clone https://github.com/zero-os/initramfs-gig
48+
49+
- name: 'Build: busybox'
50+
run: |
51+
sudo --preserve-env=PATH bash initramfs.sh --busybox
52+
53+
- name: 'Build: userland'
54+
run: |
55+
sudo --preserve-env=PATH bash initramfs.sh --tools
56+
57+
- name: 'Build: extensions'
58+
run: |
59+
sudo --preserve-env=PATH bash initramfs.sh --extensions
60+
61+
- name: 'Build: cores'
62+
run: |
63+
sudo --preserve-env=PATH bash initramfs.sh --cores
64+
65+
- name: 'Build: kernel'
66+
run: |
67+
sudo --preserve-env=PATH bash initramfs.sh --kernel --modules
68+
69+
- name: 'Upload: kernel'
70+
env:
71+
BOOTSTRAP_TOKEN: ${{ secrets.BOOTSTRAP_TOKEN }}
72+
IMAGE_BRANCH: ${{ steps.runbranch.outputs.branch }}
73+
run: |
74+
bash ./autobuild/tf-build-upload.sh
75+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,4 @@ Here is what we changed:
249249
# Repository Owner
250250
- [Maxime Daniel](https://github.com/maxux), Telegram: [@maxux](http://t.me/maxux)
251251

252+

autobuild/tf-build-deps-clean.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# install dependencies for building
4+
apt-get update
5+
apt-get install -y asciidoc xmlto --no-install-recommends
6+
7+
# toolchain dependencies
8+
deps=(pkg-config make m4 autoconf)
9+
10+
# system tools and libs
11+
deps+=(libssl-dev dnsmasq git curl bc wget)
12+
13+
# fuse
14+
deps+=(libfuse-dev)
15+
16+
# storage and filesystem
17+
deps+=(e2fslibs-dev libblkid-dev uuid-dev libattr1-dev)
18+
19+
# virtualization
20+
deps+=(libvirt-dev libdevmapper-dev)
21+
22+
# dirty list, needs to be documented
23+
deps+=(xz-utils lbzip2 libtool gettext uuid-dev)
24+
deps+=(libncurses5-dev libreadline-dev zlib1g-dev libacl1-dev)
25+
deps+=(liblzo2-dev libbison-dev flex)
26+
deps+=(libglib2.0-dev libfuse-dev libxml2-dev libpciaccess-dev)
27+
deps+=(libyajl-dev liblz4-dev libbz2-dev)
28+
deps+=(libcap-dev autopoint comerr-dev)
29+
30+
# udev and modules
31+
deps+=(gperf libelf-dev libkmod-dev liblzma-dev kmod)
32+
33+
# nftables
34+
deps+=(libnl-3-dev libnl-route-3-dev libmnl-dev xtables-addons-source)
35+
36+
# zflist
37+
deps+=(libhiredis-dev libpixman-1-dev libb2-dev libsqlite3-dev libtar-dev libjansson-dev libsnappy-dev)
38+
39+
# libwebsockets
40+
deps+=(cmake xxd)
41+
42+
# containerd
43+
deps+=(libseccomp-dev)
44+
45+
# install musl
46+
deps+=(musl musl-tools)
47+
48+
apt-get install -y ${deps[@]}

autobuild/tf-build-upload.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd staging
5+
6+
kernel=zero-os-${IMAGE_BRANCH}-generic-${GITHUB_SHA:0:10}.efi
7+
linkname=zero-os-${IMAGE_BRANCH}-generic.efi
8+
9+
echo "[+] kernel: ${kernel}"
10+
echo "[+] branch: ${linkname}"
11+
12+
cp vmlinuz.efi "${kernel}"
13+
14+
curl -b "token=${BOOTSTRAP_TOKEN}" -X POST -F "kernel=@${kernel}" "https://bootstrap.grid.tf/api/kernel"
15+
curl -b "token=${BOOTSTRAP_TOKEN}" "https://bootstrap.grid.tf/api/symlink/${linkname}/${kernel}"

autobuild/tf-build.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22
set -e
33

4-
if [ "$1" == "" ] || [ "$2" == "" ]; then
5-
echo "[-] missing remote version or repository name"
6-
exit 1
7-
fi
4+
#if [ "$1" == "" ] || [ "$2" == "" ]; then
5+
# echo "[-] missing remote version or repository name"
6+
# exit 1
7+
#fi
88

99
# preparing environment
1010
mkdir -p /target
@@ -15,8 +15,8 @@ rm -rf /target/*
1515
. $(dirname $0)/tf-build-settings.sh
1616

1717
# adding extensions (fallback to master if branch not found)
18-
cd "/$2/extensions"
19-
git clone -b "$1" https://github.com/zero-os/initramfs-gig || git clone https://github.com/zero-os/initramfs-gig
18+
#cd "/$2/extensions"
19+
#git clone -b "$1" https://github.com/zero-os/initramfs-gig || git clone https://github.com/zero-os/initramfs-gig
2020

2121
# checkings arguments
2222
arguments="--all --compact "
@@ -29,9 +29,10 @@ fi
2929
export INTERACTIVE="false"
3030

3131
# start the build
32-
cd "/$2"
32+
# cd "/$2"
33+
cd $(dirname $0)/..
3334
bash initramfs.sh ${arguments}
3435

3536
# installing kernel to remote directory
3637
echo "[+] moving kernel to /target"
37-
cp -v "/$2/staging/vmlinuz.efi" /target/
38+
# cp -v "/$2/staging/vmlinuz.efi" /target/

config/etc/zinit/init/sshd-setup.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/ash
22
if [ -f /etc/ssh/ssh_host_rsa_key ]; then
3-
# nothing to do, hackish way
4-
sleep 10
3+
# ensure existing file permissions
4+
chown root:root /etc/ssh/ssh_host_*
5+
chmod 600 /etc/ssh/ssh_host_*
56
exit 0
67
fi
78

initramfs.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,20 @@ prepare() {
174174
fi
175175

176176
if [ -z $GOPATH ]; then
177-
echo "[-] gopath not defined"
178-
exit 1
177+
if command -v go > /dev/null; then
178+
export GOPATH=$(go env GOPATH)
179+
else
180+
echo "[-] variable GOPATH not defined"
181+
exit 1
182+
fi
179183
fi
180184

185+
gover=$(go version)
186+
echo "[+] go version: ${gover}"
187+
188+
cargover=$(cargo version)
189+
echo "[+] cargo version: ${cargover}"
190+
181191
echo "[+] setting up local system"
182192
echo "[+] building mode: ${BUILDMODE}"
183193
echo "[+] ${modules} submodules loaded"
@@ -693,7 +703,6 @@ main() {
693703
build_wireguard
694704
build_dhcpcd
695705
build_bcache
696-
build_runc
697706
build_tcpdump
698707
build_rscoreutils
699708
build_firmware
@@ -719,13 +728,6 @@ main() {
719728
if [[ $DO_ALL == 1 ]] || [[ $DO_CORES == 1 ]]; then
720729
build_zinit
721730
build_zfs
722-
723-
# force re-download if we specify --cores
724-
if [[ $DO_CORES == 1 ]]; then
725-
download_modules
726-
prepare_modules
727-
fi
728-
729731
build_modules
730732
fi
731733

packages/0-fs.sh

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
1-
TF_HOME="${GOPATH}/src/github.com/threefoldtech"
2-
3-
ZFS_REPOSITORY="https://github.com/threefoldtech/0-fs"
4-
ZFS_VERSION="development"
1+
ZFS_VERSION="2.0.6"
2+
ZFS_CHECKSUM="06368fd114642373c1bb024bad2d419e"
3+
ZFS_LINK="https://github.com/threefoldtech/0-fs/archive/v${ZFS_VERSION}.tar.gz"
54

65
download_zfs() {
7-
download_git ${ZFS_REPOSITORY} ${ZFS_VERSION}
6+
download_file $ZFS_LINK $ZFS_CHECKSUM 0-fs-${ZFS_VERSION}.tar.gz
87
}
98

109
extract_zfs() {
11-
event "refreshing" "0-fs-${ZFS_VERSION}"
12-
mkdir -p ${TF_HOME}
13-
rm -rf ${TF_HOME}/0-fs
14-
cp -a ${DISTFILES}/0-fs ${TF_HOME}/
10+
if [ ! -d "0-fs-${ZFS_VERSION}" ]; then
11+
echo "[+] extracting: 0-fs-${ZFS_VERSION}"
12+
tar -xf ${DISTFILES}/0-fs-${ZFS_VERSION}.tar.gz -C .
13+
fi
1514
}
1615

1716
prepare_zfs() {
18-
echo "[+] loading source code: 0-fs"
17+
echo "[+] preparing 0-fs"
1918
}
2019

2120
compile_zfs() {
2221
echo "[+] compiling 0-fs"
23-
pushd 0-fs
2422
GO111MODULE=on make
25-
popd
2623
}
2724

2825
install_zfs() {
2926
echo "[+] copying binaries"
30-
pushd 0-fs
3127
# the binary name is still called g8ufs
3228
cp -av g8ufs "${ROOTDIR}/sbin/"
33-
popd
3429
}
3530

3631
build_zfs() {
37-
mkdir -p $TF_HOME
38-
pushd $TF_HOME
32+
pushd "${WORKDIR}/0-fs-${ZFS_VERSION}"
3933

4034
prepare_zfs
4135
compile_zfs

packages/libjsonc-musl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ download_jsonc_musl() {
88
}
99

1010
extract_jsonc_musl() {
11-
if [ ! -d "${JSONC_MUSL_PKGNAME}-${JSONC_MUSL_VERSION}" ]; then
11+
if [ ! -d "${JSONC_MUSL_PKGNAME}-json-c-${JSONC_MUSL_VERSION}" ]; then
1212
echo "[+] extracting: ${JSONC_MUSL_PKGNAME}-${JSONC_MUSL_PKGNAME}-${JSONC_MUSL_VERSION}"
1313
tar -xf ${DISTFILES}/${JSONC_MUSL_PKGNAME}-${JSONC_MUSL_VERSION}.tar.gz -C .
1414
fi

packages/modules.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
MODULES_REPOSITORY="https://github.com/threefoldtech/zos"
2-
MODULES_BRANCH="master"
3-
MODULES_TAG=""
4-
5-
TFT_SRC=$GOPATH/src/github.com/threefoldtech
1+
MODULES_VERSION="0.4.3"
2+
MODULES_CHECKSUM="99fd8573891897543db73673b6f2016d"
3+
MODULES_LINK="https://github.com/threefoldtech/zos/archive/v${MODULES_VERSION}.tar.gz"
64

75
download_modules() {
8-
mkdir -p $TFT_SRC
9-
pushd $TFT_SRC
10-
download_git $MODULES_REPOSITORY $MODULES_BRANCH $MODULES_TAG
11-
popd
6+
download_file $MODULES_LINK $MODULES_CHECKSUM zos-${MODULES_VERSION}.tar.gz
7+
}
8+
9+
extract_modules() {
10+
if [ ! -d "zos-${MODULES_VERSION}" ]; then
11+
echo "[+] extracting: zos-${MODULES_VERSION}"
12+
tar -xf ${DISTFILES}/zos-${MODULES_VERSION}.tar.gz -C .
13+
fi
1214
}
1315

1416
prepare_modules() {
1517
echo "[+] prepare modules"
1618
}
1719

1820
install_modules() {
19-
echo "[+] copying binaries"
21+
echo "[+] building zos bootstrap"
2022
pushd bootstrap
2123
make install GO111MODULE=on ROOT=${ROOTDIR}
2224
popd
2325
}
2426

2527
build_modules() {
26-
pushd $TFT_SRC/zos
28+
pushd ${WORKDIR}/zos-${MODULES_VERSION}
2729

2830
prepare_modules
2931
install_modules
@@ -33,6 +35,7 @@ build_modules() {
3335

3436
registrar_modules() {
3537
DOWNLOADERS+=(download_modules)
38+
EXTRACTORS+=(extract_modules)
3639
}
3740

3841
registrar_modules

0 commit comments

Comments
 (0)