Skip to content

Commit 0532c0d

Browse files
Merge branch 'main' into cpu-governor
2 parents 0977717 + 46e20d5 commit 0532c0d

16 files changed

+390
-171
lines changed

.github/workflows/main.yml

Lines changed: 71 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,8 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
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-
22-
name: "Build for RubikPi3"
23-
24-
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
46-
4715
build:
48-
runs-on: ubuntu-24.04
49-
16+
runs-on: ubuntu-24.04-arm
5017
strategy:
5118
fail-fast: false
5219
matrix:
@@ -93,44 +60,97 @@ jobs:
9360
- name: rock5c
9461
script: ./install_opi5.sh
9562
base_image: https://github.com/Joshua-Riek/ubuntu-rockchip/releases/download/v2.4.0/ubuntu-24.04-preinstalled-server-arm64-rock-5c.img.xz
63+
- name: rubikpi3
64+
script: ./install_rubikpi3.sh
65+
base_image: https://people.canonical.com/~platform/images/qualcomm-iot/rubikpi3/ubuntu-server-24.04/x01/ubuntu-24.04-preinstalled-server-arm64+rubikpi3-20250926-145.yaml
66+
root_location: "offset=569376768"
67+
shrink_image: "no"
9668

9769
name: "Build for ${{ matrix.name }}"
9870

9971
steps:
100-
- uses: actions/checkout@v4.1.7
72+
- uses: actions/checkout@v4
10173
with:
10274
fetch-depth: 0
10375
- name: Fetch tags
10476
run: git fetch --tags --force
10577

