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" \
"$winPath"
mkdir -p (dirname "$file")
and mkdir -p (dirname "$file")
if [ ! -f "$file" ]
and if [ ! -f "$file" ]
curl -L "$url" -o "$file"
end
begin
and begin
set -l tempDir (mktemp -d)
switch $type
and switch $type
case zip
unzip "$file" -d "$tempDir"
case exe
pushd "$tempDir" > /dev/null
7z x "$file"
popd > /dev/null
and 7z x "$file"
and popd > /dev/null
end
mkdir -p (dirname "$target")
cp -r "$tempDir/$dir" "$target"
rm -rf "$tempDir"
and mkdir -p (dirname "$target")
and cp -r "$tempDir/$dir" "$target"
and rm -rf "$tempDir"
end
end
@ -123,20 +123,20 @@ begin
set -l git $files[11..15]
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"
mkdir -p (dirname "$startupFile")
and mkdir -p (dirname "$startupFile")
begin
set -l path
for sw in git pwsh
and for sw in git pwsh
set -a path $$sw[1][5]
end
printf %s\n \
and printf %s\n \
"@echo off" (
string join ";" \
"set PATH=%PATH%" \
@ -166,68 +166,68 @@ begin
end | sudo tee "$startupFile" > /dev/null
end
mkdir -p "$(dirname "$winpe")"
sudo mount --mkdir $$varName "$winPath"
mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$winpe"
sudo mount --mkdir "$winpe" "$winpePath"
and mkdir -p "$(dirname "$winpe")"
and sudo mount --mkdir $$varName "$winPath"
and mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$winpe"
and sudo mount --mkdir "$winpe" "$winpePath"
begin
and begin
echo "$wimFile"
end | rsync --files-from=/dev/stdin "$winPath" "$winOverlay"
begin
and begin
set -l wimFile "$winOverlay/$wimFile"
chmod u+w (dirname "$wimFile")
chmod u+w "$wimFile"
and chmod u+w (dirname "$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
end
while wiminfo "$wimFile" 2 &> /dev/null
and while wiminfo "$wimFile" 2 &> /dev/null
wimdelete --soft "$wimFile" 2
end
wimoptimize "$wimFile"
chmod u-w "$wimFile"
chmod u-w (dirname "$wimFile")
and wimoptimize "$wimFile"
and chmod u-w "$wimFile"
and chmod u-w (dirname "$wimFile")
end
begin
set -l projectPath "$winOverlay/$localProjectPath"
set -l rootDir "$projectPath"
while [ ! -d "$rootDir" ]
and while [ ! -d "$rootDir" ]
set rootDir (dirname "$rootDir")
end
chmod u+w "$rootDir"
mkdir -p "$projectPath"
cp -r "$pwsh[4]" "$winOverlay/$systemDrivePath/$pwshPath"
source "$dir/../scripts/copy-repo.fish" "$projectPath"
rm -rf "$projectPath/archiso"
and chmod u+w "$rootDir"
and mkdir -p "$projectPath"
and cp -r "$pwsh[4]" "$winOverlay/$systemDrivePath/$pwshPath"
and fish "$dir/../scripts/copy-repo.fish" "$projectPath"
and rm -rf "$projectPath/archiso"
begin
and begin
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 file "$projectPath/.config/$name.json"
mkdir -p (dirname $file)
getConfig "valhalla.windows.config" --json > "$file"
and mkdir -p (dirname $file)
and getConfig "valhalla.windows.config" --json > "$file"
end
end
chmod -R u-w "$rootDir"
and chmod -R u-w "$rootDir"
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"
mkdir -p (dirname "$isoFile")
and mkdir -p (dirname "$isoFile")
mkisofs \
and mkisofs \
-V "$setupLabel" \
-no-emul-boot \
-b "efi/microsoft/boot/efisys.bin" \
@ -248,37 +248,37 @@ begin
"$dataPath"
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
end
sudo shred -vfzn 0 -s 512 "$winDisk"
and sudo shred -vfzn 0 -s 512 "$winDisk"
begin
and begin
printf %s\n \
"label: dos" \
"size=+2G type=uefi" \
"type=07"
end | sudo sfdisk "$winDisk"
sudo partprobe
sudo udevadm trigger
and sudo partprobe
and sudo udevadm trigger
begin
and begin
set -l disks
set -l diskPath (find -L /dev/disk/by-diskseq -samefile $winDisk)
set -l bootDisk "$diskPath-part1"
set -l dataDisk "$diskPath-part2"
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"
and sudo mkfs.fat -F 32 -n "BOOT" "$bootDisk"
and sudo mkfs.ntfs -fFL "$setupLabel" "$dataDisk"
and sudo mount --mkdir "$bootDisk" "$bootPath"
and sudo mount --mkdir "$dataDisk" "$dataPath"
and sudo cp -r "$winpePath"/* "$bootPath"
sudo cp -r "$valhallaPath"/* "$dataPath"
sudo cp -r "$valhallaPath/efi" "$bootPath"
and sudo cp -r "$valhallaPath"/* "$dataPath"
and sudo cp -r "$valhallaPath/efi" "$bootPath"
end
end