Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions .github/workflows/test-rubikpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./
with:
image_url: https://people.canonical.com/~platform/images/qualcomm-iot/rubikpi3/ubuntu-server-24.04/x00/ubuntu-24.04-preinstalled-server-arm64+rubikpi3-20250912-127.yaml
image_url: https://people.canonical.com/~platform/images/qualcomm-iot/rubikpi3/ubuntu-server-24.04/x01/ubuntu-24.04-preinstalled-server-arm64+rubikpi3-20250926-145.yaml
minimum_free_mb: 2000
root_location: "offset=569376768"
shrink_image: "no"
Expand All @@ -27,21 +27,27 @@ jobs:
- name: Compress image
run: |
imagedir=$(dirname ${{ steps.build_image.outputs.image }})
tardir=${RUNNER_TEMP}/photonvision_rubikpi3
tardir=photonvision_rubikpi3_fromYAML
mkdir --parents ${tardir}
if ls ${imagedir}*.tar.gz 1>/dev/null 2>&1; then
sudo tar -xzf ${imagedir}*.tar.gz -C ${tardir}
echo "Contents of imagedir: ${imagedir}"
ls -la ${imagedir}
if ls ${imagedir}/*.tar.gz 1>/dev/null 2>&1; then
sudo tar -xzf ${imagedir}/*.tar.gz -C ${tardir}
fi
sudo mv ${imagedir}/rawprogram*.xml ${tardir}/ 2>/dev/null || true
sudo mv ${imagedir}/dtb.bin ${tardir}/ 2>/dev/null || true
sudo mv ${imagedir}/*.img ${tardir}/ 2>/dev/null || true
echo "Before cleanup contents of tardir: ${tardir}"
ls -la ${tardir}
sudo find ${tardir} -mindepth 2 -type f -exec mv {} ${tardir}/ \;
sudo find ${tardir} -mindepth 1 -type d -empty -delete
sudo tar -I 'xz -T0' -cf ./photonvision_rubikpi3.tar.xz ${tardir} --checkpoint=10000 --checkpoint-action=echo='%T'
echo "After cleanup contents of tardir: ${tardir}"
ls -la ${tardir}
sudo tar -I 'xz -T0' -cf ./photonvision_rubikpi3_fromYAML.tar.xz ${tardir} --checkpoint=10000 --checkpoint-action=echo='%T'
- uses: actions/upload-artifact@v4
with:
name: photonvision_rubikpi3.tar.xz
path: ./photonvision_rubikpi3.tar.xz
name: photonvision_rubikpi3_fromYAML.tar.xz
path: ./photonvision_rubikpi3_fromYAML.tar.xz
compression-level: 0
if-no-files-found: error
retention-days: 1
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/test-tar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Test modifying a Rubik Pi tar image'
on:
push:
branches:
- 'main'
- 'releases/**'
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- uses: ./
with:
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2026.0.4/photonvision_rubikpi3.tar.xz
minimum_free_mb: 2000
root_location: "offset=569376768"
shrink_image: "no"
commands: |
echo "Testing Rubik Pi tar image"
uname -a
lsblk
echo "${loopdev}"
id: build_image
- name: Compress image
run: |
imagedir=$(dirname ${{ steps.build_image.outputs.image }})
echo "Imagedir: ${imagedir}"
ls -la ${imagedir}
tardir=photonvision_rubikpi3_fromTAR
mkdir --parents ${tardir}
echo "Tardir: ${tardir}"
ls -la ${tardir}
sudo mv ${imagedir}/* ${tardir}/
echo "After move"
ls -la ${tardir}
sudo tar -I 'xz -T0' -cf ./photonvision_rubikpi3_fromTAR.tar.xz ${tardir} --checkpoint=10000 --checkpoint-action=echo='%T'
- uses: actions/upload-artifact@v4
with:
name: photonvision_rubikpi3_fromTAR.tar.xz
path: ./photonvision_rubikpi3_fromTAR.tar.xz
compression-level: 0
if-no-files-found: error
retention-days: 1


15 changes: 11 additions & 4 deletions get_image.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -euo pipefail
set -euxo pipefail

url=$1
download_path="${RUNNER_TEMP}/image"
Expand Down Expand Up @@ -30,16 +30,23 @@ else
fi

echo "Image: ${image}"

ls -l ${download_path}
ls -la ${download_path}

if [[ ${image} = *.xz ]]; then
echo "Unzipping ${image}"
unxz ${image}
image=${image%.xz}
fi

ls -l ${download_path}
if [[ ${image} = *.tar ]]; then
echo "Untarring ${image}"
tar -xf ${image}
rm ${image}
image=$(find . -type f \( -name '*.img' \) -exec ls -s {} + 2>/dev/null | sort -rn | head -n1 | awk '{print $2}')
fi

echo "Image: ${image}"
ls -la $(dirname ${image})

if [[ ${image} != *.img ]]; then
echo "${image} isn't a valid image file"
Expand Down
8 changes: 4 additions & 4 deletions mount_image.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -euo pipefail
set -euxo pipefail

image="$1"
additional_mb=$2
Expand All @@ -17,7 +17,7 @@ case ${root_location,,} in
rootdev="${loopdev}p${rootpartition}"
;;
offset* )
rootpartition=1
rootpartition=0
rootoffset=${root_location#*=}
loopdev=$(losetup --find --show --offset=${rootoffset} ${image})
rootdev="${loopdev}"
Expand Down Expand Up @@ -65,9 +65,9 @@ if [[ ${additional_mb} -gt 0 ]]; then
fi
if [[ ${rootpartition} -gt 0 ]]; then
parted --script "${loopdev}" resizepart ${rootpartition} 100%
e2fsck -p -f "${rootdev}"
resize2fs "${rootdev}"
fi
e2fsck -p -f "${rootdev}"
resize2fs "${rootdev}"
echo "Finished resizing disk image."
fi

Expand Down
5 changes: 3 additions & 2 deletions pack_image.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -euo pipefail
set -euxo pipefail

####
# Clean up and shrink image
Expand All @@ -16,7 +16,7 @@ echo "Zero filling empty space"

umount --recursive "${rootdir}"

if [[ ${shrink,,} = y* ]]; then
if [[ ${shrink,,} = y* && ${rootpartition} -gt 0 ]]; then
echo "Resizing root filesystem to minimal size."
e2fsck -v -f -p -E discard "${rootdev}"
resize2fs -M "${rootdev}"
Expand Down Expand Up @@ -45,6 +45,7 @@ if [[ ${shrink,,} = y* ]]; then
fi
echo "Shrinking image from ${initial_image_size} to ${image_size} bytes."
truncate -s "${image_size}" "${image}"
losetup --set-capacity "${loopdev}"
if [[ "${part_type}" == "gpt" ]]; then
# use sgdisk to fix the secondary GPT after truncation
sgdisk -e "${image}"
Expand Down