1111
1212env :
1313 DOCKER_BUILDKIT : 1
14+ PACMAN_CACHE : /tmp/pacman-cache
15+ WORKSPACE : /workdir
16+ BUILD_DIR : /workdir/workdir
17+ OUTPUT_DIR : /workdir/out
1418
1519jobs :
1620 validate :
2125
2226 - name : Validate package list
2327 run : |
28+ # Check if package list exists
29+ if [ ! -f packages.x86_64 ]; then
30+ echo "::error::packages.x86_64 file not found"
31+ exit 1
32+ fi
33+
2434 # Check for duplicate packages
2535 sort packages.x86_64 | uniq -d > duplicates.txt
2636 if [ -s duplicates.txt ]; then
@@ -31,14 +41,15 @@ jobs:
3141
3242 # Validate package names exist in Arch repos
3343 docker run --rm archlinux:latest bash -c "
34- pacman -Sy
44+ set -euo pipefail
45+ pacman -Syu --noconfirm
3546 while read -r pkg; do
3647 [[ \$pkg =~ ^# ]] && continue
3748 [[ -z \$pkg ]] && continue
38- pacman -Si \$pkg >/dev/null 2>&1 || {
49+ if ! pacman -Si \$pkg >/dev/null 2>&1; then
3950 echo \"::error::Package not found: \$pkg\"
4051 exit 1
41- }
52+ fi
4253 done < packages.x86_64
4354 "
4455
@@ -75,24 +86,24 @@ jobs:
7586 - name : Cache Pacman packages
7687 uses : actions/cache@v3
7788 with :
78- path : /tmp/pacman-cache
79- key : pacman-test -${{ github.sha }}
89+ path : ${{ env.PACMAN_CACHE }}
90+ key : pacman-${{ runner.os }} -${{ github.sha }}
8091 restore-keys : |
81- pacman-test -
92+ pacman-${{ runner.os }} -
8293
8394 - name : Set up Arch Linux Container
8495 run : |
85- mkdir -p /tmp/pacman-cache
96+ mkdir -p ${{ env.PACMAN_CACHE }}
8697 docker run --privileged --name arch-container -d \
87- -v ${{ github.workspace }}:/workdir \
88- -v /tmp/pacman-cache :/var/cache/pacman/pkg \
98+ -v ${{ github.workspace }}:${{ env.WORKSPACE }} \
99+ -v ${{ env.PACMAN_CACHE }} :/var/cache/pacman/pkg \
89100 archlinux:latest sleep infinity
90101
91102 - name : Install Dependencies
92103 run : |
93104 docker exec arch-container bash -c "
94105 set -euo pipefail
95- pacman -Sy --noconfirm
106+ pacman -Syu --noconfirm
96107 pacman -S --noconfirm --needed git archiso grub
97108 "
98109
@@ -101,34 +112,53 @@ jobs:
101112 run : |
102113 docker exec arch-container bash -c "
103114 set -euo pipefail
104- cd /workdir
105- rm -rf workdir/ out/
106- mkarchiso -v -w workdir/ -o out/ .
115+ cd ${{ env.WORKSPACE }}
116+ rm -rf ${{ env.BUILD_DIR }} ${{ env.OUTPUT_DIR }}
117+ mkdir -p ${{ env.BUILD_DIR }} ${{ env.OUTPUT_DIR }}
118+ mkarchiso -v -w ${{ env.BUILD_DIR }} -o ${{ env.OUTPUT_DIR }} .
107119 "
108120
109121 - name : Verify ISO
110122 run : |
111123 docker exec arch-container bash -c "
112- cd /workdir/out
124+ set -euo pipefail
125+ cd ${{ env.OUTPUT_DIR }}
126+
113127 # Check if ISO exists
114- [ -f *.iso ] || {
115- echo '::error::ISO file not found'
128+ iso_count=\$(ls -1 *.iso 2>/dev/null | wc -l)
129+ if [ \$iso_count -eq 0 ]; then
130+ echo '::error::No ISO file found'
116131 exit 1
117- }
132+ elif [ \$iso_count -gt 1 ]; then
133+ echo '::error::Multiple ISO files found'
134+ exit 1
135+ fi
136+
137+ iso_file=\$(ls *.iso)
138+
118139 # Check ISO size (minimum 500MB)
119- size=\$(stat -c%s *.iso)
120- [ \$size -gt 524288000 ] || {
121- echo '::error::ISO file too small'
140+ size=\$(stat -c%s \"\$iso_file\")
141+ if [ \$size -lt 524288000 ]; then
142+ echo \"::error::ISO file too small: \$((\$size / 1024 / 1024))MB\"
143+ exit 1
144+ fi
145+
146+ # Verify ISO checksum
147+ sha256sum \"\$iso_file\" > checksum.sha256
148+ sha256sum -c checksum.sha256 || {
149+ echo '::error::ISO checksum verification failed'
122150 exit 1
123151 }
124152 "
125153
126154 - name : Clean Up
127155 if : always()
128156 run : |
129- docker stop arch-container || true
130- docker rm arch-container || true
131- rm -rf workdir/ out/
157+ if docker ps -a | grep -q arch-container; then
158+ docker stop arch-container || true
159+ docker rm -f arch-container || true
160+ fi
161+ sudo rm -rf ${{ env.BUILD_DIR }} ${{ env.OUTPUT_DIR }}
132162
133163 - name : Report Status
134164 if : always()
0 commit comments