Skip to content

Commit d35b6f4

Browse files
fix(ci): save kernel cache immediately after build and fix initramfs symlinks
- Split actions/cache into restore + save to cache kernel right after build, so failures in later steps don't waste the build - Fix build_initramfs.sh to use inline relative symlink creation instead of gen_links.sh which uses absolute paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cf71b17 commit d35b6f4

2 files changed

Lines changed: 26 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ jobs:
241241
echo "cross=arm-none-linux-gnueabihf-" >> "$GITHUB_OUTPUT"
242242
fi
243243
244-
- name: Cache Linux kernel
244+
- name: Restore Linux kernel cache
245245
id: cache-kernel
246-
uses: actions/cache@v4
246+
uses: actions/cache/restore@v4
247247
with:
248248
path: |
249249
third_party/linux/${{ steps.kernel.outputs.image }}
@@ -258,6 +258,16 @@ jobs:
258258
make ARCH=${{ steps.kernel.outputs.arch }} CROSS_COMPILE=${{ steps.kernel.outputs.cross }} ${{ steps.kernel.outputs.defconfig }}
259259
make ARCH=${{ steps.kernel.outputs.arch }} CROSS_COMPILE=${{ steps.kernel.outputs.cross }} -j$(nproc)
260260
261+
- name: Save Linux kernel cache
262+
if: steps.cache-kernel.outputs.cache-hit != 'true'
263+
uses: actions/cache/save@v4
264+
with:
265+
path: |
266+
third_party/linux/${{ steps.kernel.outputs.image }}
267+
third_party/linux/.config
268+
${{ matrix.target == 'armhf' && 'third_party/linux/arch/arm/boot/dts/arm/vexpress-v2p-ca9.dtb' || '' }}
269+
key: linux-kernel-${{ matrix.target }}-${{ hashFiles('third_party/linux/Makefile') }}-${{ steps.kernel.outputs.defconfig }}
270+
261271

262272
- name: Build initramfs (CFBox only, no busybox)
263273
run: |

scripts/build_initramfs.sh

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,30 +70,24 @@ case "$arch" in
7070
*) qemu_bin="qemu-$arch-static" ;;
7171
esac
7272

73-
# Try running cfbox directly; if it fails (foreign arch), use QEMU wrapper
73+
# Determine how to run the cross-compiled cfbox --list
74+
# Symlinks must use relative paths (cfbox, not absolute) for the initramfs.
7475
if "$initramfs/bin/cfbox" --list >/dev/null 2>&1; then
75-
"$project_dir/scripts/gen_links.sh" "$initramfs/bin"
76+
list_cmd="$initramfs/bin/cfbox"
77+
elif command -v "$qemu_bin" &>/dev/null; then
78+
list_cmd="$qemu_bin $initramfs/bin/cfbox"
7679
else
77-
if ! command -v "$qemu_bin" &>/dev/null; then
78-
echo "ERROR: $qemu_bin needed to run cross-compiled cfbox --list"
79-
exit 1
80-
fi
81-
# Create wrapper just for `--list` invocation
82-
qemu_wrapper="$(mktemp /tmp/cfbox-genlinks-XXXXXX.sh)"
83-
echo "#!/bin/sh" > "$qemu_wrapper"
84-
echo "exec $qemu_bin $initramfs/bin/cfbox \"\$@\"" >> "$qemu_wrapper"
85-
chmod +x "$qemu_wrapper"
86-
87-
# Get applet list via QEMU wrapper, create symlinks to the real binary
88-
while IFS= read -r line; do
89-
name=$(echo "$line" | awk '{print $1}')
90-
[[ -z "$name" ]] && continue
91-
ln -sf cfbox "$initramfs/bin/$name"
92-
echo " linked $name"
93-
done < <("$qemu_wrapper" --list)
94-
rm -f "$qemu_wrapper"
80+
echo "ERROR: $qemu_bin needed to run cross-compiled cfbox --list"
81+
exit 1
9582
fi
9683

84+
while IFS= read -r line; do
85+
name=$(echo "$line" | awk '{print $1}')
86+
[[ -z "$name" ]] && continue
87+
ln -sf cfbox "$initramfs/bin/$name"
88+
echo " linked $name"
89+
done < <($list_cmd --list)
90+
9791
# Create /init symlink — the kernel executes this first.
9892
# CFBox's init applet will detect PID 1 and mount filesystems automatically.
9993
ln -sf bin/cfbox "$initramfs/init"

0 commit comments

Comments
 (0)