From 7ddc35bbdb5cbf244111c56eab2653497b82c85f Mon Sep 17 00:00:00 2001 From: Stuart Longland Date: Sun, 3 Jul 2022 10:01:29 +1000 Subject: [PATCH] dist: Add support for `BIN/CUE` images and `ISO` images. Worth noting that SGI boot CDs are _NOT_ ISO-9660. For those of us used to 2048-byte sectored discs with a raw ISO-9660 or UDF file systems, SGI CDs are weird. They use 512-byte sectors and a SGI disklabel like a SGI hard drive would. They have multiple partitions (up to 16), and use the same filesystems as they would on a hard drive. Typically the convention is: - 8 is used for general-purpose volume file system data - 9 is the volume header partition, and is used to store the layout of the volume. It *must* start at sector 0. - 11 represents the "whole device" https://irix7.com/techpubs/007-2825-001.pdf page 6 details all the various conventions (note IRIX counts partitions from 0 not 1). Our support just loads from partition 8 without considering other partitions, since this seems to be the structure used for the foundation discs. --- scripts/dist.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/scripts/dist.sh b/scripts/dist.sh index 0810e03..e97f329 100644 --- a/scripts/dist.sh +++ b/scripts/dist.sh @@ -29,6 +29,14 @@ function formatdisk { } +### Extract an image from the given source file to the specified directory +function extractefs { + mount -t efs "$1" /mnt + rsync -aq /mnt/ $2 + umount /mnt +} + + ### Populate the distribution disk with CD images stored in irix/ ### Images must be in subfolders - multiple images in a directory will be copied on top of one another ### e.g. @@ -53,19 +61,56 @@ function copydist { SUB=${d::-1} mkdir -p /irix/$SUB + # Convert BIN/CUE files (e.g. archive.org) to raw EFS + for i in /vagrant/irix/$IRIXVERS/$SUB/*.bin + do + echo "Converting BIN/CUE image \"$i\" to ISO..." + i_bn="${i%%.bin}" + img="${i_bn}.img" + cue="${i_bn}.cue" + # Skip .bin missing .cue, or already extracted + if [ -f "$cue" ] ; then + # This will create ${i_bn}-01.iso + bchunk "$i" "$cue" "${i_bn}-" + fi + done + for i in /vagrant/irix/$IRIXVERS/$SUB/* do case "$( basename "$i" )" in *.tar.gz) # Tar/Gzip echo "Extracting files from \"$i\"..." - mkdir /irix/$SUB + if [ ! -d /irix/$SUB ]; then + mkdir /irix/$SUB + fi tar -C /irix/$SUB -xzpf "$i" ;; - *) # EFS image + *.bin|*.cue) # BIN/CUE image -- ignore + echo "Ignoring BIN/CUE image \"$i\"" + ;; + *.iso) # "ISO" image + echo "Copying files from \"$i\"..." + # loop-mount the "ISO" image, it will + # be a raw SGI disklabel (i.e. like a HDD), + # not really an ISO9660 image. We call it an "ISO" + # because bchunk does -- it won't let us call it + # anything else. + d="$( losetup -f -P -r --show "$i" )" + echo "- Loop-mounted at $d, waiting for part scan" + # EFS image is in partition 8 + echo "- Extracting from ${d}p8" + extractefs ${d}p8 /irix/$SUB + # Unmount loop image + losetup -d $d + ;; + *) # EFS image (assumed) echo "Copying files from \"$i\"..." - mount -o loop -t efs "$i" /mnt - rsync -aq /mnt/ /irix/$SUB - umount /mnt + # To keep extractefs simple, we'll do our own + # loop-mount here. + d="$( losetup -f -r --show "$i" )" + extractefs "$d" /irix/$SUB + # Unmount loop image + losetup -d $d ;; esac done