Skip to content

Commit 345ce17

Browse files
Add docker build for arm64 native and amd64 cross-compile
Adds two Dockerfiles under docker/ to build a builder image for both amd64 amd arm64 Adds a workflow to build those two docker images and store them in ghcr Chose wether to build with a amd64 or arm64 runner Choose the right container (arm64 native, or amd64 cross-compile) Signed-off-by: Simon Beaudoin <[email protected]>
1 parent e4b5b71 commit 345ce17

File tree

11 files changed

+223
-575
lines changed

11 files changed

+223
-575
lines changed

.github/actions/abi_checker/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ runs:
1818
set +e
1919
./qcom-build-utils/scripts/ppa_interface.py \
2020
--operation list-versions \
21-
--apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
21+
--apt-config "deb [arch=arm64 trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_DISTRIBUTION}}/stable main" \
2222
--package-name ${{env.BUILT_PACKAGE_NAME}}
2323
2424
RET=$?
@@ -32,7 +32,7 @@ runs:
3232
set +e
3333
./qcom-build-utils/scripts/ppa_interface.py \
3434
--operation download \
35-
--apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
35+
--apt-config "deb [arch=arm64 trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_DISTRIBUTION}}/stable main" \
3636
--package-name ${{env.BUILT_PACKAGE_NAME}}
3737
3838
RET=$?
@@ -51,7 +51,7 @@ runs:
5151
5252
./qcom-build-utils/scripts/deb_abi_checker.py \
5353
--new-package-dir ./build-area \
54-
--apt-server-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
54+
--apt-server-config "deb [arch=arm64 trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_DISTRIBUTION}}/stable main" \
5555
--result-file ./results.txt
5656
5757
RET=$?

.github/actions/build_package/action.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ runs:
1818

1919
steps:
2020

21-
- name: Validate Or Create Chroot Environment
21+
# Normalize the name of the architecture
22+
# Build Architecture: The architecture of the machine performing the build (arm64 when native or amd64 when cross compiling).
23+
# This depends on the runner executing the build
24+
- name: Set Builder Arch variable
2225
shell: bash
2326
run: |
24-
./qcom-build-utils/scripts/prep_chroot_env.py \
25-
--arch ${{env.ARCH}} \
26-
--os-codename ${{env.UBUNTU_CODENAME}} \
27-
--suffix ${{env.DISTRO}}
27+
if [ "${{ runner.arch }}" = "X64" ]; then
28+
echo "BUILD_ARCH=amd64" >> $GITHUB_ENV
29+
elif [ "${{ runner.arch }}" = "ARM64" ]; then
30+
echo "BUILD_ARCH=arm64" >> $GITHUB_ENV
31+
else
32+
echo "Unsupported architecture: ${{ runner.arch }}"
33+
exit 1
34+
fi
2835
2936
- name: Prepare Workspace Structure For The Build
3037
shell: bash
@@ -53,19 +60,23 @@ runs:
5360
lintian_flag="--no-run-lintian"
5461
fi
5562
56-
if curl -sfI "http://pkg.qualcomm.com/dists/${{env.UBUNTU_CODENAME}}/Release" > /dev/null; then
57-
EXTRA_REPO="--extra-repository='deb [arch=${{env.ARCH}} trusted=yes] http://pkg.qualcomm.com ${{env.UBUNTU_CODENAME}}/stable main'"
63+
if curl -sfI "http://pkg.qualcomm.com/dists/${{env.UBUNTU_DISTRIBUTION}}/Release" > /dev/null; then
64+
EXTRA_REPO="--extra-repository='deb [arch=arm64 trusted=yes] http://pkg.qualcomm.com ${{env.UBUNTU_DISTRIBUTION}}/stable main'"
5865
else
5966
EXTRA_REPO=""
6067
fi
6168
6269
set +e
6370
6471
# ℹ️ --git-ignore-branch is necessary because the debian branch actually checked out can be any (ex, debian/1.0.0) because we can build any previous tag
72+
# ℹ️ chroot mode unshare is important to bypass privilege issues with the mounting
73+
# Host Architecture: The architecture for which the binaries are being built (invariably arm64).
74+
6575
gbp buildpackage \
6676
--git-ignore-branch \
67-
--git-builder="sbuild --arch=${{env.ARCH}} \
68-
--dist=${{env.UBUNTU_CODENAME}}-${{env.ARCH}}-${{env.DISTRO}} \
77+
--git-builder="sbuild --host=arm64 \
78+
--build=${{env.BUILD_ARCH}} \
79+
--dist=${{env.UBUNTU_DISTRUBUTION}} \
6980
$lintian_flag \
7081
--build-dir ../${{inputs.build-dir}} \
7182
--build-dep-resolver=apt \

