copy_buildsync.sh: convert code to use arrays

This makes it a bit cleaner to work with arguments.
This commit is contained in:
Mike Frysinger 2016-03-20 16:46:11 -04:00
parent bebf046c7c
commit d14007c774

View file

@ -1,8 +1,22 @@
#!/bin/bash #!/bin/bash
ARCHES="alpha amd64 arm hppa ia64 ppc s390 sh sparc x86" ARCHES=(
#alpha amd64 arm hppa ia64 mips ppc s390 sh sparc x86 alpha
RSYNC_OPTS="-aO --delay-updates" amd64
arm
hppa
ia64
#mips
ppc
s390
sh
sparc
x86
)
RSYNC_OPTS=(
-aO
--delay-updates
)
DEBUG= DEBUG=
VERBOSE= VERBOSE=
EXTENSIONS="[.tar.xz,.tar.bz2,.tar.gz,.tar,.sfs]" EXTENSIONS="[.tar.xz,.tar.bz2,.tar.gz,.tar,.sfs]"
@ -16,11 +30,11 @@ DEBUGP=
VERBOSEP= VERBOSEP=
[ -n "$DEBUG" ] && DEBUGP=echo [ -n "$DEBUG" ] && DEBUGP=echo
[ -n "$DEBUG" ] && RSYNC_OPTS="${RSYNC_OPTS} -n" [ -n "$DEBUG" ] && RSYNC_OPTS+=( -n )
[ -n "$VERBOSE" ] && RSYNC_OPTS="${RSYNC_OPTS} -v" [ -n "$VERBOSE" ] && RSYNC_OPTS+=( -v )
[ -n "$VERBOSEP" ] && VERBOSEP="-v" [ -n "$VERBOSEP" ] && VERBOSEP="-v"
for ARCH in $ARCHES; do for ARCH in "${ARCHES[@]}"; do
rc=0 rc=0
fail=0 fail=0
@ -36,7 +50,7 @@ for ARCH in $ARCHES; do
#echo "Doing $i" #echo "Doing $i"
t="${outdir}/${i}" t="${outdir}/${i}"
mkdir -p ${t} 2>/dev/null mkdir -p ${t} 2>/dev/null
rsync ${RSYNC_OPTS} --temp-dir=${tmpdir} --partial-dir=${tmpdir} ${indir}/ --filter "S *${i}*" --filter 'S **/' --filter 'H *' ${t} rsync "${RSYNC_OPTS[@]}" --temp-dir=${tmpdir} --partial-dir=${tmpdir} ${indir}/ --filter "S *${i}*" --filter 'S **/' --filter 'H *' ${t}
rc=$? rc=$?
if [ $rc -eq 0 ]; then if [ $rc -eq 0 ]; then
find ${indir} -type f -name "*${i}*" -print0 | xargs -0 --no-run-if-empty $DEBUGP rm $VERBOSEP -f find ${indir} -type f -name "*${i}*" -print0 | xargs -0 --no-run-if-empty $DEBUGP rm $VERBOSEP -f