Skip to content

Commit 1902eee

Browse files
committed
add processing for tar files
1 parent 3f512e0 commit 1902eee

File tree

5 files changed

+73
-11
lines changed

5 files changed

+73
-11
lines changed

.github/workflows/test-raspi.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: 'Test modifying a Raspberry Pi image'
22
on:
3-
push:
4-
branches:
5-
- 'main'
6-
- 'releases/**'
7-
pull_request:
3+
# push:
4+
# branches:
5+
# - 'main'
6+
# - 'releases/**'
7+
# pull_request:
88
workflow_dispatch:
99

1010
jobs:

.github/workflows/test-rubikpi.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,22 @@ jobs:
2727
- name: Compress image
2828
run: |
2929
imagedir=$(dirname ${{ steps.build_image.outputs.image }})
30-
tardir=${RUNNER_TEMP}/photonvision_rubikpi3
30+
tardir=./photonvision_rubikpi3
3131
mkdir --parents ${tardir}
32+
echo "Contents of imagedir: ${imagedir}"
33+
ls -la ${imagedir}
3234
if ls ${imagedir}*.tar.gz 1>/dev/null 2>&1; then
33-
sudo tar -xzf ${imagedir}*.tar.gz -C ${tardir}
35+
sudo tar -xzf ${imagedir}*.tar.gz -C ${tardir} --strip-components=1
3436
fi
3537
sudo mv ${imagedir}/rawprogram*.xml ${tardir}/ 2>/dev/null || true
3638
sudo mv ${imagedir}/dtb.bin ${tardir}/ 2>/dev/null || true
3739
sudo mv ${imagedir}/*.img ${tardir}/ 2>/dev/null || true
40+
echo "Before cleanup contents of tardir: ${tardir}"
41+
ls -la ${tardir}
3842
sudo find ${tardir} -mindepth 2 -type f -exec mv {} ${tardir}/ \;
3943
sudo find ${tardir} -mindepth 1 -type d -empty -delete
44+
echo "After cleanup contents of tardir: ${tardir}"
45+
ls -la ${tardir}
4046
sudo tar -I 'xz -T0' -cf ./photonvision_rubikpi3.tar.xz ${tardir} --checkpoint=10000 --checkpoint-action=echo='%T'
4147
- uses: actions/upload-artifact@v4
4248
with:

.github/workflows/test-tar.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Test modifying a Rubik Pi tar image'
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
- 'releases/**'
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-24.04-arm
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: ./
16+
with:
17+
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/Dev/photonvision_rubikpi3.tar.xz
18+
minimum_free_mb: 2000
19+
root_location: "offset=569376768"
20+
shrink_image: "no"
21+
commands: |
22+
echo "Testing Rubik Pi tar image"
23+
uname -a
24+
lsblk
25+
echo "${loopdev}"
26+
id: build_image
27+
- name: Compress image
28+
run: |
29+
imagedir=$(dirname ${{ steps.build_image.outputs.image }})
30+
echo "Imagedir: ${imagedir}"
31+
ls -la ${imagedir}
32+
tardir=./photonvision_rubikpi3
33+
mkdir --parents ${tardir}
34+
echo "Tardir: ${tardir}"
35+
ls -la ${tardir}
36+
sudo mv ${imagedir}/* ${tardir}/
37+
echo "After move"
38+
ls -la ${tardir}
39+
sudo tar -I 'xz -T0' -cf ./photonvision_rubikpi3.tar.xz ${tardir} --checkpoint=10000 --checkpoint-action=echo='%T'
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: photonvision_rubikpi3.tar.xz
43+
path: ./photonvision_rubikpi3.tar.xz
44+
compression-level: 0
45+
if-no-files-found: error
46+
retention-days: 1
47+
48+

action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ runs:
6161
6262
cat >> "${scriptdir}/commands.sh" << EOF
6363
#!/bin/bash
64+
set -x
6465
# set -exo pipefail
6566
# export SHELLOPTS
6667
# export BASHOPTS

get_image.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -euo pipefail
2+
set -euxo pipefail
33

44
url=$1
55
download_path="${RUNNER_TEMP}/image"
@@ -30,16 +30,23 @@ else
3030
fi
3131

3232
echo "Image: ${image}"
33-
34-
ls -l ${download_path}
33+
ls -la ${download_path}
3534

3635
if [[ ${image} = *.xz ]]; then
3736
echo "Unzipping ${image}"
3837
unxz ${image}
3938
image=${image%.xz}
4039
fi
4140

42-
ls -l ${download_path}
41+
if [[ ${image} = *.tar ]]; then
42+
echo "Untarring ${image}"
43+
tar -xf ${image}
44+
rm ${image}
45+
image=$(find . -type f \( -name '*.img' \) -exec ls -s {} + 2>/dev/null | sort -rn | head -n1 | awk '{print $2}')
46+
fi
47+
48+
echo "Image: ${image}"
49+
ls -la $(dirname ${image})
4350

4451
if [[ ${image} != *.img ]]; then
4552
echo "${image} isn't a valid image file"

0 commit comments

Comments
 (0)