commit:     9fa4c8f32c637c88bf5c0b7b3259781aba1f68a6
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 21 06:55:35 2018 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Nov 21 19:13:02 2018 +0000
URL:        https://gitweb.gentoo.org/proj/releng.git/commit/?id=9fa4c8f3

scripts/copy_buildsync: cleanup excludes of tempfile

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 scripts/copy_buildsync.sh | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/scripts/copy_buildsync.sh b/scripts/copy_buildsync.sh
index 6c6085ff..815d21de 100755
--- a/scripts/copy_buildsync.sh
+++ b/scripts/copy_buildsync.sh
@@ -62,7 +62,7 @@ EOF
 # Copy artifacts for an arch to the outgoing directory.
 copy_arch_to_outgoing() {
        local ARCH=$1 indir=$2 outdir=$3 tmpdir=$4
-       local i t rc
+       local i t rc timestamps
 
        if [[ ! -d ${indir} ]]; then
                # Nothing to do for this arch.
@@ -70,21 +70,48 @@ copy_arch_to_outgoing() {
        fi
 
        # Copying
-       for i in $(find ${indir} -not -path '*/\.*' -type f | egrep -- 
'-20[0123][0-9]{5}(([0-9]{6})|(T[0-9]{6}Z))?' | sed -e 
's:^.*-\(20[^.]\+\).*$:\1:' | sort -ur); do
+       timestamps=( $(
+               find "${indir}" \
+                               -regextype posix-egrep \
+                               -type f \
+                               -regex 
'.*-20[0123][0-9]{5}(([0-9]{6})|(T[0-9]{6}Z))?.*' \
+                               \( -not -path '*/\.*' \) \
+               | sed -e 's:^.*-\(20[^.]\+\).*$:\1:' \
+               | sort -ur
+               ) )
+
+       for i in "${timestamps[@]}" ; do
                #echo "Doing $i"
                t="${outdir}/${i}"
                mkdir -p ${t} 2>/dev/null
-               rsync "${RSYNC_OPTS[@]}" --temp-dir=${tmpdir} 
--partial-dir=${tmpdir} ${indir}/ --filter '- **/.*' --filter "S *${i}*" 
--filter 'S **/' --filter 'H *' ${t}
+               rsync \
+                       "${RSYNC_OPTS[@]}" \
+                       --temp-dir="${tmpdir}" \
+                       --partial-dir="${tmpdir}" \
+                       --filter '- **/.*' \
+                       --filter "S *${i}*" \
+                       --filter 'S **/' \
+                       --filter 'H *' \
+                       ${indir}/ \
+                       ${t}
                rc=$?
                if [ $rc -eq 0 ]; then
-                       find ${indir} -not -path '*/\.*' -type f -name "*${i}*" 
-print0 | xargs -0 --no-run-if-empty $DEBUGP rm $VERBOSEP -f
+                       find "${indir}" \
+                               -type f \
+                               -name "*${i}*" \
+                               \( -not -path '*/\.*' \) \
+                               -print0 \
+                               | xargs -0 --no-run-if-empty \
+                               "$DEBUGP" rm "$VERBOSEP" -f
                else
                        echo "Not deleting ${indir}/*${i}*, rsync failed!" 1>&2
                        fail=1
                fi
        done
        find "${outdir}" \
-               -depth -mindepth 1 -type d \
+               -depth \
+               -mindepth 1 \
+               -type d \
                -exec rmdir --ignore-fail-on-non-empty {} +
 }
 

Reply via email to