copy_buildsync.sh: convert input copying logic to a func

Minor clean up ... should not be any real functional changes.
This commit is contained in:
Mike Frysinger 2016-03-20 17:44:59 -04:00
parent 2c172ab248
commit 6325704c08

View file

@ -1,5 +1,12 @@
#!/bin/bash #!/bin/bash
# Where artifacts are uploaded by builders.
INCOMING_BASE="/release/weekly/builds"
# Where artifacts are moved to so they can be uploaded to mirrors.
OUTGOING_BASE="/release/distfiles/weekly"
# Scratch space used when moving files from incoming to outgoing.
TMPDIR_BASE="/release/distfiles/tmp/buildsync/partial"
ARCHES=( ARCHES=(
alpha alpha
amd64 amd64
@ -43,20 +50,17 @@ EOF
exit ${1:-1} exit ${1:-1}
} }
process_arch() { # Copy artifacts for an arch to the outgoing directory.
local ARCH=$1 copy_arch_to_outgoing() {
local ARCH=$1 indir=$2 outdir=$3 tmpdir=$4
local i t rc
rc=0 if [[ ! -d ${indir} ]]; then
fail=0 # Nothing to do for this arch.
return
indir=/release/weekly/builds/${ARCH} fi
outdir=/release/distfiles/weekly/${ARCH}
tmpdir=/release/distfiles/tmp/buildsync/partial/${ARCH}
mkdir -p ${tmpdir} 2>/dev/null
# Copying # Copying
if [ -d "${indir}" ]; then
for i in $(find ${indir} -type f | grep -- '-20[0123][0-9]\{5\}' | sed -e 's:^.*-\(20[^.]\+\).*$:\1:' | sort -ur); do for i in $(find ${indir} -type f | grep -- '-20[0123][0-9]\{5\}' | sed -e 's:^.*-\(20[^.]\+\).*$:\1:' | sort -ur); do
#echo "Doing $i" #echo "Doing $i"
t="${outdir}/${i}" t="${outdir}/${i}"
@ -74,8 +78,22 @@ process_arch() {
| egrep -v current \ | egrep -v current \
| sort -r \ | sort -r \
| tr '\n' '\0' \ | tr '\n' '\0' \
|xargs -0 --no-run-if-empty rmdir --ignore-fail-on-non-empty | xargs -0 --no-run-if-empty rmdir --ignore-fail-on-non-empty
fi }
process_arch() {
local ARCH=$1
fail=0
indir="${INCOMING_BASE}/${ARCH}"
outdir="${OUTGOING_BASE}/${ARCH}"
tmpdir="${TMPDIR_BASE}/${ARCH}"
mkdir -p ${tmpdir} 2>/dev/null
# Sync incoming->outgoing first.
copy_arch_to_outgoing "${ARCH}" "${indir}" "${outdir}" "${tmpdir}"
# ================================================================ # ================================================================
# Build data for revealing latest: # Build data for revealing latest: