Execute commands only when successful

This commit is contained in:
Manuel Thalmann 2024-07-08 01:03:21 +02:00
parent 769b9e2f92
commit 9fe42686af
4 changed files with 24 additions and 20 deletions

View file

@ -14,17 +14,19 @@ begin
set -l nixDir "$profileDir/$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs" set -l nixDir "$profileDir/$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs"
mkdir -p "$rootHome" mkdir -p "$rootHome"
fish "$(status dirname)/../../scripts/copy-repo.fish" "$projectDir" and fish "$(status dirname)/../../scripts/copy-repo.fish" "$projectDir"
if [ ! -d "$nixCache" ] and begin
mkdir -p "$nixCache" if [ ! -d "$nixCache" ]
git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixVersion" "$nixCache" mkdir -p "$nixCache"
rm -rf "$nixCache/.git" and git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixVersion" "$nixCache"
and rm -rf "$nixCache/.git"
end
end end
sudo mount --mkdir -t overlay overlay -o lowerdir=.:"$overlayDir",upperdir="$upperDir",workdir="$workDir" "$profileDir" and sudo mount --mkdir -t overlay overlay -o lowerdir=.:"$overlayDir",upperdir="$upperDir",workdir="$workDir" "$profileDir"
sudo mount --mkdir --bind "$nixCache" "$nixDir" and sudo mount --mkdir --bind "$nixCache" "$nixDir"
sudo mkarchiso $argv "$profileDir" and sudo mkarchiso $argv "$profileDir"
sudo umount "$nixDir" sudo umount "$nixDir"
sudo umount "$profileDir" and sudo umount "$profileDir"
end end

View file

@ -8,17 +8,17 @@ begin
begin begin
. "$dir/template-path.fish" . "$dir/template-path.fish"
rm -rf "$contextRoot" rm -rf "$contextRoot"
cp -r "$(templatePath)" "$contextRoot" and cp -r "$(templatePath)" "$contextRoot"
chmod -R 755 "$contextRoot" and chmod -R 755 "$contextRoot"
git init "$contextRoot" and git init "$contextRoot"
git -C "$contextRoot" add . and git -C "$contextRoot" add .
begin and begin
git -C "$projectDir" ls-files git -C "$projectDir" ls-files
git -C "$projectDir" ls-files --exclude-standard --others git -C "$projectDir" ls-files --exclude-standard --others
end | \ end | \
rsync -r --include-from=/dev/stdin --exclude={.gitignore,README.md,scripts,LICENSE,valhalla.patch} "$dir/.." "$contextRoot" rsync -r --include-from=/dev/stdin --exclude={.gitignore,README.md,scripts,LICENSE,valhalla.patch} "$dir/.." "$contextRoot"
end 2>&1 > /dev/null; end 2>&1 > /dev/null;
git -C "$contextRoot" diff and git -C "$contextRoot" diff
end end

View file

@ -6,7 +6,9 @@ begin
. "$dir/template-path.fish" . "$dir/template-path.fish"
cp -r "$(templatePath)"/* "$projectDir" cp -r "$(templatePath)"/* "$projectDir"
if [ -f "$patch" ] and begin
git -C "$projectDir" apply --directory=archiso "$patch" if [ -f "$patch" ]
git -C "$projectDir" apply --directory=archiso "$patch"
end
end end
end end

View file

@ -3,10 +3,10 @@ begin
set -l target "$argv[1]" set -l target "$argv[1]"
set -l dir "$(status dirname)/.." set -l dir "$(status dirname)/.."
git clone "$dir" "$target" 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 while read file
cp "$dir/$file" "$target/$file" and cp "$dir/$file" "$target/$file"
end end
end end