.github/actions/push_to_repo/action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ runs:
4040
set +e
4141
./qcom-build-utils/scripts/ppa_interface.py \
4242
--operation list-versions \
43-
--apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
43+
--apt-config "deb [arch=arm64 trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_DISTRIBUTION}}/stable main" \
4444
--package-name ${{env.BUILT_PACKAGE_NAME}}
4545
4646
RET=$?
@@ -55,7 +55,7 @@ runs:
5555
set +e
5656
./qcom-build-utils/scripts/ppa_interface.py \
5757
--operation contains-version \
58-
--apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
58+
--apt-config "deb [arch=arm64 trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_DISTRIBUTION}}/stable main" \
5959
--package-name ${{env.BUILT_PACKAGE_NAME}} \
6060
--version ${{env.BUILT_PACKAGE_VERSION}}
6161
@@ -88,25 +88,25 @@ runs:
8888
if: steps.check-version.outputs.do_upload == 'true'
8989
shell: bash
9090
run: |
91-
./qcom-build-utils/scripts/ppa_organizer.py --build-dir ./build-area --output-dir ./pkg-oss-staging-repo/pool/${{env.UBUNTU_CODENAME}}/stable/main
91+
./qcom-build-utils/scripts/ppa_organizer.py --build-dir ./build-area --output-dir ./pkg-oss-staging-repo/pool/${{env.UBUNTU_DISTRIBUTION}}/stable/main
9292
9393
cd ./pkg-oss-staging-repo
9494
95-
PPA_PACKAGES_FILE_REPO_PATH=dists/${{env.UBUNTU_CODENAME}}/stable/main/binary-${{env.ARCH}}
95+
PPA_PACKAGES_FILE_REPO_PATH=dists/${{env.UBUNTU_DISTRIBUTION}}/stable/main/binary-arm64
9696
97-
dpkg-scanpackages --multiversion pool/${{env.UBUNTU_CODENAME}} > $PPA_PACKAGES_FILE_REPO_PATH/Packages
98-
dpkg-scanpackages --type ddeb --multiversion pool/${{env.UBUNTU_CODENAME}} >> $PPA_PACKAGES_FILE_REPO_PATH/Packages
97+
dpkg-scanpackages --multiversion pool/${{env.UBUNTU_DISTRIBUTION}} > $PPA_PACKAGES_FILE_REPO_PATH/Packages
98+
dpkg-scanpackages --type ddeb --multiversion pool/${{env.UBUNTU_DISTRIBUTION}} >> $PPA_PACKAGES_FILE_REPO_PATH/Packages
9999
100100
gzip -k -f $PPA_PACKAGES_FILE_REPO_PATH/Packages
101101
102102
cat $PPA_PACKAGES_FILE_REPO_PATH/Packages
103103
104104
git add .
105105
106-
git config user.name "Github Service Bot"
106+
git config user.name "GitHub Service Bot"
107107
git config user.email "[email protected]"
108108
109-
git commit -s -m "Uploaded Package ${{env.BUILT_PACKAGE_NAME}} at version ${{env.BUILT_PACKAGE_VERSION}} for distro ${{env.UBUNTU_CODENAME}}"
109+
git commit -s -m "Uploaded Package ${{env.BUILT_PACKAGE_NAME}} at version ${{env.BUILT_PACKAGE_VERSION}} for distro ${{env.UBUNTU_DISTRIBUTION}}"
110110
111111
git remote set-url origin https://x-access-token:${{inputs.token}}@github.com/${{env.REPO_NAME}}.git
112112

.github/workflows/qcom-build-pkg-reusable-workflow.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ on:
1818
required: true
1919
default: debian/latest
2020

21-
ubuntu-codename:
22-
description: The ubuntu codename to build for. Ex noble, jammy, etc
21+
ubuntu-distribution:
22+
description: The ubuntu distribution to build for. Ex noble, jammy, etc
2323
type: string
2424
default: noble
2525

@@ -43,6 +43,11 @@ on:
4343
type: boolean
4444
default: false
4545

46+
runner:
47+
description: The runner to use for the build
48+
type: string
49+
default: ubuntu-latest
50+
4651
secrets:
4752
TOKEN:
4853
required: true
@@ -55,29 +60,25 @@ env:
5560
REPO_URL: https://qualcomm-linux.github.io/pkg-oss-staging-repo/
5661
REPO_NAME: qualcomm-linux/pkg-oss-staging-repo
5762

58-
UBUNTU_CODENAME: ${{inputs.ubuntu-codename}}
59-
DISTRO: ubuntu
60-
ARCH: arm64
63+
UBUNTU_DISTRIBUTION: ${{inputs.ubuntu-distribution}}
6164

6265
jobs:
6366
build-debian-package:
6467

65-
runs-on: [self-hosted, Linux, ARM64]
66-
# runs-on: [self-hosted, lecore-stg-u2404-arm64-xlrg-od-ephem]
67-
68-
# container:
69-
# image: ubuntu:noble
70-
# options: --volume /srv/chroot:/srv/chroot
68+
runs-on: ${{inputs.runner}}
7169

72-
steps:
70+
defaults:
71+
run:
72+
shell: bash
7373

74-
# - name: Install dependencies
75-
# run: |
76-
# apt-get update
77-
# apt-get install -y git git-buildpackage sbuild debootstrap tree
74+
container:
75+
image: ghcr.io/qualcomm-linux/pkg-builder:${{inputs.runner == 'ubuntu-latest' && 'amd64' || 'arm64'}}-latest
76+
options: --privileged
77+
credentials:
78+
username: ${{vars.DEB_PKG_BOT_CI_USERNAME}}
79+
password: ${{secrets.TOKEN}}
7880

79-
- name: Ensure Workspace Is Clean
80-
run: rm -rf *
81+
steps:
8182

8283
- name: Checkout qcom-build-utils
8384
uses: actions/checkout@v4
@@ -106,7 +107,7 @@ jobs:
106107
pkg-dir: package-repo
107108
build-dir: build-area
108109
run-lintian: ${{inputs.run-lintian}}
109-
110+
110111
- name: Run ABI (Application Binary Interface) Check
111112
if: ${{inputs.run-abi-checker == true}}
112113
uses: ./qcom-build-utils/.github/actions/abi_checker
Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,68 @@
11
name: Container Build And Upload
22
description: |
3-
Builds and uploads to GHCR (GitHub Container Registry) the container used to build the packages
4-
3+
Builds and uploads to GHCR (GitHub Container Registry) the container used to build the Qualcomm debian packages.
4+
This workflow will assumes the build architecture is amd64 (x86_64) since the github's 'ubuntu-latest' runs-on tag
5+
is used. Using docker's buildx, the Dockerfile in this repo's docker/ folder will be built for amd64 and cross-compiled
6+
for arm64.
7+
58
on:
69
workflow_dispatch:
710
inputs:
8-
test:
9-
description: no description
10-
type: boolean
11-
default: false
11+
version:
12+
description: The version name to be appended to the image name, default is 'latest'
13+
type: string
14+
default: latest
1215

1316
permissions:
1417
contents: read
1518
security-events: write
1619

1720
env:
18-
GITHUB_SERVICE_BOT_USERNAME: "qcom-service-bot"
19-
2021
QCOM_ORG_NAME: "qualcomm-linux"
2122

2223
IMAGE_NAME: "pkg-builder"
2324

2425
jobs:
25-
container-build-and-upload:
26+
build-image-amd64:
2627

2728
runs-on: ubuntu-latest
2829

2930
steps:
3031

32+
- name: Checkout Dockerfile
33+
uses: actions/checkout@v4
34+
with:
35+
ref: ${{github.head_ref}}
36+
sparse-checkout: docker/Dockerfile.amd64
37+
sparse-checkout-cone-mode: false # single file -> false
38+
39+
- name: Authenticate to GHCR
40+
run: echo ${{ secrets.DEB_PKG_BOT_CI_TOKEN }} | docker login ghcr.io -u ${{ vars.DEB_PKG_BOT_CI_USERNAME }} --password-stdin
41+
42+
- name: Build and Tag the Image
43+
run: docker build -f docker/Dockerfile.amd64 -t ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:amd64-${{inputs.version}} ./docker
44+
45+
- name: Push
46+
run: docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:amd64-${{inputs.version}}
47+
48+
build-image-arm64:
49+
50+
runs-on: ["self-hosted", "lecore-prd-u2404-arm64-xlrg-od-ephem"]
51+
52+
steps:
53+
54+
- name: Checkout Dockerfile
55+
uses: actions/checkout@v4
56+
with:
57+
ref: ${{github.head_ref}}
58+
sparse-checkout: docker/Dockerfile.arm64
59+
sparse-checkout-cone-mode: false # single file -> false
60+
3161
- name: Authenticate to GHCR
32-
run: echo ${{ secrets.DEB_PKG_BOT_CI_TOKEN }} | docker login ghcr.io -u ${{env.GITHUB_SERVICE_BOT_USERNAME}} --password-stdin
62+
run: echo ${{ secrets.DEB_PKG_BOT_CI_TOKEN }} | docker login ghcr.io -u ${{ vars.DEB_PKG_BOT_CI_USERNAME }} --password-stdin
3363

