Commit 375a0093c3bccb6ea3affefe0e80d517fa2c445b

Thomas de Grivel 2023-02-15T15:16:01

wip shpkg_ci

diff --git a/bin/shpkg_ci_mux b/bin/shpkg_ci_mux
index 44424a2..9ade0c0 100755
--- a/bin/shpkg_ci_mux
+++ b/bin/shpkg_ci_mux
@@ -20,8 +20,12 @@ verbose 2 shpkg_lock shpkg_ci_mux.lock
 
 shpkg_ci_remote () {
     verbose 1 ssh "$1" sh -c "\"shpkg/bin/shpkg_ci '$2'\""
-    if [ "x$2" != "x--upgrade" ]; then
-        verbose 1 rsync -a "$1":shpkg/ci/. "${SHPKG_CI_DIR}/"
+    if [ "x$2" == "x--clean" ]; then
+        rm -rf "${SHPKG_CI_DIR}"
+    else
+        if [ "x$2" != "x--upgrade" ]; then
+            verbose 1 rsync -a "$1":shpkg/ci/. "${SHPKG_CI_DIR}/"
+        fi
     fi
 }
 
@@ -34,7 +38,8 @@ main () {
     for SHPKG_CI_MUX_HOST; do
         wait
     done
-    if [ "x${SHPKG_REPO}" == "x--upgrade" ]; then
+    if [ "x${SHPKG_REPO}" == "x--upgrade" ] ||
+       [ "x${SHPKG_REPO}" == "x--clean" ]; then
         exit
     fi
     ( cd "${SHPKG_CI_DIR}/status" &&
diff --git a/share/shpkg/shpkg.subr b/share/shpkg/shpkg.subr
index b234cb4..e929eb5 100644
--- a/share/shpkg/shpkg.subr
+++ b/share/shpkg/shpkg.subr
@@ -817,7 +817,11 @@ shpkg_upgrade_shpkg () {
 #  running -> ko, ok
 # additionaly status will be changed to ko if aborted while running
 shpkg_ci_status () {
-    SHPKG_CI_STATUS="$(cat "${SHPKG_CI_STATUS_DIR}/$1")"
+    if [ -f "${SHPKG_CI_STATUS_DIR}/$1" ]; then
+        SHPKG_CI_STATUS="$(cat "${SHPKG_CI_STATUS_DIR}/$1")"
+    else
+        SHPKG_CI_STATUS=unknown
+    fi
     if [ "x$2" = "xrunning" ]; then
         verbose -n 1 "echo $2 > ${SHPKG_CI_STATUS_DIR}/$1"
         echo "$2" > "${SHPKG_CI_STATUS_DIR}/$1"