diff --git a/utils/GetFIleHashesFromISO.sh b/utils/GetFIleHashesFromISO.sh new file mode 100755 index 0000000..5305f51 --- /dev/null +++ b/utils/GetFIleHashesFromISO.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# DEFINE ERROR HANDLERS. +set -e +# Since we have set -e, any errors will cause the script to exit immediately, +# so we must trap EXIT instead. +trap cleanup EXIT +cleanup() { + echo -e "\nAttempting to clean up mount points and attached disks..." + # We don't want to show any more errors. + umount "$mount_point" + rmdir "$mount_point" + diskutil eject "$disk_identifier" +} + +# TODO: Verify the command line arguments and provide usage. + +# STORE THE PATHS. +iso_path="$1" +mount_point="$(mktemp -d)" +cwd="$(pwd)" + +# ATTACH THE DISK IMAGE. +# When a disk image contains an HFS volume, the disk must +# be attached and THEN mounted, which is just a fluke of +# newer Macs I guess. +# +# When a partition is successfully attached, +# `hdiutil` returns output like the following: +# /dev/disk4 Apple_partition_scheme +# /dev/disk4s1 Apple_partition_map +# /dev/disk4s2 ISO +# /dev/disk4s3 Apple_HFS +# +# The "ISO" line corresponds to the PC filesystem, and the +# Apple_HFS corresponds (of course) to the HFS volume. +partitions_on_attached_iso=$(hdiutil attach -nomount "$iso_path") +echo $partitions_on_attached_iso + +# MOUNT THE WINDOWS (CD9660) PORTION. +disk_identifier=$(echo "$partitions_on_attached_iso" | awk '{print $1}' | head -n 1) +echo "CD9660 Portion: $mount_point" +mount -t cd9660 "$disk_identifier" "$mount_point" + +# PRINT THE HASHES OF EACH FILE IN THE WINDODWS PORTION. +# This gets the hashes of all files in the root directory. +for file in "$mount_point"/*; do + md5sum "$file" 2> /dev/null +done | grep -v "Not a regular file" | sed "s|$mount_point/||" | awk '{ print $2, $1 }' +# This gets the hashes of all files in subdirectories. +for file in "$mount_point"/**/**; do + md5sum "$file" 2> /dev/null +done | grep -v "Not a regular file" | sed "s|$mount_point/||" | awk '{ print $2, $1 }' diff --git a/utils/ImageGoldenMaster.sh b/utils/ImageGoldenMaster.sh new file mode 100755 index 0000000..df96855 --- /dev/null +++ b/utils/ImageGoldenMaster.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +# READ THE COMMAND-LINE ARGUMENTS. +cdrom_device=$1 +index=$2 + +# READ THE CD TOC +cdrdao read-toc --device "$cdrom_device" "$index.toc" + +# CREATE AN ISO IMAGE. +ddrescue -b 2048 -r1 -v "$cdrom_device" "$index.iso" "$index.log" + +# MOUNT THE PC PART OF THE ISO. +echo "*** WINDOWS PARTITION ***" +mount_point=$(mktemp -d) +sudo mount "$index.iso" "$mount_point" +ls -la "$mount_point" +sudo umount "$mount_point" +rmdir "$mount_point" + +echo +echo "*** MAC PARTITION ***" +hmount "$index.iso" +hls +humount diff --git a/utils/README.md b/utils/README.md new file mode 100644 index 0000000..586cc77 --- /dev/null +++ b/utils/README.md @@ -0,0 +1,2 @@ +This folder holds scripts that are useful for developing and debugging Media Station, +but are not related to the main asset extraction.