From 9fe42686af6681ec5a70bc6fb5c1fc7c58f01d75 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 8 Jul 2024 01:03:21 +0200 Subject: [PATCH] Execute commands only when successful --- archiso/scripts/build.fish | 20 +++++++++++--------- archiso/scripts/show-diff.fish | 12 ++++++------ archiso/scripts/update.fish | 6 ++++-- scripts/copy-repo.fish | 6 +++--- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/archiso/scripts/build.fish b/archiso/scripts/build.fish index 6dc96516..344a04ca 100755 --- a/archiso/scripts/build.fish +++ b/archiso/scripts/build.fish @@ -14,17 +14,19 @@ begin set -l nixDir "$profileDir/$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs" mkdir -p "$rootHome" - fish "$(status dirname)/../../scripts/copy-repo.fish" "$projectDir" + and fish "$(status dirname)/../../scripts/copy-repo.fish" "$projectDir" - if [ ! -d "$nixCache" ] - mkdir -p "$nixCache" - git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixVersion" "$nixCache" - rm -rf "$nixCache/.git" + and begin + if [ ! -d "$nixCache" ] + mkdir -p "$nixCache" + and git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixVersion" "$nixCache" + and rm -rf "$nixCache/.git" + end end - sudo mount --mkdir -t overlay overlay -o lowerdir=.:"$overlayDir",upperdir="$upperDir",workdir="$workDir" "$profileDir" - sudo mount --mkdir --bind "$nixCache" "$nixDir" - sudo mkarchiso $argv "$profileDir" + and sudo mount --mkdir -t overlay overlay -o lowerdir=.:"$overlayDir",upperdir="$upperDir",workdir="$workDir" "$profileDir" + and sudo mount --mkdir --bind "$nixCache" "$nixDir" + and sudo mkarchiso $argv "$profileDir" sudo umount "$nixDir" - sudo umount "$profileDir" + and sudo umount "$profileDir" end diff --git a/archiso/scripts/show-diff.fish b/archiso/scripts/show-diff.fish index 56c9e45f..2ec5c8f4 100755 --- a/archiso/scripts/show-diff.fish +++ b/archiso/scripts/show-diff.fish @@ -8,17 +8,17 @@ begin begin . "$dir/template-path.fish" rm -rf "$contextRoot" - cp -r "$(templatePath)" "$contextRoot" - chmod -R 755 "$contextRoot" - git init "$contextRoot" - git -C "$contextRoot" add . + and cp -r "$(templatePath)" "$contextRoot" + and chmod -R 755 "$contextRoot" + and git init "$contextRoot" + and git -C "$contextRoot" add . - begin + and begin git -C "$projectDir" ls-files git -C "$projectDir" ls-files --exclude-standard --others end | \ rsync -r --include-from=/dev/stdin --exclude={.gitignore,README.md,scripts,LICENSE,valhalla.patch} "$dir/.." "$contextRoot" end 2>&1 > /dev/null; - git -C "$contextRoot" diff + and git -C "$contextRoot" diff end diff --git a/archiso/scripts/update.fish b/archiso/scripts/update.fish index 1e062145..31d8188b 100755 --- a/archiso/scripts/update.fish +++ b/archiso/scripts/update.fish @@ -6,7 +6,9 @@ begin . "$dir/template-path.fish" cp -r "$(templatePath)"/* "$projectDir" - if [ -f "$patch" ] - git -C "$projectDir" apply --directory=archiso "$patch" + and begin + if [ -f "$patch" ] + git -C "$projectDir" apply --directory=archiso "$patch" + end end end diff --git a/scripts/copy-repo.fish b/scripts/copy-repo.fish index 2a87dd19..cc4eee9c 100755 --- a/scripts/copy-repo.fish +++ b/scripts/copy-repo.fish @@ -3,10 +3,10 @@ begin set -l target "$argv[1]" set -l dir "$(status dirname)/.." git clone "$dir" "$target" - git -C "$dir" diff HEAD | git -C "$target" apply --allow-empty + and git -C "$dir" diff HEAD | git -C "$target" apply --allow-empty - git -C "$dir" ls-files --exclude-standard --others | \ + and git -C "$dir" ls-files --exclude-standard --others | \ while read file - cp "$dir/$file" "$target/$file" + and cp "$dir/$file" "$target/$file" end end