Exit winiso deployment early on error

This commit is contained in:
Manuel Thalmann 2024-09-23 00:14:10 +02:00
parent abb686c564
commit 45c5461c7a

View file

@ -94,27 +94,27 @@ begin
"$target" \ "$target" \
"$winPath" "$winPath"
mkdir -p (dirname "$file") and mkdir -p (dirname "$file")
if [ ! -f "$file" ] and if [ ! -f "$file" ]
curl -L "$url" -o "$file" curl -L "$url" -o "$file"
end end
begin and begin
set -l tempDir (mktemp -d) set -l tempDir (mktemp -d)
switch $type and switch $type
case zip case zip
unzip "$file" -d "$tempDir" unzip "$file" -d "$tempDir"
case exe case exe
pushd "$tempDir" > /dev/null pushd "$tempDir" > /dev/null
7z x "$file" and 7z x "$file"
popd > /dev/null and popd > /dev/null
end end
mkdir -p (dirname "$target") and mkdir -p (dirname "$target")
cp -r "$tempDir/$dir" "$target" and cp -r "$tempDir/$dir" "$target"
rm -rf "$tempDir" and rm -rf "$tempDir"
end end
end end
@ -123,20 +123,20 @@ begin
set -l git $files[11..15] set -l git $files[11..15]
set -l pwsh $files[16..20] set -l pwsh $files[16..20]
cp -r "$dir/winpefs"/* "$winpeOverlay" and cp -r "$dir/winpefs"/* "$winpeOverlay"
begin and begin
set -l startupFile "$winpeOverlay/Windows/System32/startnet.cmd" set -l startupFile "$winpeOverlay/Windows/System32/startnet.cmd"
mkdir -p (dirname "$startupFile") and mkdir -p (dirname "$startupFile")
begin begin
set -l path set -l path
for sw in git pwsh and for sw in git pwsh
set -a path $$sw[1][5] set -a path $$sw[1][5]
end end
printf %s\n \ and printf %s\n \
"@echo off" ( "@echo off" (
string join ";" \ string join ";" \
"set PATH=%PATH%" \ "set PATH=%PATH%" \
@ -166,68 +166,68 @@ begin
end | sudo tee "$startupFile" > /dev/null end | sudo tee "$startupFile" > /dev/null
end end
mkdir -p "$(dirname "$winpe")" and mkdir -p "$(dirname "$winpe")"
sudo mount --mkdir $$varName "$winPath" and sudo mount --mkdir $$varName "$winPath"
mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$winpe" and mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$winpe"
sudo mount --mkdir "$winpe" "$winpePath" and sudo mount --mkdir "$winpe" "$winpePath"
begin and begin
echo "$wimFile" echo "$wimFile"
end | rsync --files-from=/dev/stdin "$winPath" "$winOverlay" end | rsync --files-from=/dev/stdin "$winPath" "$winOverlay"
begin and begin
set -l wimFile "$winOverlay/$wimFile" set -l wimFile "$winOverlay/$wimFile"
chmod u+w (dirname "$wimFile") and chmod u+w (dirname "$wimFile")
chmod u+w "$wimFile" and chmod u+w "$wimFile"
while [ ! (wiminfo "$wimFile" 1 | grep "^$editionField" | cut -d ":" -f2 | string trim) = "Professional" ] and while [ ! (wiminfo "$wimFile" 1 | grep "^$editionField" | cut -d ":" -f2 | string trim) = "Professional" ]
wimdelete --soft "$wimFile" 1 wimdelete --soft "$wimFile" 1
end end
while wiminfo "$wimFile" 2 &> /dev/null and while wiminfo "$wimFile" 2 &> /dev/null
wimdelete --soft "$wimFile" 2 wimdelete --soft "$wimFile" 2
end end
wimoptimize "$wimFile" and wimoptimize "$wimFile"
chmod u-w "$wimFile" and chmod u-w "$wimFile"
chmod u-w (dirname "$wimFile") and chmod u-w (dirname "$wimFile")
end end
begin begin
set -l projectPath "$winOverlay/$localProjectPath" set -l projectPath "$winOverlay/$localProjectPath"
set -l rootDir "$projectPath" set -l rootDir "$projectPath"
while [ ! -d "$rootDir" ] and while [ ! -d "$rootDir" ]
set rootDir (dirname "$rootDir") set rootDir (dirname "$rootDir")
end end
chmod u+w "$rootDir" and chmod u+w "$rootDir"
mkdir -p "$projectPath" and mkdir -p "$projectPath"
cp -r "$pwsh[4]" "$winOverlay/$systemDrivePath/$pwshPath" and cp -r "$pwsh[4]" "$winOverlay/$systemDrivePath/$pwshPath"
source "$dir/../scripts/copy-repo.fish" "$projectPath" and fish "$dir/../scripts/copy-repo.fish" "$projectPath"
rm -rf "$projectPath/archiso" and rm -rf "$projectPath/archiso"
begin and begin
source "$dir/../scripts/Common/Scripts/config.fish" source "$dir/../scripts/Common/Scripts/config.fish"
for name in (getProfiles | jq '.[]' --raw-output0 | string split0) and for name in (getProfiles | jq '.[]' --raw-output0 | string split0)
set -l CONFIG_NAME "$name" set -l CONFIG_NAME "$name"
set -l file "$projectPath/.config/$name.json" set -l file "$projectPath/.config/$name.json"
mkdir -p (dirname $file) and mkdir -p (dirname $file)
getConfig "valhalla.windows.config" --json > "$file" and getConfig "valhalla.windows.config" --json > "$file"
end end
end end
chmod -R u-w "$rootDir" and chmod -R u-w "$rootDir"
end end
sudo mount --mkdir -t overlay overlay -o lowerdir="$winOverlay":"$winpePath":"$winPath",upperdir="$upperDir",workdir="$workDir" "$valhallaPath" and sudo mount --mkdir -t overlay overlay -o lowerdir="$winOverlay":"$winpePath":"$winPath",upperdir="$upperDir",workdir="$workDir" "$valhallaPath"
if [ -z "$_flag_usb" ] and if [ -z "$_flag_usb" ]
set -l isoFile "$(status dirname)/build/winiso-valhalla.iso" set -l isoFile "$(status dirname)/build/winiso-valhalla.iso"
mkdir -p (dirname "$isoFile") and mkdir -p (dirname "$isoFile")
mkisofs \ and mkisofs \
-V "$setupLabel" \ -V "$setupLabel" \
-no-emul-boot \ -no-emul-boot \
-b "efi/microsoft/boot/efisys.bin" \ -b "efi/microsoft/boot/efisys.bin" \
@ -248,37 +248,37 @@ begin
"$dataPath" "$dataPath"
chooseDisk winDisk chooseDisk winDisk
echo "Proceeding will cause the disk `$winDisk` to be wiped." and echo "Proceeding will cause the disk `$winDisk` to be wiped."
if ! confirm "Are you sure you want to continue?" "n" and if ! confirm "Are you sure you want to continue?" "n"
exit 1 exit 1
end end
sudo shred -vfzn 0 -s 512 "$winDisk" and sudo shred -vfzn 0 -s 512 "$winDisk"
begin and begin
printf %s\n \ printf %s\n \
"label: dos" \ "label: dos" \
"size=+2G type=uefi" \ "size=+2G type=uefi" \
"type=07" "type=07"
end | sudo sfdisk "$winDisk" end | sudo sfdisk "$winDisk"
sudo partprobe and sudo partprobe
sudo udevadm trigger and sudo udevadm trigger
begin and begin
set -l disks set -l disks
set -l diskPath (find -L /dev/disk/by-diskseq -samefile $winDisk) set -l diskPath (find -L /dev/disk/by-diskseq -samefile $winDisk)
set -l bootDisk "$diskPath-part1" set -l bootDisk "$diskPath-part1"
set -l dataDisk "$diskPath-part2" set -l dataDisk "$diskPath-part2"
sudo mkfs.fat -F 32 -n "BOOT" "$bootDisk" and sudo mkfs.fat -F 32 -n "BOOT" "$bootDisk"
sudo mkfs.ntfs -fFL "$setupLabel" "$dataDisk" and sudo mkfs.ntfs -fFL "$setupLabel" "$dataDisk"
sudo mount --mkdir "$bootDisk" "$bootPath" and sudo mount --mkdir "$bootDisk" "$bootPath"
sudo mount --mkdir "$dataDisk" "$dataPath" and sudo mount --mkdir "$dataDisk" "$dataPath"
sudo cp -r "$winpePath"/* "$bootPath" and sudo cp -r "$winpePath"/* "$bootPath"
sudo cp -r "$valhallaPath"/* "$dataPath" and sudo cp -r "$valhallaPath"/* "$dataPath"
sudo cp -r "$valhallaPath/efi" "$bootPath" and sudo cp -r "$valhallaPath/efi" "$bootPath"
end end
end end