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
# 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=(
alpha
amd64
@ -43,20 +50,17 @@ EOF
exit ${1:-1}
}
process_arch() {
local ARCH=$1
# 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
rc=0
fail=0
indir=/release/weekly/builds/${ARCH}
outdir=/release/distfiles/weekly/${ARCH}
tmpdir=/release/distfiles/tmp/buildsync/partial/${ARCH}
mkdir -p ${tmpdir} 2>/dev/null
if [[ ! -d ${indir} ]]; then
# Nothing to do for this arch.
return
fi
# 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
#echo "Doing $i"
t="${outdir}/${i}"
@ -75,7 +79,21 @@ process_arch() {
| sort -r \
| tr '\n' '\0' \
| 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: