88 lines
2.6 KiB
Bash
Executable File
88 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
NOW=$(date +'%Y-%m-%d')
|
|
|
|
# Raspberry Pi images are built by modifying a Debian 12 image for the Raspberry
|
|
# Pi 4 family:
|
|
RASPBERRYPI_IMG_URL=https://pirogue.apt.debamax.com/raspi-images/raspi_4_bookworm.img.xz
|
|
RASPBERRYPI_SHA_URL="$RASPBERRYPI_IMG_URL.sha256"
|
|
|
|
# Use a stable name to avoid leaving various files behind when the URL gets
|
|
# updated:
|
|
RASPBERRYPI_IMG=raspi_4_bookworm.img
|
|
|
|
# Basename for the target images:
|
|
PIROGUE34_IMG="PiRogue-OS-12-Pi3_and_Pi4-$NOW.img"
|
|
PIROGUE5E_IMG="PiRogue-OS-12-Pi5-Experimental-$NOW.img"
|
|
|
|
# List of things we produce:
|
|
MANIFEST=$(realpath MANIFEST.txt)
|
|
TOP_DIR=$(pwd)
|
|
|
|
|
|
# Helpers:
|
|
# - prefer parallel compression if available:
|
|
xz_compress() {
|
|
FILE="$1"
|
|
|
|
# PTS images are published as compressed images alongside checksums for those
|
|
# compressed images (as opposed to checksums for the uncompressed images). To
|
|
# make sure everything is consistent, compare checksum of the original file
|
|
# vs. checksum of a decompressed compressed image:
|
|
echo "Computing checksum for $FILE..."
|
|
SUM1=$(sha256sum "$FILE" | awk '{print $1}')
|
|
echo " $SUM1"
|
|
|
|
if which pixz >/dev/null 2>&1; then
|
|
echo "Compressing $FILE with pixz..."
|
|
pixz "$FILE"
|
|
echo ' done'
|
|
else
|
|
echo "Compressing $FILE with xz..."
|
|
xz "$FILE"
|
|
echo ' done'
|
|
fi
|
|
|
|
echo "Computing checksum for $FILE after decompression..."
|
|
SUM2=$(xz -c -d "$FILE.xz" | sha256sum | awk '{print $1}')
|
|
if [ "$SUM1" = "$SUM2" ]; then
|
|
echo " $SUM2 (match)"
|
|
else
|
|
echo " $SUM2 (NO MATCH), exiting!"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# - compute checksum and remember both target file and checksum file:
|
|
checksum_and_publish() {
|
|
FILE="$1"
|
|
sha256sum "$FILE" > "$FILE.sha256"
|
|
SUB_DIR=$(pwd | sed "s,^$TOP_DIR/,,")
|
|
echo "$SUB_DIR/$FILE" >> "$MANIFEST"
|
|
echo "$SUB_DIR/$FILE.sha256" >> "$MANIFEST"
|
|
}
|
|
|
|
|
|
# Start afresh, manifest-wise:
|
|
rm -f "$MANIFEST"
|
|
|
|
# We might need to descend into different directories, subshells are
|
|
# a way to do that:
|
|
(
|
|
# Download and check (after switching to the stable name):
|
|
cd raspberrypi
|
|
wget -O $RASPBERRYPI_IMG.xz "$RASPBERRYPI_IMG_URL"
|
|
wget -O $RASPBERRYPI_IMG.xz.sha256 "$RASPBERRYPI_SHA_URL"
|
|
sed "s/ .*$/ $RASPBERRYPI_IMG.xz/" -i $RASPBERRYPI_IMG.xz.sha256
|
|
shasum -c $RASPBERRYPI_IMG.xz.sha256
|
|
|
|
# Modify, compress, and checksum:
|
|
sudo ./toaster $RASPBERRYPI_IMG.xz "$PIROGUE34_IMG" recipes/pi3-pi4.sh
|
|
sudo ./toaster $RASPBERRYPI_IMG.xz "$PIROGUE5E_IMG" recipes/pi5.sh
|
|
xz_compress "$PIROGUE34_IMG"
|
|
xz_compress "$PIROGUE5E_IMG"
|
|
checksum_and_publish "$PIROGUE34_IMG.xz"
|
|
checksum_and_publish "$PIROGUE5E_IMG.xz"
|
|
)
|