Fix archives script "File exists" spam 80/52780/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 3 Mar 2017 17:58:54 +0000 (12:58 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 3 Mar 2017 19:13:00 +0000 (14:13 -0500)
The archive scripts has a bug that causes it to spam "File exists" at
the end of a log. This patch improves the script to handle this a little
better.

A follow up patch will be submitted to fix ShellCheck issues.

Change-Id: I607afd4f4042d29f79d58c16eb735f124b72b393
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/include-raw-deploy-archives.sh

index 53d2991a54f02308ff1581b09ba1af72cde8722c..529fae30f20c22bc1c7b2b031e4b1b867c323aeb 100644 (file)
@@ -70,16 +70,17 @@ cat > deploy-archives.xml <<EOF
 </project>
 EOF
 
-mkdir -p $ARCHIVES_DIR
-mkdir -p $WORKSPACE/archives
-if [ ! -z "${{ARCHIVE_ARTIFACTS}}" ]; then
-    pushd $WORKSPACE
+mkdir -p "$ARCHIVES_DIR"
+mkdir -p "$WORKSPACE/archives"
+if [ ! -z "$ARCHIVE_ARTIFACTS" ]; then
+    pushd "$WORKSPACE"
     shopt -s globstar  # Enable globstar to copy archives
-    archive_artifacts=$(echo ${{ARCHIVE_ARTIFACTS}})
-    for f in $archive_artifacts; do
+    for f in $ARCHIVE_ARTIFACTS; do
+        [[ -e $f ]] || break  # handle the case of no files to archive
         echo "Archiving $f"
-        mkdir -p $WORKSPACE/archives/$(dirname $f)
-        mv $f $WORKSPACE/archives/$f
+        dir=$(dirname "$f")
+        mkdir -p "$WORKSPACE/archives/$dir"
+        mv "$f" "$WORKSPACE/archives/$f"
     done
     shopt -u globstar  # Disable globstar once archives are copied
     popd