From 26e3a86c787a4320d92a9be96e8b12b96a46e480 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 7 Apr 2021 11:49:35 +0200 Subject: [PATCH] garlic tool: check the presence of all the units This check prevents a user from removing units between the execution of the experiment and the fetch. --- garlic/sh/garlic | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/garlic/sh/garlic b/garlic/sh/garlic index e123d3a..49fe608 100755 --- a/garlic/sh/garlic +++ b/garlic/sh/garlic @@ -105,6 +105,10 @@ do_fetch() { exit 1 fi + unitNameList=$(grep '^/nix/store/.*-unit$' $experiment |\ + sort -u |\ + sed 's@^/nix/store/@@') + cwd=$(pwd) repeat=1 @@ -113,17 +117,21 @@ do_fetch() { cd $exp test $verbose && >&2 echo "$exp: checking units" - for unit in *-unit; do - cd $exp/$unit - if [ ! -e status ]; then - - test $verbose && >&2 echo "$unit: no status" + for unit in $unitNameList; do + if [ ! -e $exp/$unit ]; then + test $verbose && >&2 echo "$unit: missing unit" repeat=1 else - st=$(cat status) - test $verbose && >&2 echo "$unit: $st" - if [ "$st" != "completed" ]; then + cd $exp/$unit + if [ ! -e status ]; then + test $verbose && >&2 echo "$unit: no status" repeat=1 + else + st=$(cat status) + test $verbose && >&2 echo "$unit: $st" + if [ "$st" != "completed" ]; then + repeat=1 + fi fi fi done