106-
- uses: pguyot/arm-runner-action@HEAD
78+
- name: Generate version file
79+
run: |
80+
81+
# Build the final JSON object
82+
json_string=$(jq -n \
83+
--arg date "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
84+
--arg commit_sha "${GITHUB_SHA}" \
85+
--arg commit_tag "$(git describe --tags --abbrev=0 2>/dev/null || echo "untagged")" \
86+
--arg image_name "${{ matrix.name }}" \
87+
--arg image_source "${{ matrix.base_image }}" \
88+
'{build_date: $date, commit_sha: $commit_sha, commit_tag: $commit_tag, image_name: $image_name, image_source: $image_source}')
89+
90+
echo "$json_string"
91+
92+
echo "$json_string" > image-version.json
93+
94+
- name: Install dependencies and build image
95+
uses: photonvision/photon-image-runner@HEAD
10796
id: install_deps
10897
with:
109-
image_additional_mb: 1500
110-
bind_mount_repository: true
111-
base_image: ${{ matrix.base_image }}
98+
minimum_free_mb: 2000
99+
image_url: ${{ matrix.base_image }}
100+
root_location: ${{ matrix.root_location || 'partition=2' }}
101+
shrink_image: ${{ matrix.shrink_image || 'yes' }}
112102
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
103+
echo "Running ${{ matrix.script }}"
104+
chmod +x "${{ matrix.script }}"
105+
"./${{ matrix.script }}"
106+
echo "Running install_common.sh"
107+
chmod +x "./install_common.sh"
108+
"./install_common.sh"
119109
120-
- name: Compress built image
110+
- name: Compress built image
111+
# Compress the standard images
112+
if: ${{ ! startsWith(matrix.name, 'rubik') }}
121113
run: |
122-
mv ${{ steps.install_deps.outputs.image }} photonvision_${{ matrix.name }}.img
114+
sudo mv ${{ steps.install_deps.outputs.image }} photonvision_${{ matrix.name }}.img
123115
sudo xz -T 0 -v photonvision_${{ matrix.name }}.img
116+
echo "artifact=photonvision_${{ matrix.name }}.img.xz" >> "$GITHUB_ENV"
117+
118+
- name: Tar built image
119+
# Build the RubikPi3-specific tar file
120+
if: ${{ startsWith(matrix.name, 'rubik') }}
121+
run: |
122+
imagedir=$(dirname ${{ steps.install_deps.outputs.image }})
123+
target=photonvision_${{ matrix.name }}
124+
tardir=${target}
125+
mkdir --parents ${tardir}
126+
echo "Contents of imagedir: ${imagedir}"
127+
ls -la ${imagedir}
128+
if ls ${imagedir}/*.tar.gz 1>/dev/null 2>&1; then
129+
sudo tar -xzf ${imagedir}/*.tar.gz -C ${tardir} --strip-components=1
130+
fi
131+
sudo mv ${imagedir}/rawprogram*.xml ${tardir}/ 2>/dev/null || true
132+
sudo mv ${imagedir}/dtb.bin ${tardir}/ 2>/dev/null || true
133+
sudo mv ${imagedir}/*.img ${tardir}/ 2>/dev/null || true
134+
sudo find ${tardir} -mindepth 2 -type f -exec mv {} ${tardir}/ \;
135+
sudo find ${tardir} -mindepth 1 -type d -empty -delete
136+
echo "Contents of tardir: ${tardir}"
137+
ls -la ${tardir}
138+
sudo tar -I 'xz -T0' --create --file=${target}.tar.xz ${tardir} --checkpoint=10000 --checkpoint-action=echo='%T'
139+
echo "Contents of tar file:"
140+
# Expenive operation (has to unzip the file), only use for debugging
141+
# echo "Contents of tar file:"
142+
# tar --list --file=${target}.tar.xz
143+
echo "artifact=${target}.tar.xz" >> "$GITHUB_ENV"
124144
125-
- uses: actions/upload-artifact@v4.3.4
145+
- uses: actions/upload-artifact@v4
126146
with:
127-
name: photonvision_${{ matrix.name }}.img.xz
128-
path: photonvision_${{ matrix.name }}.img.xz
147+
name: ${{ env.artifact }}
148+
path: ${{ env.artifact }}
129149
if-no-files-found: error
130150
retention-days: 1
131151

132152
release:
133-
needs: [build, rubik]
153+
needs: [build]
134154
runs-on: ubuntu-24.04
135155
steps:
136156
# Download literally every single artifact

files/pigpiod.service

Lines changed: 0 additions & 8 deletions
This file was deleted.

install.sh

Lines changed: 15 additions & 26 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"
@@ -111,9 +111,10 @@ if grep -iq "systemcore" /etc/os-release; then
111111
fi
112112

113113
INSTALL_NETWORK_MANAGER="ask"
114+
DISABLE_NETWORKING="false"
114115
VERSION="latest"
115116

116-
while getopts "hlv:a:mnqt-:" OPT; do
117+
while getopts "hlva:mnqt-:" OPT; do
117118
if [ "$OPT" = "-" ]; then
118119
OPT="${OPTARG%%=*}" # extract long option name
119120
OPTARG="${OPTARG#"$OPT"}" # extract long option argument (may be empty)
@@ -137,8 +138,8 @@ while getopts "hlv:a:mnqt-:" OPT; do
137138
exit 0
138139
;;
139140
v | version)
140-
needs_arg
141-
VERSION=${OPTARG}
141+
# needs_arg
142+
VERSION=${OPTARG:-latest}
142143
;;
143144
a | arch) needs_arg; ARCH=$OPTARG
144145
;;
@@ -228,7 +229,7 @@ DISTRO=$(lsb_release -is)
228229
# i.e. the distro is Ubuntu, you haven't requested disabling networking,
229230
# and you have requested a quiet install.
230231
if [[ "$INSTALL_NETWORK_MANAGER" == "ask" ]]; then
231-
if [[ "$DISTRO" != "Ubuntu" || -n "$DISABLE_NETWORKING" || -n "$QUIET" ]] ; then
232+
if [[ "$DISTRO" != "Ubuntu" || "$DISABLE_NETWORKING" == "true" || -n "$QUIET" ]] ; then
232233
INSTALL_NETWORK_MANAGER="no"
233234
fi
234235
fi
@@ -245,7 +246,7 @@ fi
245246

246247
debug "Updating package list..."
247248
if [[ -z $TEST ]]; then
248-
apt-get update
249+
apt-get -q update
249250
fi
250251
debug "Updated package list."
251252

@@ -291,23 +292,6 @@ EOF
291292
fi
292293
fi
293294

294-
debug ""
295-
debug "Installing additional math packages"
296-
if [[ "$DISTRO" = "Ubuntu" && -z $(apt-cache search libcholmod3) ]]; then
297-
debug "Adding jammy to list of apt sources"
298-
if [[ -z $TEST ]]; then
299-
if [[ "$ARCH" = "x86_64" ]]; then
300-
add-apt-repository -y -S 'deb http://security.ubuntu.com/ubuntu jammy main universe'
301-
else
302-
add-apt-repository -y -S 'deb http://ports.ubuntu.com/ubuntu-ports jammy main universe'
303-
fi
304-
fi
305-
fi
306-
307-
install_if_missing libcholmod3
308-
install_if_missing liblapack3
309-
install_if_missing libsuitesparseconfig5
310-
311295
debug ""
312296

313297
debug "Downloading PhotonVision '$VERSION'..."
@@ -325,7 +309,6 @@ debug "Downloaded PhotonVision."
325309

326310
debug "Creating the PhotonVision systemd service..."
327311

328-
329312
if [[ -z $TEST ]]; then
330313
# service --status-all doesn't list photonvision on OrangePi use systemctl instead:
331314
if [[ $(systemctl --quiet is-active photonvision) = "active" ]]; then
@@ -341,6 +324,8 @@ if [[ -z $TEST ]]; then
341324
cat > /lib/systemd/system/photonvision.service <<EOF
342325
[Unit]
343326
Description=Service that runs PhotonVision
327+
# Uncomment the next line to have photonvision startup wait for NetworkManager startup
328+
# After=network.target
344329
345330
[Service]
346331
WorkingDirectory=/opt/photonvision
@@ -360,8 +345,12 @@ RestartSec=1
360345
WantedBy=multi-user.target
361346
EOF
362347

363-
if [ "$DISABLE_NETWORKING" = "true" ]; then
348+
if [[ "$DISABLE_NETWORKING" == "true" ]]; then
349+
debug "Adding -n switch to photonvision startup to disable network management"
364350
sed -i "s/photonvision.jar/photonvision.jar -n/" /lib/systemd/system/photonvision.service
351+
else
352+
debug "Setting photonvision.service to start after network.target is reached"
353+
sed -i "s/# After=network.target/After=network.target/g" /lib/systemd/system/photonvision.service
365354
fi
366355

367356
if grep -q "RK3588" /proc/cpuinfo; then

install_common.sh

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

3-
# Verbose and exit on errors
4-
set -ex
3+
# Exit on errors, print commands, ignore unset variables
4+
set -ex +u
55

66
# Do additional tasks that are common across all images,
77
# but not suitable for inclusion in install.sh
@@ -28,4 +28,13 @@ echo "photon:vision" | chpasswd
2828
# ASCII Art generated by: https://www.asciiart.eu/image-to-ascii
2929
cp -f ./files/issue.txt /etc/issue
3030
cp -f /etc/issue /etc/issue.net
31-
sed -i 's/#Banner none/Banner \/etc\/issue.net/g' /etc/ssh/sshd_config
31+
echo "Banner /etc/issue.net" > /etc/ssh/sshd_config.d/90_PhotonVisionBanner.conf
32+
33+
# Add photon version file
34+
mkdir -p /opt/photonvision/
35+
36+
# Keep this for legacy purposes
37+
# DEPRECATED: removal in 2027
38+
echo "${GITHUB_REF_NAME};${image_name}" > /opt/photonvision/image-version
39+
40+
cp -f ./image-version.json /opt/photonvision/image-version.json

install_dev_pi.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
#!/bin/bash -v
1+
#!/bin/bash
2+
3+
# Exit on errors, print commands, ignore unset variables
4+
set -ex +u
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
212

3-
# Verbose and exit on errors
4-
set -ex
513
# Run normal photon installer
614
chmod +x ./install.sh
715
./install.sh --install-nm=yes --arch=aarch64
@@ -10,22 +18,20 @@ chmod +x ./install.sh
1018
install -m 644 config.txt /boot/
1119
install -m 644 userconf.txt /boot/
1220

21+
# configure hostname
22+
echo "photonvision" > /etc/hostname
23+
sed -i 's/raspberrypi/photonvision/g' /etc/hosts
24+
1325
# Kill wifi and other networking things
1426
install -v -m 644 -D -t /etc/systemd/system/dhcpcd.service.d/ files/wait.conf
1527
install -v files/rpi-blacklist.conf /etc/modprobe.d/blacklist.conf
1628

17-
# Update pigipio service file to listen locally
18-
install -v -m 644 files/pigpiod.service /lib/systemd/system/pigpiod.service
19-
systemctl daemon-reload
20-
21-
# Enable ssh/pigpiod
29+
# Enable ssh
2230
systemctl enable ssh
23-
systemctl enable pigpiod
24-
2531

2632
echo "Installing additional things"
2733
sudo apt-get update
28-
apt-get install -y pigpiod pigpio device-tree-compiler
34+
apt-get install -y device-tree-compiler
2935
apt-get install -y network-manager net-tools
3036
# libcamera-driver stuff
3137
apt-get install -y libegl1 libopengl0 libgl1-mesa-dri libgbm1 libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk

0 commit comments

Comments
 (0)