[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] reproducible_live_build: publish function accepts more arguments

Holger Levsen (@holger) gitlab at salsa.debian.org
Mon Jun 6 15:45:49 BST 2022



Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net


Commits:
35a21dc4 by Roland Clobus at 2022-06-06T16:45:28+02:00
reproducible_live_build: publish function accepts more arguments

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


1 changed file:

- bin/reproducible_debian_live_sync_result.sh


Changes:

=====================================
bin/reproducible_debian_live_sync_result.sh
=====================================
@@ -15,25 +15,30 @@ set -u
 PROJECT=debian_live_build
 NODE=osuosl173-amd64.debian.net
 
-# Argument 1 = absolute path on $NODE
-# Argument 2 = published name
+# Argument 1 = description
+# Argument 2 = absolute path on $NODE
+# Argument 3 = published name
 rsync_remote_results() {
-    local origfile=$1
-    local filename=$(basename "$2")
-    echo "$(date -u) - Starting to sync the remote file '$filename'."
-    # copy the new results from build node to web server node
+    local description=$1
+    local origfile=$2
+    local filename=$(basename "$3")
+    echo "$(date -u) - Starting to sync $description to '$filename'."
+    # Copy the new results from the build node to the web server node
     cd "$BASE"/"$PROJECT"
     # Preserve timestamp
     scp -p -o Batchmode=yes "$NODE":"$origfile" "$filename.tmp"
     chmod 755 "$filename.tmp"
     mv "$filename.tmp" "$filename"
+    echo "$(date -u) - enjoy ${REPRODUCIBLE_URL}/${PROJECT}/${filename}"
 }
 
-# Argument 1 = filename part of the published name that was synced with 'rsync_remote_results'
+# Argument 1 = description
+# Argument 2 = filename part of the published name that was synced with 'rsync_remote_results'
 delete_live_build_file() {
-    local filetodelete=$1
+    local description=$1
+    local filetodelete=$2
     local filename=$(basename "$filetodelete")
-    echo "$(date -u) - Starting to delete the requested file '$filename'."
+    echo "$(date -u) - Delete $description: '$filename'."
     cd "$BASE"/"$PROJECT"
     if [[ "$filename" != "$filetodelete" ]]; then
         echo "E: You provided a full path, ignoring for safety" >&2
@@ -47,13 +52,19 @@ delete_live_build_file() {
     fi
 }
 
+parse_arguments() {
+    # The first argument is the name of the script
+    shift
+    if [ "$1" == "delete" ]; then
+        shift
+        delete_live_build_file "$@"
+    else
+        rsync_remote_results "$@"
+    fi
+}
+
 # main
-if [[ "${SSH_ORIGINAL_COMMAND#* }" =~ "^delete" ]]; then
-    # the # gets the whole command after the first space
-    # the ## gets the last part of the command, space-separated
-    delete_live_build_file "${SSH_ORIGINAL_COMMAND##* }"
-else
-    rsync_remote_results "${SSH_ORIGINAL_COMMAND##* }"
-fi
-
-echo "$(date -u) - the end."
+
+# Intentionally unquoted, so the space-separated arguments will be available individually
+parse_arguments ${SSH_ORIGINAL_COMMAND}
+



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/35a21dc44e05aa73def0e0b100fce2ee7a428ed8

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/35a21dc44e05aa73def0e0b100fce2ee7a428ed8
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20220606/3030b71f/attachment-0001.htm>


More information about the Qa-jenkins-scm mailing list