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