[arch-projects] [dbscripts] Various improvements
Hi, I work on the derivative of dbscripts for Parabola. Through the course of trying to merge git branches that haven't been synced in years, I ended up with some patches to your version of dbscripts, and figured I should try to contribute back! As your dbscripts works fine for you... I understand that many of these changes may be "unwelcome", and percieved as "change for the sake of change". I believe that each of these has at least some merit, but some less than others (at least grab the bugfix from patch 10!). -- Happy hacking, ~ Luke Shumaker
From: Luke Shumaker <LukeShu@sbcglobal.net> Other than pure quoting, this involved: - swapping */@ for array access in a few places - fiddling with printf in a pipeline - replacing `$(echo ${array[@]})` with `${array[*]}` - replacing `echo $(...)` with `...` When searching for these things, I used the command: grep -Prn --exclude-dir=.git '(?<!["=]|\[\[ |\[\[ -[zn] )\$(?!{?#|\(|\? )' and ignored a bunch of false positives. --- config | 2 +- cron-jobs/check_archlinux/parse_pkgbuilds.sh | 52 ++++++------ cron-jobs/devlist-mailer | 2 +- cron-jobs/ftpdir-cleanup | 36 ++++----- cron-jobs/integrity-check | 6 +- cron-jobs/sourceballs | 44 +++++----- cron-jobs/update-web-db | 20 ++--- db-functions | 117 +++++++++++++-------------- db-move | 62 +++++++------- db-remove | 24 +++--- db-repo-add | 22 ++--- db-repo-remove | 22 ++--- db-update | 40 ++++----- test/lib/common.inc | 116 +++++++++++++------------- test/packages/pkg-any-a/PKGBUILD | 4 +- test/packages/pkg-any-b/PKGBUILD | 4 +- test/packages/pkg-simple-a/PKGBUILD | 6 +- test/packages/pkg-simple-b/PKGBUILD | 6 +- test/packages/pkg-simple-epoch/PKGBUILD | 6 +- test/packages/pkg-split-a/PKGBUILD | 10 +-- test/packages/pkg-split-b/PKGBUILD | 10 +-- test/runTest | 10 +-- test/test.d/create-filelists.sh | 44 +++++----- test/test.d/db-move.sh | 64 +++++++-------- test/test.d/db-remove.sh | 48 +++++------ test/test.d/db-repo-add.sh | 28 +++---- test/test.d/db-repo-remove.sh | 36 ++++----- test/test.d/db-update.sh | 48 +++++------ test/test.d/ftpdir-cleanup.sh | 58 ++++++------- test/test.d/packages.sh | 2 +- test/test.d/signed-packages.sh | 8 +- test/test.d/sourceballs.sh | 44 +++++----- test/test.d/testing2x.sh | 2 +- testing2x | 34 ++++---- 34 files changed, 518 insertions(+), 519 deletions(-) diff --git a/config b/config index 3df6c95..6048209 100644 --- a/config +++ b/config @@ -34,4 +34,4 @@ SRCEXT=".src.tar.gz" ALLOWED_LICENSES=('GPL' 'GPL1' 'GPL2' 'LGPL' 'LGPL1' 'LGPL2' 'LGPL2.1') # Override default config with config.local -[ -f "$(dirname ${BASH_SOURCE[0]})/config.local" ] && . "$(dirname ${BASH_SOURCE[0]})/config.local" +[ -f "$(dirname "${BASH_SOURCE[0]}")/config.local" ] && . "$(dirname "${BASH_SOURCE[0]}")/config.local" diff --git a/cron-jobs/check_archlinux/parse_pkgbuilds.sh b/cron-jobs/check_archlinux/parse_pkgbuilds.sh index 3f92169..38af179 100755 --- a/cron-jobs/check_archlinux/parse_pkgbuilds.sh +++ b/cron-jobs/check_archlinux/parse_pkgbuilds.sh @@ -6,23 +6,23 @@ exit() { return; } splitpkg_overrides=('depends' 'optdepends' 'provides' 'conflicts') -variables=('pkgname' 'pkgbase' 'epoch' 'pkgver' 'pkgrel' 'makedepends' 'arch' ${splitpkg_overrides[@]}) +variables=('pkgname' 'pkgbase' 'epoch' 'pkgver' 'pkgrel' 'makedepends' 'arch' "${splitpkg_overrides[@]}") readonly -a variables splitpkg_overrides backup_package_variables() { - for var in ${splitpkg_overrides[@]}; do + for var in "${splitpkg_overrides[@]}"; do indirect="${var}_backup" - eval "${indirect}=(\${$var[@]})" + eval "${indirect}=(\"\${$var[@]}\")" done } restore_package_variables() { - for var in ${splitpkg_overrides[@]}; do + for var in "${splitpkg_overrides[@]}"; do indirect="${var}_backup" if [ -n "${!indirect}" ]; then - eval "${var}=(\${$indirect[@]})" + eval "${var}=(\"\${$indirect[@]}\")" else - unset ${var} + unset "${var}" fi done } @@ -42,31 +42,31 @@ print_info() { if [ -n "$arch" ]; then echo "%ARCH%" - for i in ${arch[@]}; do echo $i; done + for i in "${arch[@]}"; do echo "$i"; done echo "" fi if [ -n "$depends" ]; then echo "%DEPENDS%" - for i in ${depends[@]}; do - echo $i + for i in "${depends[@]}"; do + echo "$i" done echo "" fi if [ -n "$makedepends" ]; then echo "%MAKEDEPENDS%" - for i in ${makedepends[@]}; do - echo $i + for i in "${makedepends[@]}"; do + echo "$i" done echo "" fi if [ -n "$conflicts" ]; then echo "%CONFLICTS%" - for i in ${conflicts[@]}; do echo $i; done + for i in "${conflicts[@]}"; do echo "$i"; done echo "" fi if [ -n "$provides" ]; then echo "%PROVIDES%" - for i in ${provides[@]}; do echo $i; done + for i in "${provides[@]}"; do echo "$i"; done echo "" fi } @@ -75,10 +75,10 @@ source_pkgbuild() { ret=0 dir=$1 pkgbuild=$dir/PKGBUILD - for var in ${variables[@]}; do - unset ${var} + for var in "${variables[@]}"; do + unset "${var}" done - source $pkgbuild &>/dev/null || ret=$? + source "$pkgbuild" &>/dev/null || ret=$? # ensure $pkgname and $pkgver variables were found if [ $ret -ne 0 -o -z "$pkgname" -o -z "$pkgver" ]; then @@ -88,8 +88,8 @@ source_pkgbuild() { if [ "${#pkgname[@]}" -gt "1" ]; then pkgbase=${pkgbase:-${pkgname[0]}} - for pkg in ${pkgname[@]}; do - if [ "$(type -t package_${pkg})" != "function" ]; then + for pkg in "${pkgname[@]}"; do + if [ "$(type -t "package_${pkg}")" != "function" ]; then echo -e "%INVALID%\n$pkgbuild\n" return 1 else @@ -98,13 +98,13 @@ source_pkgbuild() { while IFS= read -r line; do var=${line%%=*} var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters - for realvar in ${variables[@]}; do + for realvar in "${variables[@]}"; do if [ "$var" == "$realvar" ]; then eval $line break fi done - done < <(type package_${pkg}) + done < <(type "package_${pkg}") print_info restore_package_variables fi @@ -124,14 +124,14 @@ find_pkgbuilds() { return fi - if [ -f $1/PKGBUILD ]; then - source_pkgbuild $1 + if [ -f "$1/PKGBUILD" ]; then + source_pkgbuild "$1" return fi empty=1 - for dir in $1/*; do - if [ -d $dir ]; then - find_pkgbuilds $dir + for dir in "$1"/*; do + if [ -d "$dir" ]; then + find_pkgbuilds "$dir" unset empty fi done @@ -147,7 +147,7 @@ fi CARCH=$1 shift for dir in "$@"; do - find_pkgbuilds $dir + find_pkgbuilds "$dir" done exit 0 diff --git a/cron-jobs/devlist-mailer b/cron-jobs/devlist-mailer index ca2e46b..61cd32c 100755 --- a/cron-jobs/devlist-mailer +++ b/cron-jobs/devlist-mailer @@ -23,6 +23,6 @@ echo "Subject: $SUBJECT To: $LIST From: $FROM -$stdin" | /usr/sbin/sendmail -F$FROM "$LIST" +$stdin" | /usr/sbin/sendmail -F"$FROM" "$LIST" fi diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 2683676..a2820e1 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -1,13 +1,13 @@ #!/bin/bash -. "$(dirname $0)/../config" -. "$(dirname $0)/../db-functions" +. "$(dirname "$0")/../config" +. "$(dirname "$0")/../db-functions" clean_pkg() { local pkg local target - if ! ${CLEANUP_DRYRUN}; then + if ! "${CLEANUP_DRYRUN}"; then for pkg in "$@"; do if [ -h "$pkg" ]; then rm -f "$pkg" "$pkg.sig" @@ -24,16 +24,16 @@ clean_pkg() { script_lock -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do - repo_lock ${repo} ${arch} || exit 1 +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do + repo_lock "${repo}" "${arch}" || exit 1 done done -${CLEANUP_DRYRUN} && warning 'dry run mode is active' +"${CLEANUP_DRYRUN}" && warning 'dry run mode is active' -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do if [ ! -f "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" ]; then continue fi @@ -45,7 +45,7 @@ for repo in ${PKGREPOS[@]}; do missing_pkgs=($(comm -13 "${WORKDIR}/repo-${repo}-${arch}" "${WORKDIR}/db-${repo}-${arch}")) if [ ${#missing_pkgs[@]} -ge 1 ]; then error "Missing packages in [${repo}] (${arch})..." - for missing_pkg in ${missing_pkgs[@]}; do + for missing_pkg in "${missing_pkgs[@]}"; do msg2 "${missing_pkg}" done fi @@ -53,7 +53,7 @@ for repo in ${PKGREPOS[@]}; do old_pkgs=($(comm -23 "${WORKDIR}/repo-${repo}-${arch}" "${WORKDIR}/db-${repo}-${arch}")) if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old packages from [${repo}] (${arch})..." - for old_pkg in ${old_pkgs[@]}; do + for old_pkg in "${old_pkgs[@]}"; do msg2 "${old_pkg}" clean_pkg "${FTP_BASE}/${repo}/os/${arch}/${old_pkg}" done @@ -69,27 +69,27 @@ find "${WORKDIR}" -maxdepth 1 -type f -name 'db-*' -exec cat {} \; | sort -u > " old_pkgs=($(comm -23 "${WORKDIR}/pool" "${WORKDIR}/db")) if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old packages from package pool..." - for old_pkg in ${old_pkgs[@]}; do + for old_pkg in "${old_pkgs[@]}"; do msg2 "${old_pkg}" clean_pkg "$FTP_BASE/${PKGPOOL}/${old_pkg}" done fi -old_pkgs=($(find ${CLEANUP_DESTDIR} -type f -name "*${PKGEXT}" -mtime +${CLEANUP_KEEP} -printf '%f\n')) +old_pkgs=($(find "${CLEANUP_DESTDIR}" -type f -name "*${PKGEXT}" -mtime +"${CLEANUP_KEEP}" -printf '%f\n')) if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old packages from the cleanup directory..." - for old_pkg in ${old_pkgs[@]}; do + for old_pkg in "${old_pkgs[@]}"; do msg2 "${old_pkg}" - if ! ${CLEANUP_DRYRUN}; then + if ! "${CLEANUP_DRYRUN}"; then rm -f "${CLEANUP_DESTDIR}/${old_pkg}" rm -f "${CLEANUP_DESTDIR}/${old_pkg}.sig" fi done fi -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do - repo_unlock ${repo} ${arch} +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do + repo_unlock "${repo}" "${arch}" done done diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check index f6c26cf..e77eac7 100755 --- a/cron-jobs/integrity-check +++ b/cron-jobs/integrity-check @@ -1,6 +1,6 @@ #!/bin/bash -dirname="$(dirname $0)" +dirname="$(dirname "$0")" . "${dirname}/../config" . "${dirname}/../db-functions" @@ -13,12 +13,12 @@ fi mailto=$1 check() { - ${dirname}/check_archlinux/check_packages.py \ + "${dirname}"/check_archlinux/check_packages.py \ --repos="${repos}" \ --abs-tree="/srv/abs/rsync/${arch},/srv/abs/rsync/any" \ --repo-dir="${FTP_BASE}" \ --arch="${arch}" \ - 2>&1 | ${dirname}/devlist-mailer "Integrity Check ${arch}: ${repos}" "${mailto}" + 2>&1 | "${dirname}"/devlist-mailer "Integrity Check ${arch}: ${repos}" "${mailto}" } repos='core,extra,community' diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index 4126c37..dee849a 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -1,15 +1,15 @@ #!/bin/bash -dirname="$(dirname $(readlink -e $0))" +dirname="$(dirname "$(readlink -e "$0")")" . "${dirname}/../config" . "${dirname}/../db-functions" pushd "${WORKDIR}" >/dev/null script_lock -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do - repo_lock ${repo} ${arch} || exit 1 +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do + repo_lock "${repo}" "${arch}" || exit 1 done done @@ -18,8 +18,8 @@ renice +10 -p $$ > /dev/null # Create a readable file for each repo with the following format # <pkgbase|pkgname> <pkgver>-<pkgrel> <arch> <license>[ <license>] -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do # Repo does not exist; skip it if [ ! -f "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" ]; then continue @@ -39,9 +39,9 @@ for repo in ${PKGREPOS[@]}; do done | sort -u > "${WORKDIR}/db-${repo}" done -for repo in ${PKGREPOS[@]}; do - for arch in ${ARCHES[@]}; do - repo_unlock ${repo} ${arch} +for repo in "${PKGREPOS[@]}"; do + for arch in "${ARCHES[@]}"; do + repo_unlock "${repo}" "${arch}" done done @@ -49,22 +49,22 @@ done find "${FTP_BASE}/${SRCPOOL}" -xtype f -name "*${SRCEXT}" -printf '%f\n' | sort -u > "${WORKDIR}/available-src-pkgs" # Check for all packages if we need to build a source package -for repo in ${PKGREPOS[@]}; do +for repo in "${PKGREPOS[@]}"; do newpkgs=() failedpkgs=() while read line; do - pkginfo=(${line}) + pkginfo=("${line}") pkgbase=${pkginfo[0]} pkgver=${pkginfo[1]} pkgarch=${pkginfo[2]} - pkglicense=(${pkginfo[@]:3}) + pkglicense=("${pkginfo[@]:3}") # Should this package be skipped? if grep -Fqx "${pkgbase}" "${dirname}/sourceballs.skip"; then continue fi # Check if the license or .force file does not enforce creating a source package - if ! ([[ -z ${ALLOWED_LICENSES[@]} ]] || chk_license ${pkglicense[@]} || grep -Fqx "${pkgbase}" "${dirname}/sourceballs.force"); then + if ! ([[ -z ${ALLOWED_LICENSES[*]} ]] || chk_license "${pkglicense[@]}" || grep -Fqx "${pkgbase}" "${dirname}/sourceballs.force"); then continue fi # Store the expected file name of the source package @@ -73,7 +73,7 @@ for repo in ${PKGREPOS[@]}; do # Build the source package if its not already there if ! grep -Fqx "${pkgbase}-${pkgver}${SRCEXT}" "${WORKDIR}/available-src-pkgs"; then # Check if we had failed before - if in_array "${pkgbase}-${pkgver}${SRCEXT}" ${failedpkgs[@]}; then + if in_array "${pkgbase}-${pkgver}${SRCEXT}" "${failedpkgs[@]}"; then continue fi @@ -104,13 +104,13 @@ for repo in ${PKGREPOS[@]}; do if [ ${#newpkgs[@]} -ge 1 ]; then msg "Adding source packages for [${repo}]..." - for new_pkg in ${newpkgs[@]}; do + for new_pkg in "${newpkgs[@]}"; do msg2 "${new_pkg}" done fi if [ ${#failedpkgs[@]} -ge 1 ]; then msg "Failed to create source packages for [${repo}]..." - for failed_pkg in ${failedpkgs[@]}; do + for failed_pkg in "${failedpkgs[@]}"; do msg2 "${failed_pkg}" done fi @@ -123,22 +123,22 @@ old_pkgs=($(comm -23 "${WORKDIR}/available-src-pkgs.sort" "${WORKDIR}/expected-s if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old source packages..." - ${SOURCE_CLEANUP_DRYRUN} && warning 'dry run mode is active' - for old_pkg in ${old_pkgs[@]}; do + "${SOURCE_CLEANUP_DRYRUN}" && warning 'dry run mode is active' + for old_pkg in "${old_pkgs[@]}"; do msg2 "${old_pkg}" - if ! ${SOURCE_CLEANUP_DRYRUN}; then + if ! "${SOURCE_CLEANUP_DRYRUN}"; then mv_acl "$FTP_BASE/${SRCPOOL}/${old_pkg}" "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" touch "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" fi done fi -old_pkgs=($(find ${SOURCE_CLEANUP_DESTDIR} -type f -name "*${SRCEXT}" -mtime +${SOURCE_CLEANUP_KEEP} -printf '%f\n')) +old_pkgs=($(find "${SOURCE_CLEANUP_DESTDIR}" -type f -name "*${SRCEXT}" -mtime +"${SOURCE_CLEANUP_KEEP}" -printf '%f\n')) if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old source packages from the cleanup directory..." - for old_pkg in ${old_pkgs[@]}; do + for old_pkg in "${old_pkgs[@]}"; do msg2 "${old_pkg}" - ${SOURCE_CLEANUP_DRYRUN} || rm -f "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" + "${SOURCE_CLEANUP_DRYRUN}" || rm -f "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" done fi diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db index 195d1fc..1a725dc 100755 --- a/cron-jobs/update-web-db +++ b/cron-jobs/update-web-db @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname $0)/../config" -. "$(dirname $0)/../db-functions" +. "$(dirname "$0")/../config" +. "$(dirname "$0")/../db-functions" # setup paths SPATH="/srv/http/archweb" @@ -43,26 +43,26 @@ case "$cmd" in esac # Lock the repos and get a copy of the db files to work on -for repo in ${REPOS[@]}; do - for arch in ${ARCHES[@]}; do - repo_lock ${repo} ${arch} || exit 1 +for repo in "${REPOS[@]}"; do + for arch in "${ARCHES[@]}"; do + repo_lock "${repo}" "${arch}" || exit 1 dbfile="/srv/ftp/${repo}/os/${arch}/${repo}${dbfileext}" if [ -f "${dbfile}" ]; then mkdir -p "${WORKDIR}/${repo}/${arch}" cp "${dbfile}" "${WORKDIR}/${repo}/${arch}/${repo}${dbfileext}" fi - repo_unlock ${repo} ${arch} + repo_unlock "${repo}" "${arch}" done done # Run reporead on our db copy -pushd $SPATH >/dev/null -for repo in ${REPOS[@]}; do - for arch in ${ARCHES[@]}; do +pushd "$SPATH" >/dev/null +for repo in "${REPOS[@]}"; do + for arch in "${ARCHES[@]}"; do dbcopy="${WORKDIR}/${repo}/${arch}/${repo}${dbfileext}" if [ -f "${dbcopy}" ]; then echo "Updating ${repo}-${arch}" >> "${LOGOUT}" - ./manage.py reporead ${flags} ${arch} "${dbcopy}" >> "${LOGOUT}" 2>&1 + ./manage.py reporead "${flags}" "${arch}" "${dbcopy}" >> "${LOGOUT}" 2>&1 echo "" >> "${LOGOUT}" fi done diff --git a/db-functions b/db-functions index 7e1b3aa..a40f2bb 100644 --- a/db-functions +++ b/db-functions @@ -12,7 +12,7 @@ set_umask () { } restore_umask () { - umask $UMASK >/dev/null + umask "$UMASK" >/dev/null } # just like mv -f, but we touch the file and then copy the content so @@ -81,7 +81,7 @@ in_array() { [[ -z $1 ]] && return 1 # Not Found local item for item in "$@"; do - [[ $item = $needle ]] && return 0 # Found + [[ $item = "$needle" ]] && return 0 # Found done return 1 # Not Found } @@ -93,16 +93,16 @@ in_array() { get_full_version() { if [[ $1 -eq 0 ]]; then # zero epoch case, don't include it in version - echo $2-$3 + echo "$2-$3" else - echo $1:$2-$3 + echo "$1:$2-$3" fi } script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then - local _owner="$(/usr/bin/stat -c %U $LOCKDIR)" + local _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" error "Script ${0##*/} is already locked by $_owner." exit 1 else @@ -130,12 +130,12 @@ cleanup() { local arch trap - EXIT INT QUIT TERM - for l in ${LOCKS[@]}; do + for l in "${LOCKS[@]}"; do repo=${l%.*} arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then msg "Removing left over lock from [${repo}] (${arch})" - repo_unlock $repo $arch + repo_unlock "$repo" "$arch" fi done if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then @@ -148,7 +148,7 @@ cleanup() { date +%s > "${FTP_BASE}/lastupdate" fi - [ "$1" ] && exit $1 + [ "$1" ] && exit "$1" } abort() { @@ -196,9 +196,9 @@ repo_lock () { fi _count=0 - while [ $_count -le $_trial ] || $_lockblock ; do + while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then - _owner="$(/usr/bin/stat -c %U $LOCKDIR)" + _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" warning "Repo [${1}] (${2}) is already locked by $_owner. " msg2 "Retrying in $LOCK_DELAY seconds..." else @@ -206,7 +206,7 @@ repo_lock () { set_umask return 0 fi - sleep $LOCK_DELAY + sleep "$LOCK_DELAY" let _count=$_count+1 done @@ -311,45 +311,45 @@ getpkgfile() { elif [ ! -f "${1}" ]; then error "Package ${1} not found!" exit 1 - elif ${REQUIRE_SIGNATURE} && [ ! -f "${1}.sig" ]; then + elif "${REQUIRE_SIGNATURE}" && [ ! -f "${1}.sig" ]; then error "Package signature ${1}.sig not found!" exit 1 fi - echo ${1} + echo "${1}" } getpkgfiles() { local f - if [ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]; then + if [ ! -z "$(printf '%s\n' "${@%\.*}" | sort | uniq -D)" ]; then error 'Duplicate packages found!' exit 1 fi - for f in ${@}; do + for f in "${@}"; do if [ ! -f "${f}" ]; then error "Package ${f} not found!" exit 1 - elif ${REQUIRE_SIGNATURE} && [ ! -f "${f}.sig" ]; then + elif "${REQUIRE_SIGNATURE}" && [ ! -f "${f}.sig" ]; then error "Package signature ${f}.sig not found!" exit 1 fi done - echo ${@} + echo "${@}" } check_pkgfile() { local pkgfile=$1 - local pkgname="$(getpkgname ${pkgfile})" + local pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgver="$(getpkgver ${pkgfile})" + local pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgarch="$(getpkgarch ${pkgfile})" + local pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 - in_array "${pkgarch}" ${ARCHES[@]} 'any' || return 1 + in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1 if echo "${pkgfile##*/}" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then return 0 @@ -360,17 +360,17 @@ check_pkgfile() { check_pkgsvn() { local pkgfile="${1}" - local _pkgbase="$(getpkgbase ${pkgfile})" + local _pkgbase="$(getpkgbase "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgname="$(getpkgname ${pkgfile})" + local _pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgver="$(getpkgver ${pkgfile})" + local _pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local _pkgarch="$(getpkgarch ${pkgfile})" + local _pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 local repo="${2}" - in_array "${repo}" ${PKGREPOS[@]} || return 1 + in_array "${repo}" "${PKGREPOS[@]}" || return 1 if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}" @@ -379,11 +379,11 @@ check_pkgsvn() { [ $? -ge 1 ] && return 1 fi - local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) )" + local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}")" [ "${svnver}" == "${_pkgver}" ] || return 1 - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) - in_array "${_pkgname}" ${svnnames[@]} || return 1 + local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) + in_array "${_pkgname}" "${svnnames[@]}" || return 1 return 0 } @@ -391,7 +391,7 @@ check_pkgsvn() { check_splitpkgs() { local repo="${1}" shift - local pkgfiles=(${@}) + local pkgfiles=("${@}") local pkgfile local pkgdir local svnname @@ -399,11 +399,11 @@ check_splitpkgs() { mkdir -p "${WORKDIR}/check_splitpkgs/" pushd "${WORKDIR}/check_splitpkgs" >/dev/null - for pkgfile in ${pkgfiles[@]}; do + for pkgfile in "${pkgfiles[@]}"; do issplitpkg "${pkgfile}" || continue - local _pkgbase="$(getpkgbase ${pkgfile})" - local _pkgname="$(getpkgname ${pkgfile})" - local _pkgarch="$(getpkgarch ${pkgfile})" + local _pkgbase="$(getpkgbase "${pkgfile}")" + local _pkgname="$(getpkgname "${pkgfile}")" + local _pkgarch="$(getpkgarch "${pkgfile}")" mkdir -p "${repo}/${_pkgarch}/${_pkgbase}" echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging" @@ -414,9 +414,8 @@ check_splitpkgs() { [ $? -ge 1 ] && return 1 fi - local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]})) - for svnname in ${svnnames[@]}; do - echo "${svnname}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" + local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) + printf '%s\n' in "${svnnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" done done popd >/dev/null @@ -436,11 +435,11 @@ check_splitpkgs() { check_pkgrepos() { local pkgfile=$1 - local pkgname="$(getpkgname ${pkgfile})" + local pkgname="$(getpkgname "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgver="$(getpkgver ${pkgfile})" + local pkgver="$(getpkgver "${pkgfile}")" [ $? -ge 1 ] && return 1 - local pkgarch="$(getpkgarch ${pkgfile})" + local pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 @@ -454,8 +453,8 @@ check_pkgrepos() { #usage: chk_license ${license[@]}" chk_license() { local l - for l in ${@}; do - in_array ${l} ${ALLOWED_LICENSES[@]} && return 0 + for l in "${@}"; do + in_array "${l}" "${ALLOWED_LICENSES[@]}" && return 0 done return 1 @@ -467,16 +466,16 @@ check_repo_permission() { [ ${#PKGREPOS[@]} -eq 0 ] && return 1 [ -z "${PKGPOOL}" ] && return 1 - in_array "${repo}" ${PKGREPOS[@]} || return 1 + in_array "${repo}" "${PKGREPOS[@]}" || return 1 [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1 local arch - for arch in ${ARCHES}; do + for arch in "${ARCHES}"; do local dir="${FTP_BASE}/${repo}/os/${arch}/" [ -w "${dir}" ] || return 1 - [ -f "${dir}"${repo}${DBEXT} -a ! -w "${dir}"${repo}${DBEXT} ] && return 1 - [ -f "${dir}"${repo}${FILESEXT} -a ! -w "${dir}"${repo}${FILESEXT} ] && return 1 + [ -f "${dir}${repo}"${DBEXT} -a ! -w "${dir}${repo}"${DBEXT} ] && return 1 + [ -f "${dir}${repo}"${FILESEXT} -a ! -w "${dir}${repo}"${FILESEXT} ] && return 1 done return 0 @@ -490,9 +489,9 @@ set_repo_permission() { if [ -w "${dbfile}" ]; then local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")") - chgrp $group "${dbfile}" || error "Could not change group of ${dbfile} to $group" - chgrp $group "${filesfile}" || error "Could not change group of ${filesfile} to $group" - chmod g+w "${dbfile}" || error "Could not set write permission for group $group to ${dbfile}" + chgrp "$group" "${dbfile}" || error "Could not change group of ${dbfile} to $group" + chgrp "$group" "${filesfile}" || error "Could not change group of ${filesfile} to $group" + chmod g+w "${dbfile}" || error "Could not set write permission for group $group to ${dbfile}" chmod g+w "${filesfile}" || error "Could not set write permission for group $group to ${filesfile}" else error "You don't have permission to change ${dbfile}" @@ -502,14 +501,14 @@ set_repo_permission() { arch_repo_add() { local repo=$1 local arch=$2 - local pkgs=(${@:3}) + local pkgs=("${@:3}") # package files might be relative to repo dir pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null - /usr/bin/repo-add -q "${repo}${DBEXT}" ${pkgs[@]} \ - || error "repo-add ${repo}${DBEXT} ${pkgs[@]}" - /usr/bin/repo-add -f -q "${repo}${FILESEXT}" ${pkgs[@]} \ - || error "repo-add -f ${repo}${FILESEXT} ${pkgs[@]}" + /usr/bin/repo-add -q "${repo}${DBEXT}" "${pkgs[@]}" \ + || error "repo-add ${repo}${DBEXT} ${pkgs[*]}" + /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ + || error "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" @@ -519,7 +518,7 @@ arch_repo_add() { arch_repo_remove() { local repo=$1 local arch=$2 - local pkgs=(${@:3}) + local pkgs=("${@:3}") local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" @@ -527,10 +526,10 @@ arch_repo_remove() { error "No database found at '${dbfile}'" return 1 fi - /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} \ - || error "repo-remove ${dbfile} ${pkgs[@]}" - /usr/bin/repo-remove -q "${filesfile}" ${pkgs[@]} \ - || error "repo-remove ${filesfile} ${pkgs[@]}" + /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" \ + || error "repo-remove ${dbfile} ${pkgs[*]}" + /usr/bin/repo-remove -q "${filesfile}" "${pkgs[@]}" \ + || error "repo-remove ${filesfile} ${pkgs[*]}" set_repo_permission "${repo}" "${arch}" REPO_MODIFIED=1 diff --git a/db-move b/db-move index 1fa44d4..4828e75 100755 --- a/db-move +++ b/db-move @@ -1,55 +1,55 @@ #!/bin/bash -. "$(dirname $0)/config" -. "$(dirname $0)/db-functions" +. "$(dirname "$0")/config" +. "$(dirname "$0")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} <repo-from> <repo-to> <pkgname|pkgbase> ..." exit 1 fi -args=(${@}) +args=("${@}") repo_from="${args[0]}" repo_to="${args[1]}" ftppath_from="${FTP_BASE}/${repo_from}/os/" ftppath_to="${FTP_BASE}/${repo_to}/os/" -if ! check_repo_permission $repo_to || ! check_repo_permission $repo_from; then +if ! check_repo_permission "$repo_to" || ! check_repo_permission "$repo_from"; then die "You don't have permission to move packages from ${repo_from} to ${repo_to}" fi # TODO: this might lock too much (architectures) -for pkgarch in ${ARCHES[@]}; do - repo_lock ${repo_to} ${pkgarch} || exit 1 - repo_lock ${repo_from} ${pkgarch} || exit 1 +for pkgarch in "${ARCHES[@]}"; do + repo_lock "${repo_to}" "${pkgarch}" || exit 1 + repo_lock "${repo_from}" "${pkgarch}" || exit 1 done # check if packages to be moved exist in svn and ftp dir arch_svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null -for pkgbase in ${args[@]:2}; do +for pkgbase in "${args[@]:2}"; do arch_svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null - for pkgarch in ${ARCHES[@]} 'any'; do + for pkgarch in "${ARCHES[@]}" 'any'; do svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" if [ -r "${svnrepo_from}/PKGBUILD" ]; then - pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) + pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo "${pkgname[@]}")) if [ ${#pkgnames[@]} -lt 1 ]; then die "Could not read pkgname" fi - pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) + pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") if [ -z "${pkgver}" ]; then die "Could not read pkgver" fi if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("${pkgarch}") fi - for pkgname in ${pkgnames[@]}; do - for tarch in ${tarches[@]}; do - getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT} >/dev/null + for pkgname in "${pkgnames[@]}"; do + for tarch in "${tarches[@]}"; do + getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} >/dev/null done done continue 2 @@ -62,21 +62,21 @@ msg "Moving packages from [${repo_from}] to [${repo_to}]..." declare -A add_pkgs declare -A remove_pkgs -for pkgbase in ${args[@]:2}; do +for pkgbase in "${args[@]:2}"; do tag_list="" - for pkgarch in ${ARCHES[@]} 'any'; do + for pkgarch in "${ARCHES[@]}" 'any'; do svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" svnrepo_to="${WORKDIR}/svn/${pkgbase}/repos/${repo_to}-${pkgarch}" if [ -f "${svnrepo_from}/PKGBUILD" ]; then if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("${pkgarch}") fi - msg2 "${pkgbase} ($(echo ${tarches[@]}))" - pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) - pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) + msg2 "${pkgbase} (${tarches[*]})" + pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo "${pkgname[@]}")) + pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") if [ -d "${svnrepo_to}" ]; then for file in $(arch_svn ls "${svnrepo_to}"); do @@ -93,14 +93,14 @@ for pkgbase in ${args[@]:2}; do arch_svn rm --force -q "${svnrepo_from}" tag_list="$tag_list, $pkgarch" - for pkgname in ${pkgnames[@]}; do - for tarch in ${tarches[@]}; do - pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) + for pkgname in "${pkgnames[@]}"; do + for tarch in "${tarches[@]}"; do + pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}) pkgfile="${pkgpath##*/}" - ln -s "../../../${PKGPOOL}/${pkgfile}" ${ftppath_to}/${tarch}/ - if [ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig ]; then - ln -s "../../../${PKGPOOL}/${pkgfile}.sig" ${ftppath_to}/${tarch}/ + ln -s "../../../${PKGPOOL}/${pkgfile}" "${ftppath_to}/${tarch}/" + if [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig" ]; then + ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "${ftppath_to}/${tarch}/" fi add_pkgs[${tarch}]+="${FTP_BASE}/${PKGPOOL}/${pkgfile} " remove_pkgs[${tarch}]+="${pkgname} " @@ -112,14 +112,14 @@ for pkgbase in ${args[@]:2}; do arch_svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "${0##*/}: moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${tag_list})" done -for tarch in ${ARCHES[@]}; do +for tarch in "${ARCHES[@]}"; do if [ -n "${add_pkgs[${tarch}]}" ]; then arch_repo_add "${repo_to}" "${tarch}" ${add_pkgs[${tarch}]} arch_repo_remove "${repo_from}" "${tarch}" ${remove_pkgs[${tarch}]} fi done -for pkgarch in ${ARCHES[@]}; do - repo_unlock ${repo_from} ${pkgarch} - repo_unlock ${repo_to} ${pkgarch} +for pkgarch in "${ARCHES[@]}"; do + repo_unlock "${repo_from}" "${pkgarch}" + repo_unlock "${repo_to}" "${pkgarch}" done diff --git a/db-remove b/db-remove index 25cb9a7..f23cd9e 100755 --- a/db-remove +++ b/db-remove @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname $0)/config" -. "$(dirname $0)/db-functions" +. "$(dirname "$0")/config" +. "$(dirname "$0")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} <repo> <arch> <pkgname|pkgbase> ..." @@ -10,32 +10,32 @@ fi repo="$1" arch="$2" -pkgbases=(${@:3}) +pkgbases=("${@:3}") ftppath="$FTP_BASE/$repo/os" svnrepo="$repo-$arch" -if ! check_repo_permission $repo; then +if ! check_repo_permission "$repo"; then die "You don't have permission to remove packages from ${repo}" fi if [ "$arch" == "any" ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("$arch") fi -for tarch in ${tarches[@]}; do - repo_lock $repo $tarch || exit 1 +for tarch in "${tarches[@]}"; do + repo_lock "$repo" "$tarch" || exit 1 done remove_pkgs=() -for pkgbase in ${pkgbases[@]}; do +for pkgbase in "${pkgbases[@]}"; do msg "Removing $pkgbase from [$repo]..." arch_svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then - remove_pkgs=(${remove_pkgs[@]} $(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) + remove_pkgs=("${remove_pkgs[@]}" $(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) arch_svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" arch_svn commit -q "${WORKDIR}/svn/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)" else @@ -46,7 +46,7 @@ for pkgbase in ${pkgbases[@]}; do fi done -for tarch in ${tarches[@]}; do - arch_repo_remove "${repo}" "${tarch}" ${remove_pkgs[@]} - repo_unlock $repo $tarch +for tarch in "${tarches[@]}"; do + arch_repo_remove "${repo}" "${tarch}" "${remove_pkgs[@]}" + repo_unlock "$repo" "$tarch" done diff --git a/db-repo-add b/db-repo-add index 5d5b653..a53884e 100755 --- a/db-repo-add +++ b/db-repo-add @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname $0)/config" -. "$(dirname $0)/db-functions" +. "$(dirname "$0")/config" +. "$(dirname "$0")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} <repo> <arch> <pkgfile> ..." @@ -10,32 +10,32 @@ fi repo="$1" arch="$2" -pkgfiles=(${@:3}) +pkgfiles=("${@:3}") ftppath="$FTP_BASE/$repo/os" -if ! check_repo_permission $repo; then +if ! check_repo_permission "$repo"; then die "You don't have permission to add packages to ${repo}" fi if [ "$arch" == "any" ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("$arch") fi -for tarch in ${tarches[@]}; do - repo_lock $repo $tarch || exit 1 +for tarch in "${tarches[@]}"; do + repo_lock "$repo" "$tarch" || exit 1 done -for tarch in ${tarches[@]}; do - for pkgfile in ${pkgfiles[@]}; do +for tarch in "${tarches[@]}"; do + for pkgfile in "${pkgfiles[@]}"; do if [[ ! -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}" ]]; then die "Package file ${pkgfile##*/} not found in ${FTP_BASE}/${repo}/os/${arch}/" else msg "Adding $pkgfile to [$repo]..." fi done - arch_repo_add "${repo}" "${tarch}" ${pkgfiles[@]} - repo_unlock $repo $tarch + arch_repo_add "${repo}" "${tarch}" "${pkgfiles[@]}" + repo_unlock "$repo" "$tarch" done diff --git a/db-repo-remove b/db-repo-remove index 2a693f4..df746fb 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname $0)/config" -. "$(dirname $0)/db-functions" +. "$(dirname "$0")/config" +. "$(dirname "$0")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} <repo> <arch> <pkgname> ..." @@ -10,28 +10,28 @@ fi repo="$1" arch="$2" -pkgnames=(${@:3}) +pkgnames=("${@:3}") ftppath="$FTP_BASE/$repo/os" -if ! check_repo_permission $repo; then +if ! check_repo_permission "$repo"; then die "You don't have permission to remove packages from ${repo}" fi if [ "$arch" == "any" ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("$arch") fi -for tarch in ${tarches[@]}; do - repo_lock $repo $tarch || exit 1 +for tarch in "${tarches[@]}"; do + repo_lock "$repo" "$tarch" || exit 1 done -for tarch in ${tarches[@]}; do - for pkgname in ${pkgnames[@]}; do +for tarch in "${tarches[@]}"; do + for pkgname in "${pkgnames[@]}"; do msg "Removing $pkgname from [$repo]..." done - arch_repo_remove "${repo}" "${tarch}" ${pkgnames[@]} - repo_unlock $repo $tarch + arch_repo_remove "${repo}" "${tarch}" "${pkgnames[@]}" + repo_unlock "$repo" "$tarch" done diff --git a/db-update b/db-update index cdc35a5..ec3c0f9 100755 --- a/db-update +++ b/db-update @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname $0)/config" -. "$(dirname $0)/db-functions" +. "$(dirname "$0")/config" +. "$(dirname "$0")/db-functions" if [ $# -ge 1 ]; then warning "Calling ${0##*/} with a specific repository is no longer supported" @@ -15,34 +15,34 @@ if [ $? -ge 1 ]; then fi repos=() -for staging_repo in ${staging_repos[@]##*/}; do - if in_array ${staging_repo} ${PKGREPOS[@]}; then - repos+=(${staging_repo}) +for staging_repo in "${staging_repos[@]##*/}"; do + if in_array "${staging_repo}" "${PKGREPOS[@]}"; then + repos+=("${staging_repo}") fi done # TODO: this might lock too much (architectures) -for repo in ${repos[@]}; do - for pkgarch in ${ARCHES[@]}; do - repo_lock ${repo} ${pkgarch} || exit 1 +for repo in "${repos[@]}"; do + for pkgarch in "${ARCHES[@]}"; do + repo_lock "${repo}" "${pkgarch}" || exit 1 done done # check if packages are valid -for repo in ${repos[@]}; do +for repo in "${repos[@]}"; do if ! check_repo_permission "${repo}"; then die "You don't have permission to update packages in ${repo}" fi pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) if [ $? -eq 0 ]; then - for pkg in ${pkgs[@]}; do + for pkg in "${pkgs[@]}"; do if [ -h "${pkg}" ]; then die "Package ${repo}/${pkg##*/} is a symbolic link" fi if ! check_pkgfile "${pkg}"; then die "Package ${repo}/${pkg##*/} is not consistent with its meta data" fi - if ${REQUIRE_SIGNATURE} && ! pacman-key -v "${pkg}.sig" >/dev/null 2>&1; then + if "${REQUIRE_SIGNATURE}" && ! pacman-key -v "${pkg}.sig" >/dev/null 2>&1; then die "Package ${repo}/${pkg##*/} does not have a valid signature" fi if ! check_pkgsvn "${pkg}" "${repo}"; then @@ -55,7 +55,7 @@ for repo in ${repos[@]}; do die "Package ${repo}/${pkg##*/} does not have a valid packager" fi done - if ! check_splitpkgs ${repo} ${pkgs[@]}; then + if ! check_splitpkgs "${repo}" "${pkgs[@]}"; then die "Missing split packages for ${repo}" fi else @@ -63,13 +63,13 @@ for repo in ${repos[@]}; do fi done -for repo in ${repos[@]}; do +for repo in "${repos[@]}"; do msg "Updating [${repo}]..." any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) - for pkgarch in ${ARCHES[@]}; do + for pkgarch in "${ARCHES[@]}"; do add_pkgs=() - arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXT} 2>/dev/null)) - for pkg in ${arch_pkgs[@]} ${any_pkgs[@]}; do + arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-"${pkgarch}"${PKGEXT} 2>/dev/null)) + for pkg in "${arch_pkgs[@]}" "${any_pkgs[@]}"; do pkgfile="${pkg##*/}" msg2 "${pkgfile} (${pkgarch})" # any packages might have been moved by the previous run @@ -87,13 +87,13 @@ for repo in ${repos[@]}; do add_pkgs[${#add_pkgs[*]}]=${pkgfile} done if [ ${#add_pkgs[@]} -ge 1 ]; then - arch_repo_add "${repo}" "${pkgarch}" ${add_pkgs[@]} + arch_repo_add "${repo}" "${pkgarch}" "${add_pkgs[@]}" fi done done -for repo in ${repos[@]}; do - for pkgarch in ${ARCHES[@]}; do - repo_unlock ${repo} ${pkgarch} +for repo in "${repos[@]}"; do + for pkgarch in "${ARCHES[@]}"; do + repo_unlock "${repo}" "${pkgarch}" done done diff --git a/test/lib/common.inc b/test/lib/common.inc index aeceece..bb3db5b 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,9 +1,9 @@ set -E -. "$(dirname ${BASH_SOURCE[0]})/../../config" +. "$(dirname "${BASH_SOURCE[0]}")/../../config" # override the default TMPDIR -TMPDIR="$(mktemp -d /tmp/${0##*/}.XXXXXXXXXX)" -. "$(dirname ${BASH_SOURCE[0]})/../../db-functions" +TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXXXX")" +. "$(dirname "${BASH_SOURCE[0]}")/../../db-functions" signpkg() { if [[ -r '/etc/makepkg.conf' ]]; then @@ -15,9 +15,9 @@ signpkg() { . ~/.makepkg.conf fi if [[ -n $GPGKEY ]]; then - SIGNWITHKEY="-u ${GPGKEY}" + SIGNWITHKEY=(-u "${GPGKEY}") fi - gpg --detach-sign --use-agent ${SIGNWITHKEY} ${@} || die + gpg --detach-sign --use-agent "${SIGNWITHKEY[@]}" "${@}" || die } oneTimeSetUp() { @@ -28,33 +28,33 @@ oneTimeSetUp() { local pkgarch local pkgversion local build - pkgdir="$(mktemp -d /tmp/${0##*/}.XXXXXXXXXX)" - cp -Lr $(dirname ${BASH_SOURCE[0]})/../packages/* "${pkgdir}" + pkgdir="$(mktemp -d "/tmp/${0##*/}.XXXXXXXXXX")" + cp -Lr "$(dirname "${BASH_SOURCE[0]}")"/../packages/* "${pkgdir}" msg 'Building packages...' for d in "${pkgdir}"/*; do - pushd $d >/dev/null - pkgname=($(. PKGBUILD; echo ${pkgname[@]})) - pkgarch=($(. PKGBUILD; echo ${arch[@]})) - pkgversion=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) + pushd "$d" >/dev/null + pkgname=($(. PKGBUILD; echo "${pkgname[@]}")) + pkgarch=($(. PKGBUILD; echo "${arch[@]}")) + pkgversion=$(. PKGBUILD; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") build=true - for a in ${pkgarch[@]}; do - for p in ${pkgname[@]}; do - [ ! -f ${p}-${pkgversion}-${a}${PKGEXT} ] && build=false + for a in "${pkgarch[@]}"; do + for p in "${pkgname[@]}"; do + [ ! -f "${p}-${pkgversion}-${a}"${PKGEXT} ] && build=false done done - if ! ${build}; then + if ! "${build}"; then if [ "${pkgarch[0]}" == 'any' ]; then sudo extra-x86_64-build || die 'extra-x86_64-build failed' else - for a in ${pkgarch[@]}; do - sudo extra-${a}-build || die "extra-${a}-build failed" + for a in "${pkgarch[@]}"; do + sudo "extra-${a}-build" || die "extra-${a}-build failed" done fi - for a in ${pkgarch[@]}; do - for p in ${pkgname[@]}; do - cp ${p}-${pkgversion}-${a}${PKGEXT} $(dirname ${BASH_SOURCE[0]})/../packages/${d##*/} + for a in "${pkgarch[@]}"; do + for p in "${pkgname[@]}"; do + cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]}")/../packages/${d##*/}" done done fi @@ -72,17 +72,17 @@ setUp() { local r local a - [ -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" ] && die "$(dirname ${BASH_SOURCE[0]})/../../config.local exists" - TMP="$(mktemp -d /tmp/${0##*/}.XXXXXXXXXX)" + [ -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local" ] && die "$(dirname "${BASH_SOURCE[0]}")/../../config.local exists" + TMP="$(mktemp -d "/tmp/${0##*/}.XXXXXXXXXX")" #msg "Using ${TMP}" PKGREPOS=('core' 'extra' 'testing') PKGPOOL='pool/packages' mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}} - for r in ${PKGREPOS[@]}; do + for r in "${PKGREPOS[@]}"; do mkdir -p "${TMP}/staging/${r}" - for a in ${ARCHES[@]}; do + for a in "${ARCHES[@]}"; do mkdir -p "${TMP}/ftp/${r}/os/${a}" done done @@ -96,15 +96,15 @@ setUp() { for p in "${pkgdir}"/*; do pkg=${p##*/} mkdir -p "${TMP}/svn-packages-copy/${pkg}"/{trunk,repos} - cp "${p}"/* "${TMP}/svn-packages-copy"/${pkg}/trunk/ - arch_svn add -q "${TMP}/svn-packages-copy"/${pkg} + cp "${p}"/* "${TMP}/svn-packages-copy/${pkg}/trunk/" + arch_svn add -q "${TMP}/svn-packages-copy/${pkg}" arch_svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" done - cat <<eot > "$(dirname ${BASH_SOURCE[0]})/../../config.local" + cat <<eot > "$(dirname "${BASH_SOURCE[0]}")/../../config.local" FTP_BASE="${TMP}/ftp" SVNREPO="file://${TMP}/svn-packages-repo" - PKGREPOS=(${PKGREPOS[@]}) + PKGREPOS=("${PKGREPOS[@]}") PKGPOOL="${PKGPOOL}" TESTING_REPO='testing' STABLE_REPOS=('core' 'extra') @@ -116,12 +116,12 @@ setUp() { SOURCE_CLEANUP_DRYRUN=false REQUIRE_SIGNATURE=true eot - . "$(dirname ${BASH_SOURCE[0]})/../../config" + . "$(dirname "${BASH_SOURCE[0]}")/../../config" } tearDown() { rm -rf "${TMP}" - rm -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" + rm -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local" echo } @@ -134,17 +134,17 @@ releasePackage() { local pkgver local pkgname - pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null - archrelease ${repo}-${arch} >/dev/null 2>&1 - pkgver=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) - pkgname=($(. PKGBUILD; echo ${pkgname[@]})) + pushd "${TMP}/svn-packages-copy/${pkgbase}/trunk/" >/dev/null + archrelease "${repo}-${arch}" >/dev/null 2>&1 + pkgver=$(. PKGBUILD; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") + pkgname=($(. PKGBUILD; echo "${pkgname[@]}")) popd >/dev/null - cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}${PKGEXT} "${STAGING}"/${repo}/ + cp "${pkgdir}/${pkgbase}"/*-"${pkgver}-${arch}"${PKGEXT} "${STAGING}/${repo}/" - if ${REQUIRE_SIGNATURE}; then - for a in ${arch[@]}; do - for p in ${pkgname[@]}; do - signpkg "${STAGING}"/${repo}/${p}-${pkgver}-${a}${PKGEXT} + if "${REQUIRE_SIGNATURE}"; then + for a in "${arch[@]}"; do + for p in "${pkgname[@]}"; do + signpkg "${STAGING}/${repo}/${p}-${pkgver}-${a}"${PKGEXT} done done fi @@ -157,7 +157,7 @@ checkAnyPackageDB() { local db [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" - if ${REQUIRE_SIGNATURE}; then + if "${REQUIRE_SIGNATURE}"; then [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" fi @@ -166,27 +166,27 @@ checkAnyPackageDB() { [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" - if ${REQUIRE_SIGNATURE}; then + if "${REQUIRE_SIGNATURE}"; then [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig" ] || fail "${repo}/os/${arch}/${pkg}.sig is not a symlink" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \ || fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig" fi - for db in ${DBEXT} ${FILESEXT}; do + for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done - [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - [ -r "${STAGING}"/${repo}/${pkg}.sig ] && fail "${repo}/${pkg}.sig found in staging dir" + [ -r "${STAGING}/${repo}/${pkg}" ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}/${repo}/${pkg}".sig ] && fail "${repo}/${pkg}.sig found in staging dir" } checkAnyPackage() { local repo=$1 local pkg=$2 - checkAnyPackageDB $repo $pkg + checkAnyPackageDB "$repo" "$pkg" local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}" @@ -202,23 +202,23 @@ checkPackageDB() { [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}/${repo}/${pkg}" ] && fail "${repo}/${pkg} found in staging dir" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" - if ${REQUIRE_SIGNATURE}; then + if "${REQUIRE_SIGNATURE}"; then [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig" ] || fail "${repo}/os/${arch}/${pkg}.sig is not a symlink" - [ -r "${STAGING}"/${repo}/${pkg}.sig ] && fail "${repo}/${pkg}.sig found in staging dir" + [ -r "${STAGING}/${repo}/${pkg}.sig" ] && fail "${repo}/${pkg}.sig found in staging dir" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \ || fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig" fi - for db in ${DBEXT} ${FILESEXT}; do + for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -228,7 +228,7 @@ checkPackage() { local pkg=$2 local arch=$3 - checkPackageDB $repo $pkg $arch + checkPackageDB "$repo" "$pkg" "$arch" local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}" @@ -242,9 +242,9 @@ checkRemovedPackageDB() { local arch=$3 local db - for db in ${DBEXT} ${FILESEXT}; do + for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -254,7 +254,7 @@ checkRemovedPackage() { local pkgbase=$2 local arch=$3 - checkRemovedPackageDB $repo $pkgbase $arch + checkRemovedPackageDB "$repo" "$pkgbase" "$arch" arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ @@ -267,10 +267,10 @@ checkRemovedAnyPackageDB() { local arch local db - for db in ${DBEXT} ${FILESEXT}; do + for db in "${DBEXT}" "${FILESEXT}"; do for arch in i686 x86_64; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done @@ -280,7 +280,7 @@ checkRemovedAnyPackage() { local repo=$1 local pkgbase=$2 - checkRemovedAnyPackageDB $repo $pkgbase + checkRemovedAnyPackageDB "$repo" "$pkgbase" arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ diff --git a/test/packages/pkg-any-a/PKGBUILD b/test/packages/pkg-any-a/PKGBUILD index 8749a35..cd5d66f 100644 --- a/test/packages/pkg-any-a/PKGBUILD +++ b/test/packages/pkg-any-a/PKGBUILD @@ -7,6 +7,6 @@ url='http://www.archlinux.org/' license=('GPL') package() { - install -d -m755 ${pkgdir}/usr/share/${pkgname} - echo 'test' > ${pkgdir}/usr/share/${pkgname}/test + install -d -m755 "${pkgdir}"/usr/share/${pkgname} + echo 'test' > "${pkgdir}"/usr/share/${pkgname}/test } diff --git a/test/packages/pkg-any-b/PKGBUILD b/test/packages/pkg-any-b/PKGBUILD index e6a0498..90794fc 100644 --- a/test/packages/pkg-any-b/PKGBUILD +++ b/test/packages/pkg-any-b/PKGBUILD @@ -7,6 +7,6 @@ url='http://www.archlinux.org/' license=('GPL') package() { - install -d -m755 ${pkgdir}/usr/share/${pkgname} - echo 'test' > ${pkgdir}/usr/share/${pkgname}/test + install -d -m755 "${pkgdir}"/usr/share/${pkgname} + echo 'test' > "${pkgdir}"/usr/share/${pkgname}/test } diff --git a/test/packages/pkg-simple-a/PKGBUILD b/test/packages/pkg-simple-a/PKGBUILD index 953ecfa..9b4478e 100644 --- a/test/packages/pkg-simple-a/PKGBUILD +++ b/test/packages/pkg-simple-a/PKGBUILD @@ -12,11 +12,11 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname}" } diff --git a/test/packages/pkg-simple-b/PKGBUILD b/test/packages/pkg-simple-b/PKGBUILD index 95ffd09..4a9e58d 100644 --- a/test/packages/pkg-simple-b/PKGBUILD +++ b/test/packages/pkg-simple-b/PKGBUILD @@ -12,11 +12,11 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname}" } diff --git a/test/packages/pkg-simple-epoch/PKGBUILD b/test/packages/pkg-simple-epoch/PKGBUILD index eebe2bd..0761b32 100644 --- a/test/packages/pkg-simple-epoch/PKGBUILD +++ b/test/packages/pkg-simple-epoch/PKGBUILD @@ -13,11 +13,11 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname}" } diff --git a/test/packages/pkg-split-a/PKGBUILD b/test/packages/pkg-split-a/PKGBUILD index e941976..f7a0576 100644 --- a/test/packages/pkg-split-a/PKGBUILD +++ b/test/packages/pkg-split-a/PKGBUILD @@ -13,16 +13,16 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package_pkg-split-a1() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname[0]} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname[0]}" } package_pkg-split-a2() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname[1]} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname[1]}" } diff --git a/test/packages/pkg-split-b/PKGBUILD b/test/packages/pkg-split-b/PKGBUILD index 6ddbc45..3bd635c 100644 --- a/test/packages/pkg-split-b/PKGBUILD +++ b/test/packages/pkg-split-b/PKGBUILD @@ -14,16 +14,16 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package_pkg-split-b1() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname[0]} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname[0]}" } package_pkg-split-b2() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname[1]} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname[1]}" } diff --git a/test/runTest b/test/runTest index b8713d8..7163e30 100755 --- a/test/runTest +++ b/test/runTest @@ -1,12 +1,12 @@ #!/bin/bash -. "$(dirname ${BASH_SOURCE[0]})/lib/common.inc" +. "$(dirname "${BASH_SOURCE[0]}")/lib/common.inc" -for t in "$(dirname ${BASH_SOURCE[0]})/test.d/"*.sh; do - l=$(basename ${t} .sh) - if [ -x ${t} ]; then +for t in "$(dirname "${BASH_SOURCE[0]}")/test.d/"*.sh; do + l=$(basename "${t}" .sh) + if [ -x "${t}" ]; then msg "Running test '${l}'" - ${t} + "${t}" [ $? -ne 0 ] && die "Test '${l}' failed" echo -e "\n\n\n" else diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index 49734c4..e3a30d1 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testCreateSimpleFileLists() { @@ -9,15 +9,15 @@ testCreateSimpleFileLists() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgbase}"; then fail "usr/bin/${pkgbase} not found in ${arch}/extra${FILESEXT}" fi @@ -31,13 +31,13 @@ testCreateAnyFileLists() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/share/${pkgbase}/test"; then fail "usr/share/${pkgbase}/test not found in ${arch}/extra${FILESEXT}" fi @@ -54,17 +54,17 @@ testCreateSplitFileLists() { local pkgnames local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do + for pkgbase in "${pkgs[@]}"; do pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo ${pkgname[@]})) - for pkgname in ${pkgnames[@]}; do - for arch in ${arches[@]}; do + for pkgname in "${pkgnames[@]}"; do + for arch in "${arches[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgname}"; then fail "usr/bin/${pkgname} not found in ${arch}/extra${FILESEXT}" fi @@ -80,18 +80,18 @@ testCleanupFileLists() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} pkg-simple-a + for arch in "${arches[@]}"; do + ../db-remove extra "${arch}" pkg-simple-a done - for arch in ${arches[@]}; do + for arch in "${arches[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/pkg-simple-b"; then fail "usr/bin/pkg-simple-b not found in ${arch}/extra${FILESEXT}" fi diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 890ffc4..e3207b6 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testMoveSimplePackages() { @@ -9,9 +9,9 @@ testMoveSimplePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage testing "${pkgbase}" "${arch}" done done @@ -19,11 +19,11 @@ testMoveSimplePackages() { ../db-move testing extra pkg-simple-a - for arch in ${arches[@]}; do - checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} - checkRemovedPackage testing pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} + for arch in "${arches[@]}"; do + checkPackage extra "pkg-simple-a-1-1-${arch}.pkg.tar.xz" "${arch}" + checkRemovedPackage testing "pkg-simple-a-1-1-${arch}.pkg.tar.xz" "${arch}" - checkPackage testing pkg-simple-b-1-1-${arch}.pkg.tar.xz ${arch} + checkPackage testing "pkg-simple-b-1-1-${arch}.pkg.tar.xz" "${arch}" done } @@ -33,9 +33,9 @@ testMoveMultiplePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage testing "${pkgbase}" "${arch}" done done @@ -43,10 +43,10 @@ testMoveMultiplePackages() { ../db-move testing extra pkg-simple-a pkg-simple-b - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackage extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} - checkRemovedPackage testing ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + checkPackage extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" + checkRemovedPackage testing "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } @@ -57,9 +57,9 @@ testMoveEpochPackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage testing "${pkgbase}" "${arch}" done done @@ -67,9 +67,9 @@ testMoveEpochPackages() { ../db-move testing extra pkg-simple-epoch - for arch in ${arches[@]}; do - checkPackage extra pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz ${arch} - checkRemovedPackage testing pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz ${arch} + for arch in "${arches[@]}"; do + checkPackage extra "pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" "${arch}" + checkRemovedPackage testing "pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" "${arch}" done } @@ -77,8 +77,8 @@ testMoveAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase - for pkgbase in ${pkgs[@]}; do - releasePackage testing ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage testing "${pkgbase}" any done ../db-update @@ -96,23 +96,23 @@ testMoveSplitPackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage testing "${pkgbase}" "${arch}" done done ../db-update ../db-move testing extra pkg-split-a - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/pkg-split-a"/*-${arch}${PKGEXT}; do - checkPackage extra ${pkg##*/} ${arch} + for arch in "${arches[@]}"; do + for pkg in "${pkgdir}/pkg-split-a"/*-"${arch}"${PKGEXT}; do + checkPackage extra "${pkg##*/}" "${arch}" done done - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/pkg-split-b"/*-${arch}${PKGEXT}; do - checkPackage testing ${pkg##*/} ${arch} + for arch in "${arches[@]}"; do + for pkg in "${pkgdir}/pkg-split-b"/*-"${arch}"${PKGEXT}; do + checkPackage testing "${pkg##*/}" "${arch}" done done diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index 416e693..fca480c 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testRemovePackages() { @@ -9,23 +9,23 @@ testRemovePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - ../db-remove extra ${arch} ${pkgbase} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + ../db-remove extra "${arch}" "${pkgbase}" done done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + checkRemovedPackage extra "${pkgbase}" "${arch}" done done } @@ -36,21 +36,21 @@ testRemoveMultiplePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} ${pkgs[@]} + for arch in "${arches[@]}"; do + ../db-remove extra "${arch}" "${pkgs[@]}" done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + checkRemovedPackage extra "${pkgbase}" "${arch}" done done } @@ -59,18 +59,18 @@ testRemoveAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update - for pkgbase in ${pkgs[@]}; do - ../db-remove extra any ${pkgbase} + for pkgbase in "${pkgs[@]}"; do + ../db-remove extra any "${pkgbase}" done - for pkgbase in ${pkgs[@]}; do - checkRemovedAnyPackage extra ${pkgbase} + for pkgbase in "${pkgs[@]}"; do + checkRemovedAnyPackage extra "${pkgbase}" done } diff --git a/test/test.d/db-repo-add.sh b/test/test.d/db-repo-add.sh index 8603104..3d83007 100755 --- a/test/test.d/db-repo-add.sh +++ b/test/test.d/db-repo-add.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testAddSimplePackages() { @@ -9,19 +9,19 @@ testAddSimplePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" touch "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/extra/os/${arch}/" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" "${FTP_BASE}/extra/os/${arch}/" - ../db-repo-add extra ${arch} ${pkgbase}-1-1-${arch}.pkg.tar.xz + ../db-repo-add extra "${arch}" "${pkgbase}-1-1-${arch}.pkg.tar.xz" done done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackageDB extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + checkPackageDB extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } @@ -32,21 +32,21 @@ testAddMultiplePackages() { local pkgbase local arch - for arch in ${arches[@]}; do + for arch in "${arches[@]}"; do add_pkgs=() - for pkgbase in ${pkgs[@]}; do + for pkgbase in "${pkgs[@]}"; do cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" touch "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/extra/os/${arch}/" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" "${FTP_BASE}/extra/os/${arch}/" - add_pkgs[${#add_pkgs[*]}]=${pkgbase}-1-1-${arch}.pkg.tar.xz + add_pkgs+=("${pkgbase}-1-1-${arch}.pkg.tar.xz") done - ../db-repo-add extra ${arch} ${add_pkgs[@]} + ../db-repo-add extra "${arch}" "${add_pkgs[@]}" done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackageDB extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + checkPackageDB extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } diff --git a/test/test.d/db-repo-remove.sh b/test/test.d/db-repo-remove.sh index 315d63d..ce13280 100755 --- a/test/test.d/db-repo-remove.sh +++ b/test/test.d/db-repo-remove.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testRemovePackages() { @@ -9,23 +9,23 @@ testRemovePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - ../db-repo-remove extra ${arch} ${pkgbase} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + ../db-repo-remove extra "${arch}" "${pkgbase}" done done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackageDB extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + checkRemovedPackageDB extra "${pkgbase}" "${arch}" done done } @@ -36,21 +36,21 @@ testRemoveMultiplePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-repo-remove extra ${arch} ${pkgs[@]} + for arch in "${arches[@]}"; do + ../db-repo-remove extra "${arch}" "${pkgs[@]}" done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackageDB extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + checkRemovedPackageDB extra "${pkgbase}" "${arch}" done done } diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index 7a5ce4c..c83d51b 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testAddSimplePackages() { @@ -9,17 +9,17 @@ testAddSimplePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackage extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + checkPackage extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } @@ -40,14 +40,14 @@ testAddAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update - for pkgbase in ${pkgs[@]}; do - checkAnyPackage extra ${pkgbase}-1-1-any.pkg.tar.xz + for pkgbase in "${pkgs[@]}"; do + checkAnyPackage extra "${pkgbase}-1-1-any.pkg.tar.xz" done } @@ -58,18 +58,18 @@ testAddSplitPackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-${arch}${PKGEXT}; do - checkPackage extra ${pkg##*/} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + for pkg in "${pkgdir}/${pkgbase}"/*-"${arch}"${PKGEXT}; do + checkPackage extra "${pkg##*/}" "${arch}" done done done @@ -134,7 +134,7 @@ testUpdateSameAnyPackageToDifferentRepositories() { local arch for arch in i686 x86_64; do ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" done } @@ -146,18 +146,18 @@ testAddIncompleteSplitPackage() { local pkgbase='pkg-split-a' local arch - for arch in ${arches[@]}; do - releasePackage ${repo} ${pkgbase} ${arch} + for arch in "${arches[@]}"; do + releasePackage "${repo}" "${pkgbase}" "${arch}" done # remove a split package to make db-update fail - rm "${STAGING}"/extra/${pkgbase}1-* + rm "${STAGING}/extra/${pkgbase}1-"* ../db-update >/dev/null 2>&1 && fail "db-update should fail when a split package is missing!" - for arch in ${arches[@]}; do + for arch in "${arches[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" done } diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index bfea7ea..1b075da 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testCleanupSimplePackages() { @@ -9,28 +9,28 @@ testCleanupSimplePackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} pkg-simple-a + for arch in "${arches[@]}"; do + ../db-remove extra "${arch}" pkg-simple-a done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in ${arches[@]}; do + for arch in "${arches[@]}"; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" - checkRemovedPackage extra 'pkg-simple-a' ${arch} + checkRemovedPackage extra 'pkg-simple-a' "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" - checkPackage extra ${pkg2} ${arch} + checkPackage extra "${pkg2}" "${arch}" done } @@ -40,23 +40,23 @@ testCleanupEpochPackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} pkg-simple-epoch + for arch in "${arches[@]}"; do + ../db-remove extra "${arch}" pkg-simple-epoch done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in ${arches[@]}; do + for arch in "${arches[@]}"; do local pkg1="pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" - checkRemovedPackage extra 'pkg-simple-epoch' ${arch} + checkRemovedPackage extra 'pkg-simple-epoch' "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" done @@ -67,8 +67,8 @@ testCleanupAnyPackages() { local pkgbase local arch='any' - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update @@ -81,7 +81,7 @@ testCleanupAnyPackages() { [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" - checkAnyPackage extra ${pkg2} + checkAnyPackage extra "${pkg2}" } testCleanupSplitPackages() { @@ -91,29 +91,29 @@ testCleanupSplitPackages() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} ${pkgs[0]} + for arch in "${arches[@]}"; do + ../db-remove extra "${arch}" "${pkgs[0]}" done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}${PKGEXT}; do - checkRemovedPackage extra ${pkgs[0]} ${arch} + for arch in "${arches[@]}"; do + for pkg in "${pkgdir}/${pkgs[0]}"/*-"${arch}"${PKGEXT}; do + checkRemovedPackage extra "${pkgs[0]}" "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" done - for pkg in "${pkgdir}/${pkgs[1]}"/*-${arch}${PKGEXT}; do - checkPackage extra ${pkg##*/} ${arch} + for pkg in "${pkgdir}/${pkgs[1]}"/*-"${arch}"${PKGEXT}; do + checkPackage extra "${pkg##*/}" "${arch}" done done } diff --git a/test/test.d/packages.sh b/test/test.d/packages.sh index 488cb15..1a31a41 100755 --- a/test/test.d/packages.sh +++ b/test/test.d/packages.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testPackages() { diff --git a/test/test.d/signed-packages.sh b/test/test.d/signed-packages.sh index 03566ef..4eccb41 100755 --- a/test/test.d/signed-packages.sh +++ b/test/test.d/signed-packages.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testAddSignedPackage() { @@ -18,8 +18,8 @@ testAddInvalidSignedPackage() { local p releasePackage extra 'pkg-simple-a' 'i686' for p in "${STAGING}"/extra/*${PKGEXT}; do - unxz $p - xz -0 ${p%%.xz} + unxz "$p" + xz -0 "${p%%.xz}" done ../db-update >/dev/null 2>&1 && fail "db-update should fail when a signature is invalid!" } @@ -28,7 +28,7 @@ testAddBrokenSignature() { local s releasePackage extra 'pkg-simple-a' 'i686' for s in "${STAGING}"/extra/*.sig; do - echo 0 > $s + echo 0 > "$s" done ../db-update >/dev/null 2>&1 && fail "db-update should fail when a signature is broken!" } diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index fdcf08c..1097ae0 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testSourceballs() { @@ -9,16 +9,16 @@ testSourceballs() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + for pkgbase in "${pkgs[@]}"; do + [ ! -r "${FTP_BASE}/${SRCPOOL}/${pkgbase}"-*"${SRCEXT}" ] && fail "source package not found!" done } @@ -26,14 +26,14 @@ testAnySourceballs() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + for pkgbase in "${pkgs[@]}"; do + [ ! -r "${FTP_BASE}/${SRCPOOL}/${pkgbase}"-*"${SRCEXT}" ] && fail "source package not found!" done } @@ -44,17 +44,17 @@ testSplitSourceballs() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + for pkgbase in "${pkgs[@]}"; do + [ ! -r "${FTP_BASE}/${SRCPOOL}/${pkgbase}"-*"${SRCEXT}" ] && fail "source package not found!" done } @@ -64,21 +64,21 @@ testSourceballsCleanup() { local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${arches[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update ../cron-jobs/sourceballs - for arch in ${arches[@]}; do - ../db-remove extra ${arch} pkg-simple-a + for arch in "${arches[@]}"; do + ../db-remove extra "${arch}" pkg-simple-a done ../cron-jobs/sourceballs - [ -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-a-*${SRCEXT} ] && fail "source package was not removed!" - [ ! -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-b-*${SRCEXT} ] && fail "source package not found!" + [ -r "${FTP_BASE}/${SRCPOOL}/pkg-simple-a"-*"${SRCEXT}" ] && fail "source package was not removed!" + [ ! -r "${FTP_BASE}/${SRCPOOL}/pkg-simple-b"-*"${SRCEXT}" ] && fail "source package not found!" } . "${curdir}/../lib/shunit2" diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh index 31d85b4..3bbd353 100755 --- a/test/test.d/testing2x.sh +++ b/test/test.d/testing2x.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testTesting2xAnyPackage() { diff --git a/testing2x b/testing2x index 369857f..9ff2319 100755 --- a/testing2x +++ b/testing2x @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname $0)/config" -. "$(dirname $0)/db-functions" +. "$(dirname "$0")/config" +. "$(dirname "$0")/db-functions" if [ $# -lt 1 ]; then msg "usage: ${0##*/} <pkgname|pkgbase> ..." @@ -10,30 +10,30 @@ fi # Lock everything to reduce possibility of interfering task between the different repo-updates script_lock -for repo in ${TESTING_REPO} ${STABLE_REPOS[@]}; do - for pkgarch in ${ARCHES[@]}; do - repo_lock ${repo} ${pkgarch} || exit 1 +for repo in "${TESTING_REPO}" "${STABLE_REPOS[@]}"; do + for pkgarch in "${ARCHES[@]}"; do + repo_lock "${repo}" "${pkgarch}" || exit 1 done done declare -A pkgs -for pkgbase in $*; do +for pkgbase in "$@"; do if [ ! -d "${WORKDIR}/${pkgbase}" ]; then arch_svn export -q "${SVNREPO}/${pkgbase}/repos" "${WORKDIR}/${pkgbase}" >/dev/null found_source=false - for pkgarch in ${ARCHES[@]} 'any'; do + for pkgarch in "${ARCHES[@]}" 'any'; do svnrepo_from="${WORKDIR}/${pkgbase}/${TESTING_REPO}-${pkgarch}" if [ -r "${svnrepo_from}/PKGBUILD" ]; then found_source=true break fi done - ${found_source} || die "${pkgbase} not found in [${TESTING_REPO}]" + "${found_source}" || die "${pkgbase} not found in [${TESTING_REPO}]" found_target=false - for pkgarch in ${ARCHES[@]} 'any'; do - for repo in ${STABLE_REPOS[@]}; do + for pkgarch in "${ARCHES[@]}" 'any'; do + for repo in "${STABLE_REPOS[@]}"; do svnrepo_to="${WORKDIR}/${pkgbase}/${repo}-${pkgarch}" if [ -r "${svnrepo_to}/PKGBUILD" ]; then found_target=true @@ -42,19 +42,19 @@ for pkgbase in $*; do fi done done - ${found_target} || die "${pkgbase} not found in any of these repos: ${STABLE_REPOS[@]}" + "${found_target}" || die "${pkgbase} not found in any of these repos: ${STABLE_REPOS[*]}" fi done -for pkgarch in ${ARCHES[@]}; do - repo_unlock ${TESTING_REPO} ${pkgarch} +for pkgarch in "${ARCHES[@]}"; do + repo_unlock "${TESTING_REPO}" "${pkgarch}" done -for repo in ${STABLE_REPOS[@]}; do - for pkgarch in ${ARCHES[@]}; do - repo_unlock ${repo} ${pkgarch} +for repo in "${STABLE_REPOS[@]}"; do + for pkgarch in "${ARCHES[@]}"; do + repo_unlock "${repo}" "${pkgarch}" done if [ -n "${pkgs[${repo}]}" ]; then - "$(dirname $0)/db-move" ${TESTING_REPO} "${repo}" ${pkgs[${repo}]} + "$(dirname "$0")/db-move" "${TESTING_REPO}" "${repo}" "${pkgs[${repo}]}" fi done -- 2.4.1
From: Luke Shumaker <LukeShu@sbcglobal.net> --- cron-jobs/ftpdir-cleanup | 12 +++++----- cron-jobs/integrity-check | 2 +- cron-jobs/sourceballs | 12 +++++----- cron-jobs/update-web-db | 2 +- db-functions | 57 +++++++++++++++++++++++------------------------ db-move | 10 ++++----- db-remove | 10 ++++----- db-repo-add | 8 +++---- db-repo-remove | 6 ++--- db-update | 24 ++++++++++---------- testing2x | 6 ++--- 11 files changed, 74 insertions(+), 75 deletions(-) diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index a2820e1..f6487cf 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -44,17 +44,17 @@ for repo in "${PKGREPOS[@]}"; do missing_pkgs=($(comm -13 "${WORKDIR}/repo-${repo}-${arch}" "${WORKDIR}/db-${repo}-${arch}")) if [ ${#missing_pkgs[@]} -ge 1 ]; then - error "Missing packages in [${repo}] (${arch})..." + error "Missing packages in [%s] (%s)..." "${repo}" "${arch}" for missing_pkg in "${missing_pkgs[@]}"; do - msg2 "${missing_pkg}" + msg2 '%s' "${missing_pkg}" done fi old_pkgs=($(comm -23 "${WORKDIR}/repo-${repo}-${arch}" "${WORKDIR}/db-${repo}-${arch}")) if [ ${#old_pkgs[@]} -ge 1 ]; then - msg "Removing old packages from [${repo}] (${arch})..." + msg "Removing old packages from [%s] (%s)..." "${repo}" "${arch}" for old_pkg in "${old_pkgs[@]}"; do - msg2 "${old_pkg}" + msg2 '%s' "${old_pkg}" clean_pkg "${FTP_BASE}/${repo}/os/${arch}/${old_pkg}" done fi @@ -70,7 +70,7 @@ old_pkgs=($(comm -23 "${WORKDIR}/pool" "${WORKDIR}/db")) if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old packages from package pool..." for old_pkg in "${old_pkgs[@]}"; do - msg2 "${old_pkg}" + msg2 '%s' "${old_pkg}" clean_pkg "$FTP_BASE/${PKGPOOL}/${old_pkg}" done fi @@ -79,7 +79,7 @@ old_pkgs=($(find "${CLEANUP_DESTDIR}" -type f -name "*${PKGEXT}" -mtime +"${CLEA if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old packages from the cleanup directory..." for old_pkg in "${old_pkgs[@]}"; do - msg2 "${old_pkg}" + msg2 '%s' "${old_pkg}" if ! "${CLEANUP_DRYRUN}"; then rm -f "${CLEANUP_DESTDIR}/${old_pkg}" rm -f "${CLEANUP_DESTDIR}/${old_pkg}.sig" diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check index e77eac7..677c0d3 100755 --- a/cron-jobs/integrity-check +++ b/cron-jobs/integrity-check @@ -8,7 +8,7 @@ dirname="$(dirname "$0")" script_lock if [ $# -ne 1 ]; then - die "usage: ${0##*/} <mailto>" + die "usage: %s <mailto>" "${0##*/}" fi mailto=$1 diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index dee849a..0c2f9f9 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -103,15 +103,15 @@ for repo in "${PKGREPOS[@]}"; do done < "${WORKDIR}/db-${repo}" if [ ${#newpkgs[@]} -ge 1 ]; then - msg "Adding source packages for [${repo}]..." + msg "Adding source packages for [%s]..." "${repo}" for new_pkg in "${newpkgs[@]}"; do - msg2 "${new_pkg}" + msg2 '%s' "${new_pkg}" done fi if [ ${#failedpkgs[@]} -ge 1 ]; then - msg "Failed to create source packages for [${repo}]..." + msg "Failed to create source packages for [%s]..." "${repo}" for failed_pkg in "${failedpkgs[@]}"; do - msg2 "${failed_pkg}" + msg2 '%s' "${failed_pkg}" done fi done @@ -125,7 +125,7 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old source packages..." "${SOURCE_CLEANUP_DRYRUN}" && warning 'dry run mode is active' for old_pkg in "${old_pkgs[@]}"; do - msg2 "${old_pkg}" + msg2 '%s' "${old_pkg}" if ! "${SOURCE_CLEANUP_DRYRUN}"; then mv_acl "$FTP_BASE/${SRCPOOL}/${old_pkg}" "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" touch "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" @@ -137,7 +137,7 @@ old_pkgs=($(find "${SOURCE_CLEANUP_DESTDIR}" -type f -name "*${SRCEXT}" -mtime + if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old source packages from the cleanup directory..." for old_pkg in "${old_pkgs[@]}"; do - msg2 "${old_pkg}" + msg2 '%s' "${old_pkg}" "${SOURCE_CLEANUP_DRYRUN}" || rm -f "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}" done fi diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db index 1a725dc..88bf464 100755 --- a/cron-jobs/update-web-db +++ b/cron-jobs/update-web-db @@ -16,7 +16,7 @@ LOGOUT="/tmp/archweb_update.log" # figure out what operation to perform cmd="${0##*/}" if [[ $cmd != "update-web-db" && $cmd != "update-web-files-db" ]]; then - die "Invalid command name '$cmd' specified!" + die "Invalid command name '%s' specified!" "$cmd" fi script_lock diff --git a/db-functions b/db-functions index a40f2bb..2953d41 100644 --- a/db-functions +++ b/db-functions @@ -103,7 +103,7 @@ script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then local _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - error "Script ${0##*/} is already locked by $_owner." + error "Script %s is already locked by %s." "${0##*/}" "$_owner" exit 1 else set_umask @@ -114,7 +114,7 @@ script_lock() { script_unlock() { local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if [ ! -d "$LOCKDIR" ]; then - warning "Script ${0##*/} was not locked!" + warning "Script %s was not locked!" "${0##*/}" restore_umask return 1 else @@ -134,12 +134,12 @@ cleanup() { repo=${l%.*} arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then - msg "Removing left over lock from [${repo}] (${arch})" + msg "Removing left over lock from [%s] (%s)" "${repo}" "${arch}" repo_unlock "$repo" "$arch" fi done if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then - msg "Removing left over lock from ${0##*/}" + msg "Removing left over lock from %s" "${0##*/}" script_unlock fi rm -rf "$WORKDIR" @@ -178,11 +178,11 @@ repo_lock () { # This is the lock file used by repo-add and repo-remove if [ -f "${DBLOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat $DBLOCKFILE)" + error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(<"$DBLOCKFILE")" return 1 fi if [ -f "${FILESLOCKFILE}" ]; then - error "Repo [${1}] (${2}) is already locked by repo-{add,remove} process $(cat ${FILESLOCKFILE})" + error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(<"$FILESLOCKFILE")" return 1 fi @@ -199,8 +199,8 @@ repo_lock () { while [ "$_count" -le "$_trial" ] || "$_lockblock" ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" - warning "Repo [${1}] (${2}) is already locked by $_owner. " - msg2 "Retrying in $LOCK_DELAY seconds..." + warning "Repo [%s] (%s) is already locked by %s." "${1}" "${2}" "$_owner" + msg2 "Retrying in %d seconds..." "$LOCK_DELAY" else LOCKS[${#LOCKS[*]}]="$1.$2" set_umask @@ -210,14 +210,14 @@ repo_lock () { let _count=$_count+1 done - error "Repo [${1}] (${2}) is already locked by $_owner. Giving up!" + error "Repo [%s] (%s) is already locked by %s. Giving up!" "${1}" "${2}" "$_owner" return 1 } repo_unlock () { #repo_unlock <repo-name> <arch> local LOCKDIR="$TMPDIR/.repolock.$1.$2" if [ ! -d "$LOCKDIR" ]; then - warning "Repo lock [${1}] (${2}) was not locked!" + warning "Repo lock [%s] (%s) was not locked!" "${1}" "${2}" restore_umask return 1 else @@ -265,7 +265,7 @@ getpkgname() { _name="$(_grep_pkginfo "$1" "pkgname")" if [ -z "$_name" ]; then - error "Package '$1' has no pkgname in the PKGINFO. Fail!" + error "Package '%s' has no pkgname in the PKGINFO. Fail!" "$1" exit 1 fi @@ -278,7 +278,7 @@ getpkgver() { _ver="$(_grep_pkginfo "$1" "pkgver")" if [ -z "$_ver" ]; then - error "Package '$1' has no pkgver in the PKGINFO. Fail!" + error "Package '%s' has no pkgver in the PKGINFO. Fail!" "$1" exit 1 fi @@ -290,7 +290,7 @@ getpkgarch() { _ver="$(_grep_pkginfo "$1" "arch")" if [ -z "$_ver" ]; then - error "Package '$1' has no arch in the PKGINFO. Fail!" + error "Package '%s' has no arch in the PKGINFO. Fail!" "$1" exit 1 fi @@ -309,10 +309,10 @@ getpkgfile() { error 'No canonical package found!' exit 1 elif [ ! -f "${1}" ]; then - error "Package ${1} not found!" + error "Package %s not found!" "${1}" exit 1 elif "${REQUIRE_SIGNATURE}" && [ ! -f "${1}.sig" ]; then - error "Package signature ${1}.sig not found!" + error "Package signature %s not found!" "${1}.sig" exit 1 fi @@ -328,10 +328,10 @@ getpkgfiles() { for f in "${@}"; do if [ ! -f "${f}" ]; then - error "Package ${f} not found!" + error "Package %s not found!" "${f}" exit 1 elif "${REQUIRE_SIGNATURE}" && [ ! -f "${f}.sig" ]; then - error "Package signature ${f}.sig not found!" + error "Package signature %s not found!" "${f}.sig" exit 1 fi done @@ -415,8 +415,7 @@ check_splitpkgs() { fi local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}")) - printf '%s\n' in "${svnnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" - done + printf '%s\n' "${svnnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn" done popd >/dev/null @@ -489,12 +488,12 @@ set_repo_permission() { if [ -w "${dbfile}" ]; then local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")") - chgrp "$group" "${dbfile}" || error "Could not change group of ${dbfile} to $group" - chgrp "$group" "${filesfile}" || error "Could not change group of ${filesfile} to $group" - chmod g+w "${dbfile}" || error "Could not set write permission for group $group to ${dbfile}" - chmod g+w "${filesfile}" || error "Could not set write permission for group $group to ${filesfile}" + chgrp "$group" "${dbfile}" || error "Could not change group of %s to %s" "${dbfile}" "$group" + chgrp "$group" "${filesfile}" || error "Could not change group of %s to %s" "${filesfile}" "$group" + chmod g+w "${dbfile}" || error "Could not set write permission for group %s to %s" "$group" "${dbfile}" + chmod g+w "${filesfile}" || error "Could not set write permission for group %s to %s" "$group" "${filesfile}" else - error "You don't have permission to change ${dbfile}" + error "You don't have permission to change %s" "${dbfile}" fi } @@ -506,9 +505,9 @@ arch_repo_add() { # package files might be relative to repo dir pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null /usr/bin/repo-add -q "${repo}${DBEXT}" "${pkgs[@]}" \ - || error "repo-add ${repo}${DBEXT} ${pkgs[*]}" + || error '%s' "repo-add ${repo}${DBEXT} ${pkgs[*]}" /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ - || error "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" + || error '%s' "repo-add -f ${repo}${FILESEXT} ${pkgs[*]}" popd >/dev/null set_repo_permission "${repo}" "${arch}" @@ -523,13 +522,13 @@ arch_repo_remove() { local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" if [ ! -f "${dbfile}" ]; then - error "No database found at '${dbfile}'" + error "No database found at '%s'" "${dbfile}" return 1 fi /usr/bin/repo-remove -q "${dbfile}" "${pkgs[@]}" \ - || error "repo-remove ${dbfile} ${pkgs[*]}" + || error '%s' "repo-remove ${dbfile} ${pkgs[*]}" /usr/bin/repo-remove -q "${filesfile}" "${pkgs[@]}" \ - || error "repo-remove ${filesfile} ${pkgs[*]}" + || error '%s' "repo-remove ${filesfile} ${pkgs[*]}" set_repo_permission "${repo}" "${arch}" REPO_MODIFIED=1 diff --git a/db-move b/db-move index 4828e75..cd67953 100755 --- a/db-move +++ b/db-move @@ -4,7 +4,7 @@ . "$(dirname "$0")/db-functions" if [ $# -lt 3 ]; then - msg "usage: ${0##*/} <repo-from> <repo-to> <pkgname|pkgbase> ..." + msg "usage: %s <repo-from> <repo-to> <pkgname|pkgbase> ..." "${0##*/}" exit 1 fi @@ -15,7 +15,7 @@ ftppath_from="${FTP_BASE}/${repo_from}/os/" ftppath_to="${FTP_BASE}/${repo_to}/os/" if ! check_repo_permission "$repo_to" || ! check_repo_permission "$repo_from"; then - die "You don't have permission to move packages from ${repo_from} to ${repo_to}" + die "You don't have permission to move packages from %s to %s" "${repo_from}" "${repo_to}" fi # TODO: this might lock too much (architectures) @@ -55,10 +55,10 @@ for pkgbase in "${args[@]:2}"; do continue 2 fi done - die "${pkgbase} not found in ${repo_from}" + die "%s not found in %s" "${pkgbase}" "${repo_from}" done -msg "Moving packages from [${repo_from}] to [${repo_to}]..." +msg "Moving packages from [%s] to [%s]..." "${repo_from}" "${repo_to}" declare -A add_pkgs declare -A remove_pkgs @@ -74,7 +74,7 @@ for pkgbase in "${args[@]:2}"; do else tarches=("${pkgarch}") fi - msg2 "${pkgbase} (${tarches[*]})" + msg2 "%s (%s)" "${pkgbase}" "${tarches[*]}" pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo "${pkgname[@]}")) pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") diff --git a/db-remove b/db-remove index f23cd9e..3bb67b0 100755 --- a/db-remove +++ b/db-remove @@ -4,7 +4,7 @@ . "$(dirname "$0")/db-functions" if [ $# -lt 3 ]; then - msg "usage: ${0##*/} <repo> <arch> <pkgname|pkgbase> ..." + msg "usage: %s <repo> <arch> <pkgname|pkgbase> ..." "${0##*/}" exit 1 fi @@ -16,7 +16,7 @@ ftppath="$FTP_BASE/$repo/os" svnrepo="$repo-$arch" if ! check_repo_permission "$repo"; then - die "You don't have permission to remove packages from ${repo}" + die "You don't have permission to remove packages from %s" "${repo}" fi if [ "$arch" == "any" ]; then @@ -31,7 +31,7 @@ done remove_pkgs=() for pkgbase in "${pkgbases[@]}"; do - msg "Removing $pkgbase from [$repo]..." + msg "Removing %s from [%s]..." "$pkgbase" "$repo" arch_svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then @@ -39,8 +39,8 @@ for pkgbase in "${pkgbases[@]}"; do arch_svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" arch_svn commit -q "${WORKDIR}/svn/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)" else - warning "$pkgbase not found in $svnrepo" - warning "Removing only $pkgbase from the repo" + warning "%s not found in %s" "$pkgbase" "$svnrepo" + warning "Removing only %s from the repo" "$pkgbase" warning "If it was a split package you have to remove the others yourself!" remove_pkgs[${#remove_pkgs[*]}]=$pkgbase fi diff --git a/db-repo-add b/db-repo-add index a53884e..09ce865 100755 --- a/db-repo-add +++ b/db-repo-add @@ -4,7 +4,7 @@ . "$(dirname "$0")/db-functions" if [ $# -lt 3 ]; then - msg "usage: ${0##*/} <repo> <arch> <pkgfile> ..." + msg "usage: %s <repo> <arch> <pkgfile> ..." "${0##*/}" exit 1 fi @@ -15,7 +15,7 @@ pkgfiles=("${@:3}") ftppath="$FTP_BASE/$repo/os" if ! check_repo_permission "$repo"; then - die "You don't have permission to add packages to ${repo}" + die "You don't have permission to add packages to %s" "${repo}" fi if [ "$arch" == "any" ]; then @@ -31,9 +31,9 @@ done for tarch in "${tarches[@]}"; do for pkgfile in "${pkgfiles[@]}"; do if [[ ! -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}" ]]; then - die "Package file ${pkgfile##*/} not found in ${FTP_BASE}/${repo}/os/${arch}/" + die "Package file %s not found in %s" "${pkgfile##*/}" "${FTP_BASE}/${repo}/os/${arch}/" else - msg "Adding $pkgfile to [$repo]..." + msg "Adding %s to [%s]..." "$pkgfile" "$repo" fi done arch_repo_add "${repo}" "${tarch}" "${pkgfiles[@]}" diff --git a/db-repo-remove b/db-repo-remove index df746fb..97a671b 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -4,7 +4,7 @@ . "$(dirname "$0")/db-functions" if [ $# -lt 3 ]; then - msg "usage: ${0##*/} <repo> <arch> <pkgname> ..." + msg "usage: %s <repo> <arch> <pkgname> ..." "${0##*/}" exit 1 fi @@ -15,7 +15,7 @@ pkgnames=("${@:3}") ftppath="$FTP_BASE/$repo/os" if ! check_repo_permission "$repo"; then - die "You don't have permission to remove packages from ${repo}" + die "You don't have permission to remove packages from %s" "${repo}" fi if [ "$arch" == "any" ]; then @@ -30,7 +30,7 @@ done for tarch in "${tarches[@]}"; do for pkgname in "${pkgnames[@]}"; do - msg "Removing $pkgname from [$repo]..." + msg "Removing %s from [%s]..." "$pkgname" "$repo" done arch_repo_remove "${repo}" "${tarch}" "${pkgnames[@]}" repo_unlock "$repo" "$tarch" diff --git a/db-update b/db-update index ec3c0f9..33dc551 100755 --- a/db-update +++ b/db-update @@ -4,14 +4,14 @@ . "$(dirname "$0")/db-functions" if [ $# -ge 1 ]; then - warning "Calling ${0##*/} with a specific repository is no longer supported" + warning "Calling %s with a specific repository is no longer supported" "${0##*/}" exit 1 fi # Find repos with packages to release staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u)) if [ $? -ge 1 ]; then - die "Could not read ${STAGING}" + die "Could not read %s" "${STAGING}" fi repos=() @@ -31,47 +31,47 @@ done # check if packages are valid for repo in "${repos[@]}"; do if ! check_repo_permission "${repo}"; then - die "You don't have permission to update packages in ${repo}" + die "You don't have permission to update packages in %s" "${repo}" fi pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) if [ $? -eq 0 ]; then for pkg in "${pkgs[@]}"; do if [ -h "${pkg}" ]; then - die "Package ${repo}/${pkg##*/} is a symbolic link" + die "Package %s is a symbolic link" "${repo}/${pkg##*/}" fi if ! check_pkgfile "${pkg}"; then - die "Package ${repo}/${pkg##*/} is not consistent with its meta data" + die "Package %s is not consistent with its meta data" "${repo}/${pkg##*/}" fi if "${REQUIRE_SIGNATURE}" && ! pacman-key -v "${pkg}.sig" >/dev/null 2>&1; then - die "Package ${repo}/${pkg##*/} does not have a valid signature" + die "Package %s does not have a valid signature" "${repo}/${pkg##*/}" fi if ! check_pkgsvn "${pkg}" "${repo}"; then - die "Package ${repo}/${pkg##*/} is not consistent with svn repository" + die "Package %s is not consistent with svn repository" "${repo}/${pkg##*/}" fi if ! check_pkgrepos "${pkg}"; then - die "Package ${repo}/${pkg##*/} already exists in another repository" + die "Package %s already exists in another repository" "${repo}/${pkg##*/}" fi if ! check_packager "${pkg}"; then die "Package ${repo}/${pkg##*/} does not have a valid packager" fi done if ! check_splitpkgs "${repo}" "${pkgs[@]}"; then - die "Missing split packages for ${repo}" + die "Missing split packages for %s" "${repo}" fi else - die "Could not read ${STAGING}" + die "Could not read %s" "${STAGING}" fi done for repo in "${repos[@]}"; do - msg "Updating [${repo}]..." + msg "Updating [%s]..." "${repo}" any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) for pkgarch in "${ARCHES[@]}"; do add_pkgs=() arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-"${pkgarch}"${PKGEXT} 2>/dev/null)) for pkg in "${arch_pkgs[@]}" "${any_pkgs[@]}"; do pkgfile="${pkg##*/}" - msg2 "${pkgfile} (${pkgarch})" + msg2 "%s (%s)" "${pkgfile}" "${pkgarch}" # any packages might have been moved by the previous run if [ -f "${pkg}" ]; then mv "${pkg}" "$FTP_BASE/${PKGPOOL}" diff --git a/testing2x b/testing2x index 9ff2319..e269248 100755 --- a/testing2x +++ b/testing2x @@ -4,7 +4,7 @@ . "$(dirname "$0")/db-functions" if [ $# -lt 1 ]; then - msg "usage: ${0##*/} <pkgname|pkgbase> ..." + msg "usage: %s <pkgname|pkgbase> ..." "${0##*/}" exit 1 fi @@ -30,7 +30,7 @@ for pkgbase in "$@"; do break fi done - "${found_source}" || die "${pkgbase} not found in [${TESTING_REPO}]" + "${found_source}" || die "%s not found in [%s]" "${pkgbase}" "${TESTING_REPO}" found_target=false for pkgarch in "${ARCHES[@]}" 'any'; do for repo in "${STABLE_REPOS[@]}"; do @@ -42,7 +42,7 @@ for pkgbase in "$@"; do fi done done - "${found_target}" || die "${pkgbase} not found in any of these repos: ${STABLE_REPOS[*]}" + "${found_target}" || die "%s not found in any of these repos: " "${pkgbase}" "${STABLE_REPOS[*]}" fi done -- 2.4.1
From: Luke Shumaker <LukeShu@sbcglobal.net> The += operator was introduced in Bash 3.1, and was already used in some places in dbscripts, but not everywhere. For normal strings, this isn't a big deal, but appending to an array without using += is nasty. --- cron-jobs/sourceballs | 6 +++--- db-functions | 2 +- db-move | 2 +- db-remove | 2 +- db-update | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index 0c2f9f9..a1030e9 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -82,7 +82,7 @@ for repo in "${PKGREPOS[@]}"; do arch_svn export -q "${SVNREPO}/${pkgbase}/repos/${repo}-${pkgarch}" \ "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}" >/dev/null 2>&1 if [ $? -ge 1 ]; then - failedpkgs[${#failedpkgs[*]}]="${pkgbase}-${pkgver}${SRCEXT}" + failedpkgs+=("${pkgbase}-${pkgver}${SRCEXT}") continue fi @@ -93,9 +93,9 @@ for repo in "${PKGREPOS[@]}"; do mv_acl "${pkgbase}-${pkgver}${SRCEXT}" "${FTP_BASE}/${SRCPOOL}/${pkgbase}-${pkgver}${SRCEXT}" # Avoid creating the same source package for every arch echo "${pkgbase}-${pkgver}${SRCEXT}" >> "${WORKDIR}/available-src-pkgs" - newpkgs[${#newpkgs[*]}]="${pkgbase}-${pkgver}${SRCEXT}" + newpkgs+=("${pkgbase}-${pkgver}${SRCEXT}") else - failedpkgs[${#failedpkgs[*]}]="${pkgbase}-${pkgver}${SRCEXT}" + failedpkgs+=("${pkgbase}-${pkgver}${SRCEXT}") cat "${WORKDIR}/${pkgbase}.log" >> "${WORKDIR}/makepkg-fail.log" fi popd >/dev/null diff --git a/db-functions b/db-functions index 2953d41..8523cff 100644 --- a/db-functions +++ b/db-functions @@ -202,7 +202,7 @@ repo_lock () { warning "Repo [%s] (%s) is already locked by %s." "${1}" "${2}" "$_owner" msg2 "Retrying in %d seconds..." "$LOCK_DELAY" else - LOCKS[${#LOCKS[*]}]="$1.$2" + LOCKS+=("$1.$2") set_umask return 0 fi diff --git a/db-move b/db-move index cd67953..b589bca 100755 --- a/db-move +++ b/db-move @@ -91,7 +91,7 @@ for pkgbase in "${args[@]:2}"; do arch_svn mv -q -r HEAD "${svnrepo_from}/$file@" "${svnrepo_to}/" done arch_svn rm --force -q "${svnrepo_from}" - tag_list="$tag_list, $pkgarch" + tag_list+=", $pkgarch" for pkgname in "${pkgnames[@]}"; do for tarch in "${tarches[@]}"; do diff --git a/db-remove b/db-remove index 3bb67b0..59f2db0 100755 --- a/db-remove +++ b/db-remove @@ -42,7 +42,7 @@ for pkgbase in "${pkgbases[@]}"; do warning "%s not found in %s" "$pkgbase" "$svnrepo" warning "Removing only %s from the repo" "$pkgbase" warning "If it was a split package you have to remove the others yourself!" - remove_pkgs[${#remove_pkgs[*]}]=$pkgbase + remove_pkgs+=("$pkgbase") fi done diff --git a/db-update b/db-update index 33dc551..7f59ce7 100755 --- a/db-update +++ b/db-update @@ -84,7 +84,7 @@ for repo in "${repos[@]}"; do if [ -f "$FTP_BASE/${PKGPOOL}/${pkgfile}.sig" ]; then ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "$FTP_BASE/$repo/os/${pkgarch}" fi - add_pkgs[${#add_pkgs[*]}]=${pkgfile} + add_pkgs+=("${pkgfile}") done if [ ${#add_pkgs[@]} -ge 1 ]; then arch_repo_add "${repo}" "${pkgarch}" "${add_pkgs[@]}" -- 2.4.1
From: Luke Shumaker <LukeShu@sbcglobal.net> --- config | 2 +- db-functions | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index 6048209..b781555 100644 --- a/config +++ b/config @@ -23,7 +23,7 @@ LOCK_DELAY=10 LOCK_TIMEOUT=300 STAGING="$HOME/staging" -TMPDIR="/var/tmp" +export TMPDIR="/var/tmp" ARCHES=(i686 x86_64) DBEXT=".db.tar.gz" FILESEXT=".files.tar.gz" diff --git a/db-functions b/db-functions index 8523cff..eb61f51 100644 --- a/db-functions +++ b/db-functions @@ -25,7 +25,7 @@ mv_acl() { } # set up general environment -WORKDIR=$(mktemp -d "${TMPDIR}/${0##*/}.XXXXXXXXXX") +WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") if [ -n "${SVNUSER}" ]; then setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}" setfacl -m d:u:"${USER}":rwx "${WORKDIR}" -- 2.4.1
Because common.inc is included in nested calls, to prevent later calls from overriding earlier calls, we export MASTER_TMPDIR to signal the top-level value. Calls to mktemp have also bee adjusted to obey TMPDIR. --- config.testing | 5 +++++ test/lib/common.inc | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 config.testing diff --git a/config.testing b/config.testing new file mode 100644 index 0000000..a7ec4d1 --- /dev/null +++ b/config.testing @@ -0,0 +1,5 @@ +#!/hint/bash + +# override the default TMPDIR +[[ -n $MASTER_TMPDIR ]] || export MASTER_TMPDIR="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" +TMPDIR=$MASTER_TMPDIR diff --git a/test/lib/common.inc b/test/lib/common.inc index bb3db5b..9a7e4d9 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,8 +1,7 @@ set -E . "$(dirname "${BASH_SOURCE[0]}")/../../config" -# override the default TMPDIR -TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXXXX")" +. "$(dirname "${BASH_SOURCE[0]}")/../../config.testing" . "$(dirname "${BASH_SOURCE[0]}")/../../db-functions" signpkg() { @@ -28,7 +27,7 @@ oneTimeSetUp() { local pkgarch local pkgversion local build - pkgdir="$(mktemp -d "/tmp/${0##*/}.XXXXXXXXXX")" + pkgdir="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" cp -Lr "$(dirname "${BASH_SOURCE[0]}")"/../packages/* "${pkgdir}" msg 'Building packages...' for d in "${pkgdir}"/*; do @@ -73,7 +72,7 @@ setUp() { local a [ -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local" ] && die "$(dirname "${BASH_SOURCE[0]}")/../../config.local exists" - TMP="$(mktemp -d "/tmp/${0##*/}.XXXXXXXXXX")" + TMP="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" #msg "Using ${TMP}" PKGREPOS=('core' 'extra' 'testing') -- 2.4.1
--- config.testing | 5 +++++ test/lib/common.inc | 16 ++++++++++------ test/test.d/create-filelists.sh | 20 ++++++++------------ test/test.d/db-move.sh | 22 +++++++++------------- test/test.d/db-remove.sh | 14 ++++++-------- test/test.d/db-repo-add.sh | 10 ++++------ test/test.d/db-repo-remove.sh | 14 ++++++-------- test/test.d/db-update.sh | 15 ++++++--------- test/test.d/ftpdir-cleanup.sh | 21 +++++++++------------ test/test.d/sourceballs.sh | 11 ++++------- 10 files changed, 67 insertions(+), 81 deletions(-) diff --git a/config.testing b/config.testing index a7ec4d1..24c2283 100644 --- a/config.testing +++ b/config.testing @@ -1,5 +1,10 @@ #!/hint/bash +# The host architecture +ARCH_HOST=$(uname -m) +# Which architectures should we test building for? +ARCH_BUILD=("$ARCH_HOST"); if [[ $ARCH_HOST == x86_64 ]]; then ARCH_BUILD+=("i686"); fi + # override the default TMPDIR [[ -n $MASTER_TMPDIR ]] || export MASTER_TMPDIR="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" TMPDIR=$MASTER_TMPDIR diff --git a/test/lib/common.inc b/test/lib/common.inc index 9a7e4d9..5b06616 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -48,13 +48,17 @@ oneTimeSetUp() { sudo extra-x86_64-build || die 'extra-x86_64-build failed' else for a in "${pkgarch[@]}"; do - sudo "extra-${a}-build" || die "extra-${a}-build failed" + if in_array "$a" "${ARCH_BUILD[@]}"; then + sudo "extra-${a}-build" || die "extra-${a}-build failed" + fi done fi for a in "${pkgarch[@]}"; do - for p in "${pkgname[@]}"; do - cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]}")/../packages/${d##*/}" - done + if in_array "$a" "${ARCH_BUILD[@]}"; then + for p in "${pkgname[@]}"; do + cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]}")/../packages/${d##*/}" + done + fi done fi popd >/dev/null @@ -160,7 +164,7 @@ checkAnyPackageDB() { [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" fi - for arch in i686 x86_64; do + for arch in "${ARCH_BUILD[@]}"; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} is not a symlink" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" @@ -267,7 +271,7 @@ checkRemovedAnyPackageDB() { local db for db in "${DBEXT}" "${FILESEXT}"; do - for arch in i686 x86_64; do + for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index e3a30d1..e16a8d1 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -4,20 +4,19 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testCreateSimpleFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgbase}"; then fail "usr/bin/${pkgbase} not found in ${arch}/extra${FILESEXT}" fi @@ -26,7 +25,6 @@ testCreateSimpleFileLists() { } testCreateAnyFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase local arch @@ -37,7 +35,7 @@ testCreateAnyFileLists() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/share/${pkgbase}/test"; then fail "usr/share/${pkgbase}/test not found in ${arch}/extra${FILESEXT}" fi @@ -46,7 +44,6 @@ testCreateAnyFileLists() { } testCreateSplitFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase @@ -55,7 +52,7 @@ testCreateSplitFileLists() { local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -64,7 +61,7 @@ testCreateSplitFileLists() { for pkgbase in "${pkgs[@]}"; do pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo ${pkgname[@]})) for pkgname in "${pkgnames[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgname}"; then fail "usr/bin/${pkgname} not found in ${arch}/extra${FILESEXT}" fi @@ -75,23 +72,22 @@ testCreateSplitFileLists() { testCleanupFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" pkg-simple-a done - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/pkg-simple-b"; then fail "usr/bin/pkg-simple-b not found in ${arch}/extra${FILESEXT}" fi diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index e3207b6..410e222 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testMoveSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage testing "${pkgbase}" "${arch}" done done @@ -19,7 +18,7 @@ testMoveSimplePackages() { ../db-move testing extra pkg-simple-a - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackage extra "pkg-simple-a-1-1-${arch}.pkg.tar.xz" "${arch}" checkRemovedPackage testing "pkg-simple-a-1-1-${arch}.pkg.tar.xz" "${arch}" @@ -28,13 +27,12 @@ testMoveSimplePackages() { } testMoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage testing "${pkgbase}" "${arch}" done done @@ -44,7 +42,7 @@ testMoveMultiplePackages() { ../db-move testing extra pkg-simple-a pkg-simple-b for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackage extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" checkRemovedPackage testing "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done @@ -52,13 +50,12 @@ testMoveMultiplePackages() { } testMoveEpochPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage testing "${pkgbase}" "${arch}" done done @@ -67,7 +64,7 @@ testMoveEpochPackages() { ../db-move testing extra pkg-simple-epoch - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackage extra "pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" "${arch}" checkRemovedPackage testing "pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" "${arch}" done @@ -90,14 +87,13 @@ testMoveAnyPackages() { } testMoveSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage testing "${pkgbase}" "${arch}" done done @@ -105,12 +101,12 @@ testMoveSplitPackages() { ../db-update ../db-move testing extra pkg-split-a - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do for pkg in "${pkgdir}/pkg-split-a"/*-"${arch}"${PKGEXT}; do checkPackage extra "${pkg##*/}" "${arch}" done done - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do for pkg in "${pkgdir}/pkg-split-b"/*-"${arch}"${PKGEXT}; do checkPackage testing "${pkg##*/}" "${arch}" done diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index fca480c..4fd5548 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testRemovePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -18,38 +17,37 @@ testRemovePackages() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" "${pkgbase}" done done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkRemovedPackage extra "${pkgbase}" "${arch}" done done } testRemoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" "${pkgs[@]}" done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkRemovedPackage extra "${pkgbase}" "${arch}" done done diff --git a/test/test.d/db-repo-add.sh b/test/test.d/db-repo-add.sh index 3d83007..776c0a2 100755 --- a/test/test.d/db-repo-add.sh +++ b/test/test.d/db-repo-add.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testAddSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" touch "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/extra/os/${arch}/" @@ -20,19 +19,18 @@ testAddSimplePackages() { done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackageDB extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } testAddMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do add_pkgs=() for pkgbase in "${pkgs[@]}"; do cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" @@ -45,7 +43,7 @@ testAddMultiplePackages() { done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackageDB extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done diff --git a/test/test.d/db-repo-remove.sh b/test/test.d/db-repo-remove.sh index ce13280..fd69fa7 100755 --- a/test/test.d/db-repo-remove.sh +++ b/test/test.d/db-repo-remove.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testRemovePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -18,38 +17,37 @@ testRemovePackages() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-repo-remove extra "${arch}" "${pkgbase}" done done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkRemovedPackageDB extra "${pkgbase}" "${arch}" done done } testRemoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-repo-remove extra "${arch}" "${pkgs[@]}" done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkRemovedPackageDB extra "${pkgbase}" "${arch}" done done diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index c83d51b..48c243d 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testAddSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -18,7 +17,7 @@ testAddSimplePackages() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackage extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done @@ -52,14 +51,13 @@ testAddAnyPackages() { } testAddSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -67,7 +65,7 @@ testAddSplitPackages() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do for pkg in "${pkgdir}/${pkgbase}"/*-"${arch}"${PKGEXT}; do checkPackage extra "${pkg##*/}" "${arch}" done @@ -141,12 +139,11 @@ testUpdateSameAnyPackageToDifferentRepositories() { testAddIncompleteSplitPackage() { - local arches=('i686' 'x86_64') local repo='extra' local pkgbase='pkg-split-a' local arch - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage "${repo}" "${pkgbase}" "${arch}" done @@ -155,7 +152,7 @@ testAddIncompleteSplitPackage() { ../db-update >/dev/null 2>&1 && fail "db-update should fail when a split package is missing!" - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 1b075da..6902b9b 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -4,26 +4,25 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testCleanupSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" pkg-simple-a done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" checkRemovedPackage extra 'pkg-simple-a' "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" @@ -35,26 +34,25 @@ testCleanupSimplePackages() { } testCleanupEpochPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" pkg-simple-epoch done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do local pkg1="pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" checkRemovedPackage extra 'pkg-simple-epoch' "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" @@ -85,27 +83,26 @@ testCleanupAnyPackages() { } testCleanupSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" "${pkgs[0]}" done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do for pkg in "${pkgdir}/${pkgs[0]}"/*-"${arch}"${PKGEXT}; do checkRemovedPackage extra "${pkgs[0]}" "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index 1097ae0..561169e 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testSourceballs() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -38,14 +37,13 @@ testAnySourceballs() { } testSplitSourceballs() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -59,20 +57,19 @@ testSplitSourceballs() { } testSourceballsCleanup() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update ../cron-jobs/sourceballs - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" pkg-simple-a done -- 2.4.1
`grep -q` may exit as soon as it finds a match; the program piped in to it might not be finished writing, and consequently print a message about a "write error" to stderr. I'll add that this is not purely hypothetical--it happened to me while testing. --- test/lib/common.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/lib/common.inc b/test/lib/common.inc index 5b06616..83c54bd 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -177,7 +177,7 @@ checkAnyPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done @@ -221,7 +221,7 @@ checkPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -247,7 +247,7 @@ checkRemovedPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -273,7 +273,7 @@ checkRemovedAnyPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done -- 2.4.1
On Sun, May 17, 2015 at 07:44:15PM -0400, Luke Shumaker wrote:
`grep -q` may exit as soon as it finds a match; the program piped in to it might not be finished writing, and consequently print a message about a "write error" to stderr.
I'll add that this is not purely hypothetical--it happened to me while testing.
The rationale doesn't make sense to me. If the program writing to the input side of the pipe is the one throwing the error, why should piping grep's output to /dev/null change this?
--- test/lib/common.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/lib/common.inc b/test/lib/common.inc index 5b06616..83c54bd 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -177,7 +177,7 @@ checkAnyPackageDB() {
for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done @@ -221,7 +221,7 @@ checkPackageDB() {
for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -247,7 +247,7 @@ checkRemovedPackageDB() {
for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -273,7 +273,7 @@ checkRemovedAnyPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done -- 2.4.1
On Sun, 17 May 2015 20:38:33 -0400, Dave Reisner wrote:
On Sun, May 17, 2015 at 07:44:15PM -0400, Luke Shumaker wrote:
`grep -q` may exit as soon as it finds a match; the program piped in to it might not be finished writing, and consequently print a message about a "write error" to stderr.
I'll add that this is not purely hypothetical--it happened to me while testing.
The rationale doesn't make sense to me. If the program writing to the input side of the pipe is the one throwing the error, why should piping grep's output to /dev/null change this?
Because it changes when grep terminates. With `grep -q` grep terminates as soon as it finds a match, if we run grep without `-q`, but send the output to /dev/null then grep doesn't terminate until it reaches the end of the input. This is important because if grep hangs up too early (before the program on the input side finishes), then the program in the input side encounters a write error, as its destination no longer exists. -- Happy hacking, ~ Luke Shumaker
It is a method of notifying text-editors that a file is in Bash syntax without giving it a propper shebang (which would be confusing, as it would suggest that the file should be executable), as well as working across virtually all text-editors (unlike "-*- Mode: Bash -*-" or whatever). --- config | 2 ++ config.local.svn-community | 2 ++ config.local.svn-packages | 2 ++ test/lib/common.inc | 1 + 4 files changed, 7 insertions(+) diff --git a/config b/config index b781555..cdb552c 100644 --- a/config +++ b/config @@ -1,3 +1,5 @@ +#!/hint/bash + FTP_BASE="/srv/ftp" SVNREPO='' SVNUSER='' diff --git a/config.local.svn-community b/config.local.svn-community index 105ea66..5d61b5e 100644 --- a/config.local.svn-community +++ b/config.local.svn-community @@ -1,3 +1,5 @@ +#!/hint/bash + PKGREPOS=('community' 'community-testing' 'community-staging' 'multilib' 'multilib-testing' 'multilib-staging') PKGPOOL='pool/community' SRCPOOL='sources/community' diff --git a/config.local.svn-packages b/config.local.svn-packages index 958a483..34aab35 100644 --- a/config.local.svn-packages +++ b/config.local.svn-packages @@ -1,3 +1,5 @@ +#!/hint/bash + PKGREPOS=('core' 'extra' 'testing' 'staging' 'kde-unstable' 'gnome-unstable') PKGPOOL='pool/packages' SRCPOOL='sources/packages' diff --git a/test/lib/common.inc b/test/lib/common.inc index 83c54bd..954868b 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,3 +1,4 @@ +#!/hint/bash set -E . "$(dirname "${BASH_SOURCE[0]}")/../../config" -- 2.4.1
From: Luke Shumaker <LukeShu@sbcglobal.net> This does correct handling of - executing a program by symlink - any weird characters in the full path - I'm sure there's another case I thought about when I originally did this. --- cron-jobs/ftpdir-cleanup | 4 ++-- cron-jobs/integrity-check | 2 +- cron-jobs/update-web-db | 4 ++-- db-move | 4 ++-- db-remove | 4 ++-- db-repo-add | 4 ++-- db-repo-remove | 4 ++-- db-update | 4 ++-- test/test.d/create-filelists.sh | 2 +- test/test.d/db-move.sh | 2 +- test/test.d/db-remove.sh | 2 +- test/test.d/db-repo-add.sh | 2 +- test/test.d/db-repo-remove.sh | 2 +- test/test.d/db-update.sh | 2 +- test/test.d/ftpdir-cleanup.sh | 2 +- test/test.d/packages.sh | 2 +- test/test.d/signed-packages.sh | 2 +- test/test.d/sourceballs.sh | 2 +- test/test.d/testing2x.sh | 2 +- testing2x | 6 +++--- 20 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index f6487cf..4063c09 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/../config" -. "$(dirname "$0")/../db-functions" +. "$(dirname "$(readlink -e "$0")")/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" clean_pkg() { local pkg diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check index 677c0d3..7459380 100755 --- a/cron-jobs/integrity-check +++ b/cron-jobs/integrity-check @@ -1,6 +1,6 @@ #!/bin/bash -dirname="$(dirname "$0")" +dirname="$(dirname "$(readlink -e "$0")")" . "${dirname}/../config" . "${dirname}/../db-functions" diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db index 88bf464..c8bf74a 100755 --- a/cron-jobs/update-web-db +++ b/cron-jobs/update-web-db @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/../config" -. "$(dirname "$0")/../db-functions" +. "$(dirname "$(readlink -e "$0")")/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" # setup paths SPATH="/srv/http/archweb" diff --git a/db-move b/db-move index b589bca..a55dd50 100755 --- a/db-move +++ b/db-move @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: %s <repo-from> <repo-to> <pkgname|pkgbase> ..." "${0##*/}" diff --git a/db-remove b/db-remove index 59f2db0..9c86143 100755 --- a/db-remove +++ b/db-remove @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: %s <repo> <arch> <pkgname|pkgbase> ..." "${0##*/}" diff --git a/db-repo-add b/db-repo-add index 09ce865..4611bdf 100755 --- a/db-repo-add +++ b/db-repo-add @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: %s <repo> <arch> <pkgfile> ..." "${0##*/}" diff --git a/db-repo-remove b/db-repo-remove index 97a671b..aadc4ce 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: %s <repo> <arch> <pkgname> ..." "${0##*/}" diff --git a/db-update b/db-update index 7f59ce7..8966f0e 100755 --- a/db-update +++ b/db-update @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -ge 1 ]; then warning "Calling %s with a specific repository is no longer supported" "${0##*/}" diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index e16a8d1..21bf292 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testCreateSimpleFileLists() { diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 410e222..4b4120e 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testMoveSimplePackages() { diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index 4fd5548..a391197 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testRemovePackages() { diff --git a/test/test.d/db-repo-add.sh b/test/test.d/db-repo-add.sh index 776c0a2..266a696 100755 --- a/test/test.d/db-repo-add.sh +++ b/test/test.d/db-repo-add.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testAddSimplePackages() { diff --git a/test/test.d/db-repo-remove.sh b/test/test.d/db-repo-remove.sh index fd69fa7..727188d 100755 --- a/test/test.d/db-repo-remove.sh +++ b/test/test.d/db-repo-remove.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testRemovePackages() { diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index 48c243d..ca4efe7 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testAddSimplePackages() { diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 6902b9b..5a7afea 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testCleanupSimplePackages() { diff --git a/test/test.d/packages.sh b/test/test.d/packages.sh index 1a31a41..18266eb 100755 --- a/test/test.d/packages.sh +++ b/test/test.d/packages.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testPackages() { diff --git a/test/test.d/signed-packages.sh b/test/test.d/signed-packages.sh index 4eccb41..3ffe146 100755 --- a/test/test.d/signed-packages.sh +++ b/test/test.d/signed-packages.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testAddSignedPackage() { diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index 561169e..81c9265 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testSourceballs() { diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh index 3bbd353..c611ce4 100755 --- a/test/test.d/testing2x.sh +++ b/test/test.d/testing2x.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testTesting2xAnyPackage() { diff --git a/testing2x b/testing2x index e269248..901c1b0 100755 --- a/testing2x +++ b/testing2x @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 1 ]; then msg "usage: %s <pkgname|pkgbase> ..." "${0##*/}" @@ -54,7 +54,7 @@ for repo in "${STABLE_REPOS[@]}"; do repo_unlock "${repo}" "${pkgarch}" done if [ -n "${pkgs[${repo}]}" ]; then - "$(dirname "$0")/db-move" "${TESTING_REPO}" "${repo}" "${pkgs[${repo}]}" + "$(dirname "$(readlink -e "$0")")/db-move" "${TESTING_REPO}" "${repo}" "${pkgs[${repo}]}" fi done -- 2.4.1
It mistakenly looped over just the first element of the ARCHES array, instead of the entire array. This meant that it only checked the permissions for one architecture. --- db-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db-functions b/db-functions index eb61f51..4fd6763 100644 --- a/db-functions +++ b/db-functions @@ -470,7 +470,7 @@ check_repo_permission() { [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1 local arch - for arch in "${ARCHES}"; do + for arch in "${ARCHES[@]}"; do local dir="${FTP_BASE}/${repo}/os/${arch}/" [ -w "${dir}" ] || return 1 [ -f "${dir}${repo}"${DBEXT} -a ! -w "${dir}${repo}"${DBEXT} ] && return 1 -- 2.4.1
From: Luke Shumaker <LukeShu@sbcglobal.net> --- cron-jobs/check_archlinux/parse_pkgbuilds.sh | 10 +++++----- cron-jobs/devlist-mailer | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cron-jobs/check_archlinux/parse_pkgbuilds.sh b/cron-jobs/check_archlinux/parse_pkgbuilds.sh index 38af179..b857ac8 100755 --- a/cron-jobs/check_archlinux/parse_pkgbuilds.sh +++ b/cron-jobs/check_archlinux/parse_pkgbuilds.sh @@ -118,11 +118,11 @@ source_pkgbuild() { } find_pkgbuilds() { - #Skip over some dirs - local d="${1##*/}" - if [ "$d" = "CVS" -o "$d" = ".svn" ]; then - return - fi + #Skip over some dirs + local d="${1##*/}" + if [ "$d" = "CVS" -o "$d" = ".svn" ]; then + return + fi if [ -f "$1/PKGBUILD" ]; then source_pkgbuild "$1" diff --git a/cron-jobs/devlist-mailer b/cron-jobs/devlist-mailer index 61cd32c..1a05521 100755 --- a/cron-jobs/devlist-mailer +++ b/cron-jobs/devlist-mailer @@ -8,18 +8,18 @@ FROM="repomaint@archlinux.org" SUBJECT="Repository Maintenance $(date +"%d-%m-%Y")" if [ $# -ge 1 ]; then - SUBJECT="$1 $(date +"%d-%m-%Y")" + SUBJECT="$1 $(date +"%d-%m-%Y")" fi if [ $# -ge 2 ]; then - LIST="$2" + LIST="$2" fi stdin="$(cat)" #echo used to strip whitespace for checking for actual data if [ -n "$(echo $stdin)" ]; then -echo "Subject: $SUBJECT + echo "Subject: $SUBJECT To: $LIST From: $FROM -- 2.4.1
participants (2)
-
Dave Reisner
-
Luke Shumaker