Skip to content

Commit d0f174e

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

File tree

2 files changed

+176
-0
lines changed

2 files changed

+176
-0
lines changed

.github/workflows/linux.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build Linux deb for Qualcomm hardware
2+
3+
on:
4+
# run on pull requests to the main branch
5+
pull_request:
6+
branches: [main]
7+
# run on pushes to the main branch
8+
push:
9+
branches: [main]
10+
# run weekly on Monday at 8:30am
11+
schedule:
12+
- cron: '30 8 * * 1'
13+
# allow manual runs
14+
workflow_dispatch:
15+
16+
# only need permission to read repository; implicitely set all other
17+
# permissions to none
18+
permissions:
19+
contents: read
20+
21+
env:
22+
# where results will be posted/hosted
23+
FILESERVER_URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app
24+
# github runs are only unique per repository and may also be re-run; create a
25+
# build id for the current run
26+
BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
27+
28+
# cancel in progress builds for this workflow triggered by the same ref
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.ref }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
build-linux-deb:
35+
# TODO test whether this builds on x86 too
36+
# XXX currently missing docker
37+
#runs-on: [self-hosted, x86]
38+
runs-on: [self-hosted, arm64, debbuilder]
39+
container:
40+
image: debian:trixie
41+
volumes:
42+
- /srv/gh-runners/quic-yocto/builds:/fileserver-builds
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
# make sure we have latest packages first, to get latest fixes, to avoid
49+
# an automated update while we're building, and to prevent version skews
50+
- name: Update OS packages
51+
run: |
52+
set -ux
53+
apt update
54+
apt -y upgrade
55+
apt -y full-upgrade
56+
57+
- name: Build Linux kernel deb for Qualcomm hardware
58+
run: |
59+
set -ux
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 dpkg-dev debhelper-compat kmod python3 \
63+
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+
# create directory for results on fileserver
75+
dir="/fileserver-builds/${BUILD_ID}"
76+
mkdir -vp "${dir}"
77+
# copy results to fileserver
78+
cp -av `dcmd *.changes` "${dir}"
79+
# instruct fileserver to publish this directory
80+
url="${FILESERVER_URL}/${BUILD_ID}/"
81+
curl -X POST -H 'Accept: text/event-stream' "${url}"
82+
# save directory and URL of these results
83+
echo "${dir}" >linux-deb.dir
84+
echo "${url}" >linux-deb.url
85+
86+
- name: Save links to build results as an artifact
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: linux-deb-links
90+
path: |
91+
linux-deb.dir
92+
linux-deb.url
93+

scripts/build-linux-deb.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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"
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 "${CONFIG}" local.config
76+
77+
log_i "Building Linux deb"
78+
# TODO: build other packages?
79+
make -j$(nproc) bindeb-pkg
80+
81+
ls
82+
ls ..
83+

0 commit comments

Comments
 (0)