From 32272174c52fbf96b6f5c83d8507a59ffb7c779b Mon Sep 17 00:00:00 2001 From: Nikhil Dabas Date: Tue, 2 Feb 2021 22:58:38 +0530 Subject: [PATCH] Make script idempotent If the script fails on the first try, and is re-run later, it fails for two reasons: - The `mkdir build` commands fail - The `git clone` for `picoprobe` and `picotool` fail because those repos have already been cloned. This PR fixes these issues. This will also supersede/obsolete #6 and fix #10. --- pico_setup.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pico_setup.sh b/pico_setup.sh index 4a928d7..ce4d1db 100755 --- a/pico_setup.sh +++ b/pico_setup.sh @@ -83,7 +83,7 @@ source ~/.bashrc # Build a couple of examples cd "$OUTDIR/pico-examples" -mkdir build +mkdir -p build cd build cmake ../ -DCMAKE_BUILD_TYPE=Debug @@ -102,11 +102,14 @@ for REPO in picoprobe picotool do DEST="$OUTDIR/$REPO" REPO_URL="${GITHUB_PREFIX}${REPO}${GITHUB_SUFFIX}" - git clone $REPO_URL + if [ ! -d $DEST ]; then + git clone $REPO_URL + fi # Build both + echo "Building $REPO" cd $DEST - mkdir build + mkdir -p build cd build cmake ../ make -j$JNUM