Skip to content

Commit 34e1ee3

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

File tree

2 files changed

+164
-0
lines changed

2 files changed

+164
-0
lines changed

.github/workflows/linux.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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
61+
apt -y install git crossbuild-essential-arm64 make flex bison bc \
62+
libelf-dev libssl-dev coreutils
63+
scripts/build-linux-deb.sh
64+
65+
- name: Upload results to fileserver
66+
run: |
67+
set -ux
68+
# curl will be used to talk to fileserver; should be installed by
69+
# default
70+
apt -y install curl
71+
# create directory for results on fileserver
72+
dir="/fileserver-builds/${BUILD_ID}"
73+
mkdir -vp "${dir}"
74+
# copy output files
75+
cp -av *.deb "${dir}"
76+
# instruct fileserver to publish this directory
77+
url="${FILESERVER_URL}/${BUILD_ID}/"
78+
curl -X POST -H 'Accept: text/event-stream' "${url}"
79+
# create files with directory and URL of these results
80+
echo "${dir}" >linux-deb.dir
81+
echo "${url}" >linux-deb.url
82+
83+
- name: Save URL of build results as an artifact
84+
uses: actions/upload-artifact@v4
85+
with:
86+
path: linux-deb.dir
87+
path: linux-deb.url
88+

scripts/build-linux-deb.sh

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

0 commit comments

Comments
 (0)