Allow creating ISO files for installing windows

This commit is contained in:
Manuel Thalmann 2024-07-23 20:10:58 +02:00
parent e6ea44a216
commit 24e557e95c

View file

@ -12,6 +12,7 @@ begin
set -l setupLabel "winiso-valhalla"
set -l buildDir "$(status dirname)/build"
set -l cacheDir ~/.cache/winiso-valhalla
set -l isoFile "$buildDir/winiso-valhalla.iso"
set -l winpe "$cacheDir/winpe.iso"
set -l winPath "/media/win"
set -l winpePath "/media/winpe"
@ -20,6 +21,8 @@ begin
set -l dataPath "/media/data"
set -l winpeOverlay (mktemp -d)
set -l winOverlay (mktemp -d)
set -l upperDir (mktemp -d)
set -l workDir (mktemp -d)
set -l editionField "Edition ID"
set -l wimFile "sources/install.wim"
@ -113,67 +116,82 @@ begin
end
end
sudo mount --mkdir -t overlay overlay -o lowerdir="$winOverlay":"$winPath" "$valhallaPath"
sudo mount --mkdir -t overlay overlay -o lowerdir="$winOverlay":"$winpePath":"$winPath",upperdir="$upperDir",workdir="$workDir" "$valhallaPath"
if [ ! -b "$WIN_DISK" ]
chooseDisk WIN_DISK
end
sudo shred -vfzn 0 -s 512 "$WIN_DISK"
begin
printf %s\n \
o \
n \
"" \
"" \
"" \
+2G \
y \
t \
c \
a \
"" \
\
n \
"" \
"" \
"" \
"" \
y \
t \
"" \
7 \
\
w
end | sudo fdisk "$WIN_DISK"
begin
set -l disks
while true
set disks (string split -n " " (bash -c "echo $WIN_DISK*"))
[ (count $disks) -ge 3 ] && break
if [ -z "$_flag_usb" ]
mkisofs \
-V "$setupLabel" \
-no-emul-boot \
-b "efi/microsoft/boot/efisys.bin" \
-iso-level 4 \
-udf \
-joliet \
-disable-deep-relocation \
-omit-version-number \
-relaxed-filenames \
-output "$isoFile" \
"$valhallaPath"
else
if [ ! -b "$WIN_DISK" ]
chooseDisk WIN_DISK
end
set -l bootDisk "$disks[2]"
set -l dataDisk "$disks[3]"
sudo mkfs.fat -F 32 -n "BOOT" "$bootDisk"
sudo mkfs.ntfs -fFL "$setupLabel" "$dataDisk"
sudo mount --mkdir "$bootDisk" "$bootPath"
sudo mount --mkdir "$dataDisk" "$dataPath"
sudo cp -r "$winpePath"/* "$bootPath"
sudo shred -vfzn 0 -s 512 "$WIN_DISK"
sudo cp -r "$valhallaPath"/* "$dataPath"
sudo cp -r "$valhallaPath/efi" "$bootPath"
begin
printf %s\n \
o \
n \
"" \
"" \
"" \
+2G \
y \
t \
c \
a \
"" \
\
n \
"" \
"" \
"" \
"" \
y \
t \
"" \
7 \
\
w
end | sudo fdisk "$WIN_DISK"
for path in "$valhallaPath" \
"$winPath" \
"$winpePath" \
"$bootPath" \
"$dataPath"
sudo umount -vf "$path"
sudo rm -rf "$path"
begin
set -l disks
while true
set disks (string split -n " " (bash -c "echo $WIN_DISK*"))
[ (count $disks) -ge 3 ] && break
end
set -l bootDisk "$disks[2]"
set -l dataDisk "$disks[3]"
sudo mkfs.fat -F 32 -n "BOOT" "$bootDisk"
sudo mkfs.ntfs -fFL "$setupLabel" "$dataDisk"
sudo mount --mkdir "$bootDisk" "$bootPath"
sudo mount --mkdir "$dataDisk" "$dataPath"
sudo cp -r "$winpePath"/* "$bootPath"
sudo cp -r "$valhallaPath"/* "$dataPath"
sudo cp -r "$valhallaPath/efi" "$bootPath"
for path in "$valhallaPath" \
"$winPath" \
"$winpePath" \
"$bootPath" \
"$dataPath"
sudo umount -vf "$path"
sudo rm -rf "$path"
end
end
end
end