5858chmod +x " $MOCK_BIN /diskutil"
5959
6060# Mock mount (for check)
61- cat << EOF > "$MOCK_BIN /mount"
61+ # Will be overwritten later with correct path
62+ cat << 'EOF ' > "$MOCK_BIN/mount"
6263#!/bin/sh
63- echo "/dev/disk0s1 on $MOCK_VOLUMES /EFI (msdos, local, nodev, nosuid, noowners) "
64+ echo "mount mock "
6465EOF
6566chmod +x " $MOCK_BIN /mount"
6667
@@ -82,12 +83,7 @@ chmod +x "$MOCK_BIN/shutdown"
8283
8384echo " Running restore.sh in test environment..."
8485
85- # We need to modify restore.sh slightly to run in our test env (paths)
86- # or we can just symlink our mock repo to where the script expects it.
87- # The script expects ./BOOTEFIX64/EFI relative to CWD.
88-
8986# Copy restore.sh to test dir
90- # We assume restore.sh is in the parent directory
9187if [ ! -f " ../restore.sh" ]; then
9288 echo " Error: ../restore.sh not found!"
9389 exit 1
@@ -115,13 +111,17 @@ RUNTIME_MOCK_VOLUMES="./Volumes"
115111
116112# Replace /Volumes/EFI with our mock path
117113# Use | as delimiter to avoid escaping slashes
118- sed " s|/Volumes/EFI|$RUNTIME_MOCK_VOLUMES /EFI|g" " $TEST_DIR /restore.sh" > " $TEST_DIR /restore.sh.tmp"
114+ # We replace the whole line to be safe
115+ sed " s|EFI_MOUNT_POINT=\" /Volumes/EFI\" |EFI_MOUNT_POINT=\" $RUNTIME_MOCK_VOLUMES /EFI\" |g" " $TEST_DIR /restore.sh" > " $TEST_DIR /restore.sh.tmp"
119116mv " $TEST_DIR /restore.sh.tmp" " $TEST_DIR /restore.sh"
120117
121118# Replace /Volumes/EFI_BACKUP with our mock path
122- sed " s|/Volumes/EFI_BACKUP|$RUNTIME_MOCK_VOLUMES /EFI_BACKUP|g" " $TEST_DIR /restore.sh" > " $TEST_DIR /restore.sh.tmp"
119+ # We replace the whole line prefix
120+ sed " s|BACKUP_DIR=\" /Volumes/EFI_BACKUP_|BACKUP_DIR=\" $RUNTIME_MOCK_VOLUMES /EFI_BACKUP_|g" " $TEST_DIR /restore.sh" > " $TEST_DIR /restore.sh.tmp"
123121mv " $TEST_DIR /restore.sh.tmp" " $TEST_DIR /restore.sh"
124122
123+ chmod +x " $TEST_DIR /restore.sh"
124+
125125# Also update the mock mount script to return the path relative to CWD or absolute
126126# Since we are inside TEST_DIR, ./Volumes/EFI is correct.
127127cat << EOF > "$MOCK_BIN /mount"
@@ -130,8 +130,6 @@ echo "/dev/disk0s1 on $RUNTIME_MOCK_VOLUMES/EFI (msdos, local, nodev, nosuid, no
130130EOF
131131chmod +x " $MOCK_BIN /mount"
132132
133- chmod +x " $TEST_DIR /restore.sh"
134-
135133# Run the script
136134# We pipe "y" to confirm the prompt, and "enter" for the final prompt
137135cd " $TEST_DIR "
0 commit comments