Files
pxe-server/playbook/utilities/convert-cal-iso.sh
cproudlock e1ea6b7c62 Wax/Trace: switch baseline to FormTracePak v6.213 vendor install
Replace the V6.0 captured-binary replay (pf-x86-MitutoyoApp.zip +
c-MitutoyoApp.zip + hklm-wow-mitutoyo.reg.gz) with a real vendor install
from FORMTRACEPAK-V6.213.iso mounted via Mount-DiskImage.

09-Setup-WaxAndTrace.ps1:
- Step 2 rewritten: Mount-DiskImage on
  C:\WaxTrace-Install\formtracepak\FORMTRACEPAK-V6.213.iso, run the VB6
  Setup.exe wrapper from the assigned drive letter (DRIVE_CDROM check
  satisfied by virtual mount, no real CD needed), then Dismount.
- Header rewritten: drop captured/ description, note legacy fallback
  remains in the repo (captured-binary/ unchanged) for manual recovery
  if the v6.213 vendor install fails on a bay.

sync-waxtrace.sh:
- Push formtracepak/FORMTRACEPAK-V6.213.iso (2.0 GB) into the bundle
  instead of captured/ payload. Override path via $FTPAK_ISO env var if
  needed (e.g. testing a v6.213 patch ISO).
- Sanity check no longer demands pf-x86-MitutoyoApp.zip; only requires
  prereqs/ + the manifest + dispatcher PS1.

playbook/utilities/convert-cal-iso.sh:
- New helper. Rebuilds a Linux-dd of a multi-session UDF cal disc into
  a clean ISO9660+UDF hybrid that Windows Mount-DiskImage reads. mkisofs
  reads the file via loop-udf, repacks single-session with the asset tag
  as volume label. Run when `file CAL-*.iso` reports "data" (multi-session
  UDF dd produced a Linux-readable but Windows-unreadable container).
  Single-session 218-458A discs from dd are already ISO9660 and don't
  need this.

Verified on win11 VM via qga: V6.213 ISO mounts, Setup.exe locatable.
14 cal ISOs all converted to ISO9660 (md5s refreshed in INDEX.csv),
re-synced to /srv/samba/enrollment/installers-post/waxtrace/calibrations/.
PXE share bundle now 2.0 GB total (V6.213 ISO + 14 cal ISOs + prereqs).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 15:44:42 -04:00

84 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# Convert a Linux-dd multi-session UDF cal ISO into a Windows-readable
# single-session ISO+UDF hybrid. Mounts the dd file via UDF loop, copies
# files into a temp tree, repacks via mkisofs with ISO9660+UDF.
#
# Use this when a Mitutoyo cal disc was ripped with `dd if=/dev/sr0`
# (default Linux rip). For multi-session UDF discs `dd` captures session
# 1 only and truncates trailing UDF Anchor Volume Descriptor Pointers;
# the file mounts on Linux (loop-udf) but Windows Mount-DiskImage reports
# IsReady=False. mkisofs rebuilds clean metadata Windows reads. Linux
# still reads the result.
#
# Single-session discs (older 218-458A Mitutoyo pattern) are already
# ISO9660 from dd - no conversion needed. Run `file CAL-*.iso`:
# ISO 9660 = fine; "data" = convert.
#
# Usage: convert-cal-iso.sh <input.iso>
# Replaces input in place. Saves <input>.dd-backup on first run.
#
# Requires: sudo (loop-udf mount), mkisofs (genisoimage / cdrtools).
set -euo pipefail
ISO="$1"
test -f "$ISO" || { echo "Missing: $ISO"; exit 1; }
# Extract label from filename, e.g. CAL-WJF00052_... -> 12AAE675-ish.
# Use the asset tag as the volume label so it stays unique + greppable.
ASSET=$(basename "$ISO" | sed -n 's/^CAL-\([A-Za-z0-9]*\)_.*/\1/p')
test -n "$ASSET" || { echo "Could not parse asset from $ISO"; exit 1; }
LABEL="CAL-$ASSET"
# Length cap: ISO9660 vol id <= 32 chars
LABEL="${LABEL:0:32}"
STAGE=$(mktemp -d -p /tmp calconv.XXXX)
MNT="$STAGE/mnt"
TREE="$STAGE/tree"
mkdir -p "$MNT" "$TREE"
cleanup() {
if mountpoint -q "$MNT"; then sudo umount "$MNT" 2>/dev/null || true; fi
rm -rf "$STAGE"
}
trap cleanup EXIT
echo "[$ASSET] mount $ISO"
sudo mount -t udf -o loop,ro "$ISO" "$MNT"
echo "[$ASSET] copy"
cp -a "$MNT/." "$TREE/"
sudo umount "$MNT"
rmdir "$MNT" 2>/dev/null || true
# Verify expected files present (case-insensitive: older WJRP discs use Setup.exe)
test -d "$TREE/data" -o -d "$TREE/Data" -o -d "$TREE/DATA" || { echo "[$ASSET] missing data/ dir in tree"; exit 1; }
find "$TREE" -maxdepth 1 -iname 'setup.exe' -type f -print -quit | grep -q . || { echo "[$ASSET] missing setup.exe in tree"; exit 1; }
NEW="$STAGE/new.iso"
echo "[$ASSET] mkisofs -> $NEW"
mkisofs -V "$LABEL" \
-udf \
-iso-level 3 \
-J -joliet-long \
-r \
-o "$NEW" \
"$TREE" 2>&1 | tail -3
NEW_SIZE=$(stat -c %s "$NEW")
echo "[$ASSET] new size: $NEW_SIZE"
# Replace original (backup the dd version once)
BACKUP="${ISO}.dd-backup"
if [ ! -f "$BACKUP" ]; then
mv "$ISO" "$BACKUP"
echo "[$ASSET] backed up dd version -> $BACKUP"
else
rm "$ISO"
fi
mv "$NEW" "$ISO"
echo "[$ASSET] replaced. md5: $(md5sum $ISO | cut -d' ' -f1)"