Skip to content

Commit ae662c5

Browse files
authored
Native-arm-runner-action (#97)
Utilize the [photon-image-runner](https://github.com/PhotonVision/photon-image-runner) action to build images. Once this is validated, we can use the same action for modifying the images in [photonvision](https://github.com/PhotonVision/photonvision) and [photon-libcamera-gl-driver](https://github.com/PhotonVision/photon-libcamera-gl-driver) workflows. Improvements in this PR: * Like #95, this uses the GitHub arm runner to greatly speed up image build times. * Images specified by a yaml file, like the RubikPi3, are handled correctly. * A PhotonVision release can be specified in the workflow, which allows images to be built with releases other than latest. * The action implements an option to specify the minimum free space needed in the image. This should prevent repeated increases in the size of an image if it can't be shrunk by the action. * Several minor problems were fixed, including * CIDATA partition is properly mounted on OrangePi * Version information is added by `install_common.sh` * Empty space is zero filled on all images for better compression * No more log spam from Dpkg Supersedes #95
1 parent 717627d commit ae662c5

File tree

10 files changed

+282
-82
lines changed

10 files changed

+282
-82
lines changed

.github/workflows/main.yml

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,14 @@ concurrency:
1313

1414
jobs:
1515
rubik:
16-
env:
17-
script: "./tmp/build/install_rubikpi3.sh"
18-
base_image: "https://people.canonical.com/~platform/images/qualcomm-iot/rubikpi3/ubuntu-server-24.04/x00/ubuntu-24.04-preinstalled-server-arm64+rubikpi3-20250912-127.yaml"
19-
20-
runs-on: ubuntu-24.04-arm
21-
16+
runs-on: ubuntu-24.04-arm
2217
name: "Build for RubikPi3"
23-
2418
steps:
25-
- uses: actions/checkout@v4.1.7
26-
with:
27-
fetch-depth: 0
28-
- name: Fetch tags
29-
run: git fetch --tags --force
30-
31-
- name: Build rubikpi3 with mounting
32-
run: |
33-
chmod +x ./mount_rubikpi3.sh
34-
./mount_rubikpi3.sh ${{ env.base_image }} ${{ env.script }} ${{ github.ref_name }}
35-
36-
- name: Compress built image
37-
run: |
38-
tar -I 'xz -T0' -cf photonvision_rubikpi3.tar.xz photonvision_rubikpi3 --checkpoint=10000 --checkpoint-action=echo='%T'
39-
40-
- uses: actions/upload-artifact@v4.3.4
41-
with:
42-
name: photonvision_rubikpi3.tar.xz
43-
path: photonvision_rubikpi3.tar.xz
44-
if-no-files-found: error
45-
retention-days: 1
19+
- name: Dummy
20+
run: echo "This is a dummy step. Remove when the ""Build for RubikPi3"" job is no longer required"
4621

4722
build:
48-
runs-on: ubuntu-24.04
23+
runs-on: ubuntu-24.04-arm
4924

5025
strategy:
5126
fail-fast: false
@@ -93,44 +68,71 @@ jobs:
9368
- name: rock5c
9469
script: ./install_opi5.sh
9570
base_image: https://github.com/Joshua-Riek/ubuntu-rockchip/releases/download/v2.4.0/ubuntu-24.04-preinstalled-server-arm64-rock-5c.img.xz
71+
- name: rubikpi3
72+
script: ./install_rubikpi3.sh
73+
base_image: https://people.canonical.com/~platform/images/qualcomm-iot/rubikpi3/ubuntu-server-24.04/x00/ubuntu-24.04-preinstalled-server-arm64+rubikpi3-20250912-127.yaml
74+
root_location: "offset=569376768"
9675

9776
name: "Build for ${{ matrix.name }}"
9877

9978
steps:
100-
- uses: actions/checkout@v4.1.7
79+
- uses: actions/checkout@v4
10180
with:
10281
fetch-depth: 0
10382
- name: Fetch tags
10483
run: git fetch --tags --force
10584

106-
- uses: pguyot/arm-runner-action@HEAD
85+
- name: Install dependencies and build image
86+
uses: photonvision/photon-image-runner@HEAD
10787
id: install_deps
10888
with:
109-
image_additional_mb: 1500
110-
bind_mount_repository: true
111-
base_image: ${{ matrix.base_image }}
89+
minimum_free_mb: 2000
90+
image_url: ${{ matrix.base_image }}
91+
root_location: ${{ contains('rubikpi3', matrix.name) && 'offset=569376768' || 'partition=2' }}
92+
shrink_image: ${{ contains('rubikpi3', matrix.name) && 'no' || 'yes' }}
11293
commands: |
113-
chmod +x ${{matrix.script}}
114-
${{ matrix.script }}
115-
chmod +x ./install_common.sh
116-
./install_common.sh
117-
mkdir -p /opt/photonvision/
118-
echo "${{ github.ref_name }};${{ matrix.name }}" > /opt/photonvision/image-version
94+
echo "Running ${{ matrix.script }}"
95+
chmod +x "${{ matrix.script }}"
96+
"./${{ matrix.script }}" "v2026.0.0-alpha-2"
97+
echo "Running install_common.sh"
98+
chmod +x "./install_common.sh"
99+
"./install_common.sh"
119100
120-
- name: Compress built image
101+
- name: Compress built image
102+
if: ${{ ! endsWith(matrix.base_image, 'yaml') }}
121103
run: |
122-
mv ${{ steps.install_deps.outputs.image }} photonvision_${{ matrix.name }}.img
104+
sudo mv ${{ steps.install_deps.outputs.image }} photonvision_${{ matrix.name }}.img
123105
sudo xz -T 0 -v photonvision_${{ matrix.name }}.img
106+
echo "artifact=photonvision_${{ matrix.name }}.img.xz" >> "$GITHUB_ENV"
107+
108+
- name: Tar built image
109+
if: ${{ endsWith(matrix.base_image, 'yaml') }}
110+
run: |
111+
imagedir=$(dirname ${{ steps.install_deps.outputs.image }})
112+
target=photonvision_${{ matrix.name }}
113+
tardir=${RUNNER_TEMP}/${target}
114+
mkdir --parents ${tardir}
115+
if ls ${imagedir}*.tar.gz 1>/dev/null 2>&1; then
116+
sudo tar -xzf ${imagedir}*.tar.gz -C ${tardir}
117+
fi
118+
sudo mv ${imagedir}/rawprogram*.xml ${tardir}/ 2>/dev/null || true
119+
sudo mv ${imagedir}/dtb.bin ${tardir}/ 2>/dev/null || true
120+
sudo mv ${imagedir}/*.img ${tardir}/ 2>/dev/null || true
121+
sudo find ${tardir} -mindepth 2 -type f -exec mv {} ${tardir}/ \;
122+
sudo find ${tardir} -mindepth 1 -type d -empty -delete
123+
sudo tar -I 'xz -T0' -cf ${target}.tar.xz ${tardir} --checkpoint=10000 --checkpoint-action=echo='%T'
124+
echo "artifact=${target}.tar.xz" >> "$GITHUB_ENV"
124125
125-
- uses: actions/upload-artifact@v4.3.4
126+
- uses: actions/upload-artifact@v4
126127
with:
127-
name: photonvision_${{ matrix.name }}.img.xz
128-
path: photonvision_${{ matrix.name }}.img.xz
128+
name: ${{ env.artifact }}
129+
path: ${{ env.artifact }}
129130
if-no-files-found: error
130131
retention-days: 1
131132

132133
release:
133-
needs: [build, rubik]
134+
# needs: [build, rubik]
135+
needs: [build]
134136
runs-on: ubuntu-24.04
135137
steps:
136138
# Download literally every single artifact

install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Exit on errors
4-
set -e
4+
set -e +u
55

66
needs_arg() {
77
if [ -z "$OPTARG" ]; then
@@ -42,7 +42,7 @@ install_if_missing() {
4242

4343
debug "Installing $1..."
4444
if [[ -z $TEST ]]; then
45-
apt-get install --yes "$1"
45+
apt-get --yes install "$1"
4646
# Always mark our upstream apt deps as held back, which will prevent the package
4747
# from being automatically installed, upgraded or removed
4848
apt-mark manual "$1"
@@ -113,7 +113,7 @@ fi
113113
INSTALL_NETWORK_MANAGER="ask"
114114
VERSION="latest"
115115

116-
while getopts "hlv:a:mnqt-:" OPT; do
116+
while getopts "hlva:mnqt-:" OPT; do
117117
if [ "$OPT" = "-" ]; then
118118
OPT="${OPTARG%%=*}" # extract long option name
119119
OPTARG="${OPTARG#"$OPT"}" # extract long option argument (may be empty)
@@ -137,8 +137,8 @@ while getopts "hlv:a:mnqt-:" OPT; do
137137
exit 0
138138
;;
139139
v | version)
140-
needs_arg
141-
VERSION=${OPTARG}
140+
# needs_arg
141+
VERSION=${OPTARG:-latest}
142142
;;
143143
a | arch) needs_arg; ARCH=$OPTARG
144144
;;
@@ -245,7 +245,7 @@ fi
245245

246246
debug "Updating package list..."
247247
if [[ -z $TEST ]]; then
248-
apt-get update
248+
apt-get -q update
249249
fi
250250
debug "Updated package list."
251251

install_common.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#!/bin/bash -v
2-
1+
#!/bin/bash
32
# Verbose and exit on errors
4-
set -ex
3+
# set -ex
54

65
# Do additional tasks that are common across all images,
76
# but not suitable for inclusion in install.sh
@@ -29,3 +28,7 @@ echo "photon:vision" | chpasswd
2928
cp -f ./files/issue.txt /etc/issue
3029
cp -f /etc/issue /etc/issue.net
3130
sed -i 's/#Banner none/Banner \/etc\/issue.net/g' /etc/ssh/sshd_config
31+
32+
# Add photon version file
33+
mkdir -p /opt/photonvision/
34+
echo "${GITHUB_REF_NAME};${image_name}" > /opt/photonvision/image-version

install_dev_pi.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
# Verbose and exit on errors
44
set -ex
5+
6+
# silence log spam from dpkg
7+
cat > /etc/apt/apt.conf.d/99dpkg.conf << EOF
8+
Dpkg::Progress-Fancy "0";
9+
APT::Color "0";
10+
Dpkg::Use-Pty "0";
11+
EOF
12+
513
# Run normal photon installer
614
chmod +x ./install.sh
715
./install.sh --install-nm=yes --arch=aarch64

install_limelight.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
# Verbose and exit on errors
44
set -ex
55

6+
# silence log spam from dpkg
7+
cat > /etc/apt/apt.conf.d/99dpkg.conf << EOF
8+
Dpkg::Progress-Fancy "0";
9+
APT::Color "0";
10+
Dpkg::Use-Pty "0";
11+
EOF
12+
613
# Run normal photon installer
714
chmod +x ./install.sh
8-
./install.sh --install-nm=yes --arch=aarch64
15+
./install.sh --install-nm=yes --arch=aarch64 --version="$1"
916

1017
# edit boot partition
1118
install -m 644 limelight/config.txt /boot/

install_opi5.sh

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/bin/bash -v
2-
1+
#!/bin/bash
2+
set +u
33
# Verbose and exit on errors
4-
set -ex
4+
# set -ex
55

66
# Create pi/raspberry login
7-
if id "$1" >/dev/null 2>&1; then
7+
if id "pi" >/dev/null 2>&1; then
88
echo 'user found'
99
else
1010
echo "creating pi user"
@@ -15,7 +15,14 @@ else
1515
fi
1616
echo "pi:raspberry" | chpasswd
1717

18-
apt-get update --quiet
18+
# silence log spam from dpkg
19+
cat > /etc/apt/apt.conf.d/99dpkg.conf << EOF
20+
Dpkg::Progress-Fancy "0";
21+
APT::Color "0";
22+
Dpkg::Use-Pty "0";
23+
EOF
24+
25+
apt-get -q update
1926

2027
before=$(df --output=used / | tail -n1)
2128
# clean up stuff
@@ -24,13 +31,13 @@ before=$(df --output=used / | tail -n1)
2431
echo "Purging snaps"
2532
rm -rf /var/lib/snapd/seed/snaps/*
2633
rm -f /var/lib/snapd/seed/seed.yaml
27-
apt-get purge --yes --quiet lxd-installer lxd-agent-loader
28-
apt-get purge --yes --quiet snapd
34+
apt-get --yes -q purge lxd-installer lxd-agent-loader
35+
apt-get --yes -q purge snapd
2936

3037
# remove bluetooth daemon
31-
apt-get purge --yes --quiet bluez
38+
apt-get --yes -q purge bluez
3239

33-
apt-get --yes --quiet autoremove
40+
apt-get --yes -q autoremove
3441

3542
# remove firmware that (probably) isn't needed
3643
rm -rf /usr/lib/firmware/mrvl
@@ -46,19 +53,23 @@ echo "Freed up $freed KiB"
4653

4754
# run Photonvision install script
4855
chmod +x ./install.sh
49-
./install.sh --install-nm=yes --arch=aarch64
56+
./install.sh --install-nm=yes --arch=aarch64 --version="$1"
5057

5158
echo "Installing additional things"
52-
apt-get install --yes --quiet libc6 libstdc++6
59+
apt-get --yes -qq install libc6 libstdc++6
5360

5461
# let netplan create the config during cloud-init
5562
rm -f /etc/netplan/00-default-nm-renderer.yaml
5663

64+
mkdir --parents /mnt/CIDATA
65+
mount "${loopdev}p1" /mnt/CIDATA
5766
# set NetworkManager as the renderer in cloud-init
58-
cp -f ./OPi5_CIDATA/network-config /boot/network-config
59-
67+
cp -f ./OPi5_CIDATA/network-config /mnt/CIDATA/network-config
6068
# add customized user-data file for cloud-init
61-
cp -f ./OPi5_CIDATA/user-data /boot/user-data
69+
cp -f ./OPi5_CIDATA/user-data /mnt/CIDATA/user-data
70+
71+
umount /mnt/CIDATA
72+
rmdir /mnt/CIDATA
6273

6374
# modify photonvision.service to enable big cores
6475
sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=4-7/g' /lib/systemd/system/photonvision.service
@@ -86,7 +97,7 @@ for btservice in $btservices; do
8697
done
8798

8899
rm -rf /var/lib/apt/lists/*
89-
apt-get --yes --quiet clean
100+
apt-get --yes -qq clean
90101

91102
rm -rf /usr/share/doc
92103
rm -rf /usr/share/locale/

install_pi.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
#!/bin/bash -v
1+
#!/bin/bash
22

33
# Verbose and exit on errors
4-
set -ex
4+
# set -ex
5+
6+
# silence log spam from dpkg
7+
cat > /etc/apt/apt.conf.d/99dpkg.conf << EOF
8+
Dpkg::Progress-Fancy "0";
9+
APT::Color "0";
10+
Dpkg::Use-Pty "0";
11+
EOF
512

613
# Run normal photon installer
714
chmod +x ./install.sh
8-
./install.sh --install-nm=yes --arch=aarch64
15+
./install.sh -v "$1" --install-nm=yes --arch=aarch64 --version="$1"
916

1017
# and edit boot partition
1118
install -m 644 config.txt /boot/

install_rubikpi3.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ wget -qO - https://thundercomm.s3.dualstack.ap-northeast-1.amazonaws.com/uploads
3232

3333
# Run normal photon installer
3434
chmod +x ./install.sh
35-
./install.sh --install-nm=yes --arch=aarch64
35+
./install.sh --install-nm=yes --arch=aarch64 --version="$1"
3636

3737
# Install packages from the RUBIK Pi PPA, we skip calling apt-get update here because install.sh already does that
3838
apt-get -y install libqnn1 libsnpe1 qcom-adreno1 device-tree-compiler
@@ -60,7 +60,3 @@ rm -rf /usr/share/locale/
6060
echo '=== Running install_common.sh ==='
6161
chmod +x ./install_common.sh
6262
./install_common.sh
63-
echo '=== Creating version file ==='
64-
mkdir -p /opt/photonvision/
65-
echo '{$1};rubikpi3' > /opt/photonvision/image-version
66-
echo '=== Installation complete ==='

0 commit comments

Comments
 (0)