Create image using an overlayfs

This commit is contained in:
Manuel Thalmann 2024-07-23 17:06:36 +02:00
parent 15742f29e1
commit 7e5915cab0

View file

@ -14,11 +14,14 @@ begin
set -l cacheDir ~/.cache/winiso-valhalla set -l cacheDir ~/.cache/winiso-valhalla
set -l isoFile "$buildDir/win.iso" set -l isoFile "$buildDir/win.iso"
set -l winPath "/media/win" set -l winPath "/media/win"
set -l winpePath "/media/winpe"
set -l valhallaPath "/media/winiso-valhalla"
set -l bootPath "/media/boot" set -l bootPath "/media/boot"
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 editionField "Edition ID" set -l editionField "Edition ID"
set -l wimFile "$dataPath/sources/install.wim" set -l wimFile "sources/install.wim"
set -l files set -l files
@ -91,8 +94,26 @@ begin
mkdir -p "$(dirname "$isoFile")" mkdir -p "$(dirname "$isoFile")"
sudo mount --mkdir "$WIN11_IMAGE_PATH" "$winPath" sudo mount --mkdir "$WIN11_IMAGE_PATH" "$winPath"
mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$isoFile" mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$isoFile"
sudo umount "$winPath"
rm -rf "$winpeOverlay" rm -rf "$winpeOverlay"
sudo mount --mkdir "$isoFile" "$winpePath"
begin
echo "$wimFile"
end | rsync --files-from=/dev/stdin "$winPath" "$winOverlay"
begin
set -l wimFile "$winOverlay/$wimFile"
while [ ! (wiminfo "$wimFile" 1 | grep "^$editionField" | cut -d ":" -f2 | string trim) = "Professional" ]
sudo wimdelete --soft "$wimFile" 1
end
while wiminfo "$wimFile" 2 &> /dev/null
sudo wimdelete --soft "$wimFile" 2
end
end
sudo mount --mkdir -t overlay overlay -o lowerdir="$winOverlay":"$winPath" "$valhallaPath"
if [ ! -b "$WIN_DISK" ] if [ ! -b "$WIN_DISK" ]
chooseDisk WIN_DISK chooseDisk WIN_DISK
@ -145,18 +166,16 @@ begin
sudo cp -r "$winPath"/* "$bootPath" sudo cp -r "$winPath"/* "$bootPath"
sudo umount "$winPath" sudo umount "$winPath"
sudo mount "$WIN11_IMAGE_PATH" "$winPath" sudo cp -r "$valhallaPath"/* "$dataPath"
sudo cp -r "$winPath"/* "$dataPath" sudo cp -r "$valhallaPath/efi" "$bootPath"
sudo cp -r "$winPath/efi" "$bootPath"
while [ ! (wiminfo "$wimFile" 1 | grep "^$editionField" | cut -d ":" -f2 | string trim) = "Professional" ] for path in "$valhallaPath" \
sudo wimdelete --soft "$wimFile" 1 "$winPath" \
"$winpePath" \
"$bootPath" \
"$dataPath"
sudo umount -vf "$path"
sudo rm -rf "$path"
end end
while wiminfo "$wimFile" 2 &> /dev/null
sudo wimdelete --soft "$wimFile" 2
end
sudo -- bash -c "umount -vf $(string escape "$winPath"); umount -vf $(string escape "$bootPath"); umount -vf $(string escape "$dataPath"); rm -rf $(string escape "$winPath") $(string escape "$dataPath");"
end end
end end