Skip to content

Commit 8acf95f

Browse files
hhromicXECDesign
authored andcommitted
Do not assume the changelog file is always present for the info file (#280)
The `(..)/raspberrypi-kernel/changelog.Debian.gz` file is not guaranteed to be present in the built `ROOTFS_DIR`, for example when building very minimal images without package documentation. In these cases, the `firmware` variable will be left empty and the subsequent calls to `curl` will return large 404 HTML content from GitHub. Instead, simply check if the changelog file exists before using it.
1 parent 407663a commit 8acf95f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

export-image/04-finalise/01-run.sh

+10-8
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,19 @@ cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE"
5050

5151

5252
{
53-
firmware=$(zgrep "firmware as of" \
54-
"$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" | \
55-
head -n1 | sed -n 's|.* \([^ ]*\)$|\1|p')
56-
printf "\nFirmware: https://github.com/raspberrypi/firmware/tree/%s\n" "$firmware"
53+
if [ -f "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" ]; then
54+
firmware=$(zgrep "firmware as of" \
55+
"$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" | \
56+
head -n1 | sed -n 's|.* \([^ ]*\)$|\1|p')
57+
printf "\nFirmware: https://github.com/raspberrypi/firmware/tree/%s\n" "$firmware"
5758

58-
kernel="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/git_hash")"
59-
printf "Kernel: https://github.com/raspberrypi/linux/tree/%s\n" "$kernel"
59+
kernel="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/git_hash")"
60+
printf "Kernel: https://github.com/raspberrypi/linux/tree/%s\n" "$kernel"
6061

61-
uname="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")"
62+
uname="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")"
63+
printf "Uname string: %s\n" "$uname"
64+
fi
6265

63-
printf "Uname string: %s\n" "$uname"
6466
printf "\nPackages:\n"
6567
dpkg -l --root "$ROOTFS_DIR"
6668
} >> "$INFO_FILE"

0 commit comments

Comments
 (0)