3464
- name: Build and Tag the Image
35-
run: docker build -t ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:latest .
65+
run: docker build -f docker/Dockerfile.arm64 -t ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:arm64-${{inputs.version}} ./docker
66+
67+
- name: Push
68+
run: docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:arm64-${{inputs.version}}

.github/workflows/qcom-promote-upstream-reusable-workflow.yml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,25 @@ env:
4141
NORMALIZED_VERSION: ""
4242
DISTRIBUTION: noble
4343

44-
#TODOOOOOOO : Check if a PR branch already exist. This wwould mean that someone or something triggered the
44+
#TODO : Check if a PR branch already exist. This would mean that someone or something triggered the
4545
# promotion more than once before it was merged
4646

4747
jobs:
4848
promote-upstream-version:
4949

50-
runs-on: [self-hosted, Linux, ARM64]
51-
# runs-on: [self-hosted, lecore-stg-u2404-arm64-xlrg-od-ephem]
50+
runs-on: ubuntu-latest
5251

53-
# container:
54-
# image: ubuntu:noble
52+
defaults:
53+
run:
54+
shell: bash
5555

56-
steps:
57-
58-
# - name: Install dependencies
59-
# run: |
60-
# apt-get update
61-
# apt-get install -y git git-buildpackage
56+
container:
57+
image: ghcr.io/qualcomm-linux/pkg-builder:amd64-latest
58+
credentials:
59+
username: ${{ vars.DEB_PKG_BOT_CI_USERNAME }}
60+
password: ${{ secrets.TOKEN }}
6261

63-
- name: Check Dependencies
64-
run: |
65-
git --version
66-
gbp --version
67-
gh --version
62+
steps:
6863

6964
- name: Ensure Workspace Is Clean
7065
run: rm -rf *
@@ -100,7 +95,7 @@ jobs:
10095
path: ./package-repo
10196
fetch-depth: 0
10297

103-
- name: Fetch All Branches and Tags
98+
- name: Show branches/tags and checkout debian/upstream latest
10499
run: |
105100
cd ./package-repo
106101
@@ -139,7 +134,7 @@ jobs:
139134
- name: Add Upstream Link As A Remote And Fetch Tags
140135
run: |
141136
cd ./package-repo
142-
git remote add upstream-source git@github.com:${{inputs.upstream-repo}}.git
137+
git remote add upstream-source https://x-access-token:${{secrets.TOKEN}}@github.com/${{inputs.upstream-repo}}.git
143138
git fetch upstream-source "+refs/tags/*:refs/tags/*"
144139
145140
- name: Clone Upstream Repo At Specified Tag
@@ -174,8 +169,8 @@ jobs:
174169
run: |
175170
cd ./package-repo
176171
177-
git config user.name "Github Service Bot"
178-
git config user.email "[email protected]"
172+
git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}"
173+
git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}"
179174
180175
git checkout -b debian/pr/${{env.NORMALIZED_VERSION}}-1
181176
@@ -206,13 +201,12 @@ jobs:
206201
-m "Filtered out .git, .github and debian from upstram, and preserved .github debian/latest" \
207202
upstream/latest
208203
209-
#TODO : Think about how to promote the distro -1 version, and if we push the tag or not
210204
- name: Promote Changelog
211205
run: |
212206
cd ./package-repo
213207
214-
export DEBFULLNAME="Github Service Bot"
215-
export DEBEMAIL=[email protected]
208+
export DEBFULLNAME="${{vars.DEB_PKG_BOT_CI_NAME}}"
209+
export DEBEMAIL="${{vars.DEB_PKG_BOT_CI_EMAIL}}"
216210
217211
# use ignore branch because we are not on default debian branch
218212
gbp dch \

0 commit comments

Comments
 (0)