Skip to content

Commit 7f37c63

Browse files
committed
workflows: Add weekly Linux deb build
Signed-off-by: Loïc Minier <[email protected]>
1 parent 3d836d5 commit 7f37c63

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

.github/workflows/linux.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Build Linux kernel deb
2+
3+
on:
4+
# run weekly on Monday at 8:30am
5+
schedule:
6+
- cron: '30 8 * * 1'
7+
# allow manual runs
8+
workflow_dispatch:
9+
10+
# only need permission to read repository; implicitely set all other
11+
# permissions to none
12+
permissions:
13+
contents: read
14+
15+
env:
16+
# where results will be posted/hosted
17+
FILESERVER_URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app
18+
# github runs are only unique per repository and may also be re-run; create a
19+
# build id for the current run
20+
BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
21+
22+
# cancel in progress builds for this workflow triggered by the same ref
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
build-linux-deb:
29+
# for cross-builds
30+
runs-on: [self-hosted, x86]
31+
# alternative for native builds, but overkill to do both
32+
#runs-on: [self-hosted, arm64, debbuilder]
33+
container:
34+
image: debian:trixie
35+
volumes:
36+
- /srv/gh-runners/quic-yocto/builds:/fileserver-builds
37+
- /srv/gh-runners/quic-yocto/downloads:/fileserver-downloads
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
43+
# make sure we have latest packages first, to get latest fixes, to avoid
44+
# an automated update while we're building, and to prevent version skews
45+
- name: Update OS packages
46+
run: |
47+
set -ux
48+
apt update
49+
apt -y upgrade
50+
apt -y full-upgrade
51+
52+
- name: Build Linux kernel deb
53+
run: |
54+
set -ux
55+
# download arm64 package lists to install cross build-dependencies
56+
if [ "$(dpkg --print-architecture)" != arm64 ]; then
57+
dpkg --add-architecture arm64
58+
apt update
59+
fi
60+
# install build-dependencies; TODO: --no-install-recommends
61+
apt -y install git crossbuild-essential-arm64 make flex bison bc \
62+
libelf-dev libssl-dev libssl-dev:arm64 dpkg-dev \
63+
debhelper-compat kmod python3 rsync coreutils
64+
scripts/build-linux-deb.sh
65+
66+
- name: Upload results to fileserver
67+
run: |
68+
set -ux
69+
# dcmd from devscripts will be used to parse .changes file
70+
apt -y install --no-install-recommends devscripts
71+
# curl will be used to talk to fileserver; should be installed by
72+
# default
73+
apt -y install curl
74+
# copy to fileserver builds and downloads directories
75+
for dir in "/fileserver-builds/${BUILD_ID}" \
76+
"/fileserver-downloads/qcom-deb-images/linux-deb-latest"; do
77+
mkdir -vp "${dir}"
78+
cp -av `dcmd *.changes` "${dir}"
79+
done
80+
# perhaps help NFS sync
81+
sync
82+
# instruct fileserver to publish this directory
83+
url="${FILESERVER_URL}/${BUILD_ID}/"
84+
curl -X POST -H 'Accept: text/event-stream' "${url}"

scripts/build-linux-deb.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
# git repo/branch to use
6+
GIT_REPO="https://github.com/torvalds/linux"
7+
GIT_BRANCH="master"
8+
# base config to use
9+
CONFIG="defconfig"
10+
# extra configs to set
11+
# systemd-boot won't implement support for compressed images (zImage); see
12+
# https://github.com/systemd/systemd/issues/23788
13+
EXTRA_CONFIGS="CONFIG_EFI_ZBOOT=y"
14+
15+
log_i() {
16+
echo "I: $*" >&2
17+
}
18+
19+
fatal() {
20+
echo "F: $*" >&2
21+
exit 1
22+
}
23+
24+
# needed to clone repository
25+
packages="git"
26+
# will pull gcc-aarch64-linux-gnu; should pull a native compiler on arm64 and
27+
# a cross-compiler on other architectures
28+
packages="${packages} crossbuild-essential-arm64"
29+
# linux build-dependencies
30+
packages="${packages} make flex bison bc libelf-dev libssl-dev libssl-dev:arm64"
31+
# linux build-dependencies for debs
32+
packages="${packages} dpkg-dev debhelper-compat kmod python3 rsync"
33+
# for nproc
34+
packages="${packages} coreutils"
35+
36+
log_i "Checking build-dependencies ($packages)"
37+
missing=""
38+
for pkg in ${packages}; do
39+
# check if package with this name is installed
40+
if dpkg -l "${pkg}" 2>&1 | grep -q "^ii ${pkg}"; then
41+
continue
42+
fi
43+
# otherwise, check if it's a virtual package and if some package providing
44+
# it is installed
45+
providers="$(apt-cache showpkg "${pkg}" |
46+
sed -e '1,/^Reverse Provides: *$/ d' -e 's/ .*$//' |
47+
sort -u)"
48+
provider_found="no"
49+
for provider in ${providers}; do
50+
if dpkg -l "${provider}" 2>&1 | grep -q "^ii ${provider}"; then
51+
provider_found="yes"
52+
break
53+
fi
54+
done
55+
if [ "${provider_found}" = yes ]; then
56+
continue
57+
fi
58+
missing="${missing} ${pkg}"
59+
done
60+
if [ -n "${missing}" ]; then
61+
fatal "Missing build-dependencies: ${missing}"
62+
fi
63+
64+
log_i "Cloning Linux (${GIT_REPO}:${GIT_BRANCH})"
65+
git clone --depth=1 --branch "${GIT_BRANCH}" "${GIT_REPO}" linux
66+
67+
cd linux
68+
69+
log_i "Configuring Linux (${CONFIG}, ${EXTRA_CONFIGS})"
70+
rm -vf kernel/configs/local.config
71+
touch kernel/configs/local.config
72+
for c in ${EXTRA_CONFIGS}; do
73+
echo "${c}" >>kernel/configs/local.config
74+
done
75+
make ARCH=arm64 "${CONFIG}" local.config
76+
77+
log_i "Building Linux deb"
78+
# TODO: build other packages?
79+
make -j$(nproc) \
80+
ARCH=arm64 DEB_HOST_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
81+
bindeb-pkg
82+

0 commit comments

Comments
 (0)