diff --git a/Makefile b/Makefile index ecfc7e50d..f81666ae3 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ populate:;@ # usage: make rebuild system=foo [target=bar] [operation=switch] .PHONY: rebuild -rebuild: populate ;@ +rebuild: populate ;@set -x ssh root@"$$target" nixos-rebuild "$${operation-switch}" -I /var/src else diff --git a/krebs/v2/default.nix b/krebs/v2/default.nix index 7eb60103f..78e990d1c 100644 --- a/krebs/v2/default.nix +++ b/krebs/v2/default.nix @@ -15,26 +15,34 @@ let populate = '' #! /bin/sh - set -efu + set -eu + + verbose() { + printf '+' >&2 + printf ' %q' "$@" >&2 + printf '\n' + "$@" + } echo ${shell.escape git-script} \ | ssh ${shell.escape "${target-user}@${target-host}"} -T - tmpdir=$(mktemp -dt stockholm.XXXXXXXX) + unset tmpdir trap ' - set +f rm "$tmpdir"/* rmdir "$tmpdir" trap - EXIT INT QUIT ' EXIT INT QUIT + tmpdir=$(mktemp -dt stockholm.XXXXXXXX) chmod 0755 "$tmpdir" + ${concatStringsSep "\n" (mapAttrsToList (name: spec: let dst = removePrefix "symlink:" (get-url spec); in - "ln -s ${shell.escape dst} $tmpdir/${shell.escape name}") + "verbose ln -s ${shell.escape dst} $tmpdir/${shell.escape name}") symlink-specs)} - proot \ + verbose proot \ -b $tmpdir:${shell.escape target-path} \ ${concatStringsSep " \\\n " (mapAttrsToList @@ -77,6 +85,15 @@ let filterAttrs (_: spec: has-schema "symlink" (get-url spec)) source; git-script = '' + #! /bin/sh + set -efu + + verbose() { + printf '+' >&2 + printf ' %q' "$@" >&2 + printf '\n' + } + fetch_git() {( dst_dir=$1 src_url=$2 @@ -109,6 +126,7 @@ let ${concatStringsSep "\n" (mapAttrsToList (name: spec: toString (map shell.escape [ + "verbose" "fetch_git" "${target-path}/${name}" spec.url