summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2018-03-15 21:47:58 -0400
committerEli Schwartz <eschwartz@archlinux.org>2018-04-08 16:18:19 -0400
commit5b4b19cd7f4c0ef7a479306b73a4db3733df9c44 (patch)
tree1d24bbdf051454cf0cb3a5c6a54073d01d6f0fd4
parenta852b2822620b6294e2efa411ff88a3b0afe1754 (diff)
Fixup quoting around variables, especially arrays
Search for unquoted variables using the command: grep -Prn --exclude-dir=.git '(?<!["=]|\[\[ |\[\[ -[zn] )\$(?!{?#|\(|\? )' and ignore a bunch of false positives. You may verify that the only differences between the lines removed and lines added are double-quotes: diff -u \ <(git show|sed -n 's/^-//p'|grep -v '^-- a/'|sed 's/"//g') \ <(git show|sed -n 's/^+//p'|grep -v '^++ b/'|sed 's/"//g')
-rw-r--r--config2
-rwxr-xr-xcron-jobs/check_archlinux/parse_pkgbuilds.sh42
-rwxr-xr-xcron-jobs/devlist-mailer2
-rwxr-xr-xcron-jobs/ftpdir-cleanup28
-rwxr-xr-xcron-jobs/integrity-check6
-rwxr-xr-xcron-jobs/sourceballs30
-rwxr-xr-xcron-jobs/update-web-db20
-rw-r--r--db-functions70
-rwxr-xr-xdb-move56
-rwxr-xr-xdb-remove22
-rwxr-xr-xdb-repo-add22
-rwxr-xr-xdb-repo-remove22
-rwxr-xr-xdb-update36
-rwxr-xr-xtesting2x26
14 files changed, 192 insertions, 192 deletions
diff --git a/config b/config
index e5db66a..d703e7b 100644
--- a/config
+++ b/config
@@ -36,5 +36,5 @@ PKGEXTS=".pkg.tar.@(gz|bz2|xz|lzo|lrz|Z)"
ALLOWED_LICENSES=('GPL' 'GPL1' 'GPL2' 'GPL3' 'LGPL' 'LGPL1' 'LGPL2' 'LGPL2.1' 'LGPL3')
# Override default config with config.local
-LOCAL_CONFIG=${DBSCRIPTS_CONFIG:-"$(dirname ${BASH_SOURCE[0]})/config.local"}
+LOCAL_CONFIG=${DBSCRIPTS_CONFIG:-"$(dirname "${BASH_SOURCE[0]}")/config.local"}
[[ -f "${LOCAL_CONFIG}" ]] && . "${LOCAL_CONFIG}"
diff --git a/cron-jobs/check_archlinux/parse_pkgbuilds.sh b/cron-jobs/check_archlinux/parse_pkgbuilds.sh
index 27dca7b..dd153bf 100755
--- a/cron-jobs/check_archlinux/parse_pkgbuilds.sh
+++ b/cron-jobs/check_archlinux/parse_pkgbuilds.sh
@@ -6,7 +6,7 @@
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() {
@@ -30,31 +30,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
}
@@ -64,10 +64,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
@@ -77,8 +77,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
@@ -87,13 +87,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
eval "$restore_package_variables"
fi
@@ -113,14 +113,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
@@ -136,7 +136,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 712b38b..1b59cb3 100755
--- a/cron-jobs/devlist-mailer
+++ b/cron-jobs/devlist-mailer
@@ -23,6 +23,6 @@ if [[ -n "$(echo $stdin)" ]]; then
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 d54cdec..e742536 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 "$0")/../config"
+. "$(dirname "$0")/../db-functions"
clean_pkg() {
local pkg
@@ -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 = true ]] && 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
@@ -49,7 +49,7 @@ for repo in ${PKGREPOS[@]}; do
missing_pkgs=($(comm -13 "${WORKDIR}/repo-${repo}-${arch}" "${WORKDIR}/db-${repo}-${arch}"))
if (( ${#missing_pkgs[@]} >= 1 )); then
error "Missing packages in [%s] (%s)..." "$repo" "$arch"
- for missing_pkg in ${missing_pkgs[@]}; do
+ for missing_pkg in "${missing_pkgs[@]}"; do
msg2 '%s' "${missing_pkg}"
done
fi
@@ -57,7 +57,7 @@ for repo in ${PKGREPOS[@]}; do
old_pkgs=($(comm -23 "${WORKDIR}/repo-${repo}-${arch}" "${WORKDIR}/db-${repo}-${arch}"))
if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old packages from [%s] (%s)..." "$repo" "$arch"
- for old_pkg in ${old_pkgs[@]}; do
+ for old_pkg in "${old_pkgs[@]}"; do
msg2 '%s' "${old_pkg}"
clean_pkg "${FTP_BASE}/${repo}/os/${arch}/${old_pkg}"
done
@@ -75,7 +75,7 @@ cat "${WORKDIR}"/db-* 2>/dev/null | sort -u > "${WORKDIR}/db"
old_pkgs=($(comm -23 "${WORKDIR}/pool" "${WORKDIR}/db"))
if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old packages from package pool..."
- for old_pkg in ${old_pkgs[@]}; do
+ for old_pkg in "${old_pkgs[@]}"; do
msg2 '%s' "${old_pkg}"
clean_pkg "$FTP_BASE/${PKGPOOL}/${old_pkg}"
done
@@ -90,7 +90,7 @@ for f in "${CLEANUP_DESTDIR}"/**/*${PKGEXTS}; do
done
if (( ${#old_pkgs[@]} >= 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 '%s' "${old_pkg}"
if [[ $CLEANUP_DRYRUN != true ]]; then
rm -f "${CLEANUP_DESTDIR}/${old_pkg}"
@@ -99,9 +99,9 @@ if (( ${#old_pkgs[@]} >= 1 )); then
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 47cf856..17153c7 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,multilib'
diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs
index 14947ab..6be28ab 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
@@ -53,7 +53,7 @@ for f in "${FTP_BASE}"/${SRCPOOL}/*${SRCEXT}; do
done | 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 -r pkgbase pkgver pkgarch pkglicense; do
@@ -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 [%s]..." "$repo"
- for new_pkg in ${newpkgs[@]}; do
+ for new_pkg in "${newpkgs[@]}"; do
msg2 '%s' "${new_pkg}"
done
fi
if [ ${#failedpkgs[@]} -ge 1 ]; then
msg "Failed to create source packages for [%s]..." "$repo"
- for failed_pkg in ${failedpkgs[@]}; do
+ for failed_pkg in "${failedpkgs[@]}"; do
msg2 '%s' "${failed_pkg}"
done
fi
@@ -124,7 +124,7 @@ old_pkgs=($(comm -23 "${WORKDIR}/available-src-pkgs.sort" "${WORKDIR}/expected-s
if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old source packages..."
[[ $SOURCE_CLEANUP_DRYRUN = true ]] && warning 'dry run mode is active'
- for old_pkg in ${old_pkgs[@]}; do
+ for old_pkg in "${old_pkgs[@]}"; do
msg2 '%s' "${old_pkg}"
if [[ $SOURCE_CLEANUP_DRYRUN != true ]]; then
mv_acl "$FTP_BASE/${SRCPOOL}/${old_pkg}" "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}"
@@ -143,7 +143,7 @@ done
if (( ${#old_pkgs[@]} >= 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 '%s' "${old_pkg}"
[[ $SOURCE_CLEANUP_DRYRUN = true ]] || rm -f "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}"
done
diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db
index c859ce0..87e8bb0 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 a4a5522..0491c22 100644
--- a/db-functions
+++ b/db-functions
@@ -17,7 +17,7 @@ set_umask () {
}
restore_umask () {
- umask $UMASK >/dev/null
+ umask "$UMASK" >/dev/null
}
# Proxy function to check if a file exists. Using [[ -f ... ]] directly is not
@@ -50,7 +50,7 @@ REPO_MODIFIED=0
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 %s is already locked by %s." "${0##*/}" "$_owner"
exit 1
else
@@ -78,12 +78,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 [%s] (%s)" "$repo" "$arch"
- repo_unlock $repo $arch
+ repo_unlock "$repo" "$arch"
fi
done
if [[ -d $TMPDIR/.scriptlock.${0##*/} ]]; then
@@ -96,7 +96,7 @@ cleanup() {
date +%s > "${FTP_BASE}/lastupdate"
fi
- [[ -n $1 ]] && exit $1
+ [[ -n $1 ]] && exit "$1"
}
abort() {
@@ -125,7 +125,7 @@ repo_lock () {
# This is the lock file used by repo-add and repo-remove
if [[ -f ${DBLOCKFILE} ]]; then
- error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(cat $DBLOCKFILE)"
+ error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(cat "$DBLOCKFILE")"
return 1
fi
@@ -141,7 +141,7 @@ repo_lock () {
_count=0
while (( _count <= _trial )) || [[ $_lockblock = true ]]; 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 [%s] (%s) is already locked by %s." "$1" "$2" "$_owner"
msg2 "Retrying in %s seconds..." "$LOCK_DELAY"
else
@@ -149,7 +149,7 @@ repo_lock () {
set_umask
return 0
fi
- sleep $LOCK_DELAY
+ sleep "$LOCK_DELAY"
let _count=$_count+1
done
@@ -277,7 +277,7 @@ getpkgfile() {
exit 1
fi
- echo ${1}
+ echo "${1}"
}
getpkgfiles() {
@@ -291,30 +291,30 @@ getpkgfiles() {
files+=("$(getpkgfile "$f")") || exit 1
done
- echo ${files[@]}
+ echo "${files[@]}"
}
check_pkgfile() {
local pkgfile=$1
- local pkgname="$(getpkgname ${pkgfile})" || return 1
- local pkgver="$(getpkgver ${pkgfile})" || return 1
- local pkgarch="$(getpkgarch ${pkgfile})" || return 1
+ local pkgname="$(getpkgname "${pkgfile}")" || return 1
+ local pkgver="$(getpkgver "${pkgfile}")" || return 1
+ local pkgarch="$(getpkgarch "${pkgfile}")" || return 1
- in_array "${pkgarch}" ${ARCHES[@]} 'any' || return 1
+ in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1
- [[ ${pkgfile##*/} = ${pkgname}-${pkgver}-${pkgarch}* ]]
+ [[ ${pkgfile##*/} = "${pkgname}-${pkgver}-${pkgarch}"* ]]
}
check_pkgsvn() {
local pkgfile="${1}"
- local _pkgbase="$(getpkgbase ${pkgfile})" || return 1
- local _pkgname="$(getpkgname ${pkgfile})" || return 1
- local _pkgver="$(getpkgver ${pkgfile})" || return 1
- local _pkgarch="$(getpkgarch ${pkgfile})" || return 1
+ local _pkgbase="$(getpkgbase "${pkgfile}")" || return 1
+ local _pkgname="$(getpkgname "${pkgfile}")" || return 1
+ local _pkgver="$(getpkgver "${pkgfile}")" || return 1
+ local _pkgarch="$(getpkgarch "${pkgfile}")" || 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}"
@@ -325,8 +325,8 @@ check_pkgsvn() {
local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; get_full_version)"
[[ "${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
}
@@ -334,7 +334,7 @@ check_pkgsvn() {
check_splitpkgs() {
local repo="${1}"
shift
- local pkgfiles=(${@})
+ local pkgfiles=("${@}")
local pkgfile
local pkgdir
local svnname
@@ -342,11 +342,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"
@@ -356,7 +356,7 @@ check_splitpkgs() {
"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null || return 1
fi
- local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]}))
+ local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}"))
printf '%s\n' "${svnnames[@]}" >> "${repo}/${_pkgarch}/${_pkgbase}/svn"
done
popd >/dev/null
@@ -376,9 +376,9 @@ check_splitpkgs() {
check_pkgrepos() {
local pkgfile=$1
- local pkgname="$(getpkgname ${pkgfile})" || return 1
- local pkgver="$(getpkgver ${pkgfile})" || return 1
- local pkgarch="$(getpkgarch ${pkgfile})" || return 1
+ local pkgname="$(getpkgname "${pkgfile}")" || return 1
+ local pkgver="$(getpkgver "${pkgfile}")" || return 1
+ local pkgarch="$(getpkgarch "${pkgfile}")" || return 1
is_globfile "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS} && return 1
is_globfile "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS}.sig && return 1
@@ -392,7 +392,7 @@ check_pkgrepos() {
chk_license() {
local l
for l in "${@}"; do
- in_array ${l} ${ALLOWED_LICENSES[@]} && return 0
+ in_array "${l}" "${ALLOWED_LICENSES[@]}" && return 0
done
return 1
@@ -404,12 +404,12 @@ check_repo_permission() {
(( ${#PKGREPOS[@]} == 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} && ! -w ${dir}${repo}${DBEXT} ]] && return 1
@@ -450,7 +450,7 @@ arch_repo_modify() {
# package files for repo-add might be relative to repo dir
pushd "${dbfile%/*}" >/dev/null
- /usr/bin/repo-${action} -q "${dbfile}" "${pkgs[@]}" \
+ /usr/bin/"repo-${action}" -q "${dbfile}" "${pkgs[@]}" \
|| error '%s' "repo-${action} ${dbfile@Q} ${pkgs[*]@Q}"
set_repo_permission "${repo}" "${arch}"
popd >/dev/null
diff --git a/db-move b/db-move
index e686d5a..1fa2055 100755
--- a/db-move
+++ b/db-move
@@ -1,37 +1,37 @@
#!/bin/bash
-. "$(dirname $0)/config"
-. "$(dirname $0)/db-functions"
+. "$(dirname "$0")/config"
+. "$(dirname "$0")/db-functions"
if (( $# < 3 )); then
msg "usage: %s <repo-from> <repo-to> <pkgname|pkgbase> ..." "${0##*/}"
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 %s to %s" "$repo_from" "$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[@]} < 1 )); then
die "Could not read pkgname"
fi
@@ -41,15 +41,15 @@ for pkgbase in ${args[@]:2}; do
die "Could not read pkgver"
fi
- if [[ ${pkgarch} = any ]]; then
- tarches=(${ARCHES[@]})
+ if [[ "${pkgarch}" = any ]]; then
+ tarches=("${ARCHES[@]}")
else
tarches=("${pkgarch}")
fi
- for pkgname in ${pkgnames[@]}; do
- for tarch in ${tarches[@]}; do
- getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXTS} >/dev/null
+ for pkgname in "${pkgnames[@]}"; do
+ for tarch in "${tarches[@]}"; do
+ getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS} >/dev/null
done
done
continue 2
@@ -62,20 +62,20 @@ msg "Moving packages from [%s] to [%s]..." "$repo_from" "$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 "%s (%s)" "$pkgbase" "${tarches[*]}"
- pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]}))
+ pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo "${pkgname[@]}"))
pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version)
if [[ -d ${svnrepo_to} ]]; then
@@ -93,14 +93,14 @@ for pkgbase in ${args[@]:2}; do
arch_svn rm --force -q "${svnrepo_from}"
tag_list+=", $pkgarch"
- for pkgname in ${pkgnames[@]}; do
- for tarch in ${tarches[@]}; do
- pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXTS})
+ for pkgname in "${pkgnames[@]}"; do
+ for tarch in "${tarches[@]}"; do
+ pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS})
pkgfile="${pkgpath##*/}"
- ln -s "../../../${PKGPOOL}/${pkgfile}" ${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}/
+ 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_modify add "${repo_to}" "${tarch}" ${add_pkgs[${tarch}]}
arch_repo_modify 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 b34cda5..e42a977 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 (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgname|pkgbase> ..." "${0##*/}"
@@ -10,27 +10,27 @@ 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 %s" "$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 %s from [%s]..." "$pkgbase" "$repo"
arch_svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null
@@ -46,7 +46,7 @@ for pkgbase in ${pkgbases[@]}; do
fi
done
-for tarch in ${tarches[@]}; do
- arch_repo_modify remove "${repo}" "${tarch}" ${remove_pkgs[@]}
- repo_unlock $repo $tarch
+for tarch in "${tarches[@]}"; do
+ arch_repo_modify remove "${repo}" "${tarch}" "${remove_pkgs[@]}"
+ repo_unlock "$repo" "$tarch"
done
diff --git a/db-repo-add b/db-repo-add
index 90e94cc..1cc63af 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 (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgfile> ..." "${0##*/}"
@@ -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 %s" "$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/${tarch}/${pkgfile##*/} ]]; then
die "Package file %s not found in %s" "${pkgfile##*/}" "${FTP_BASE}/${repo}/os/${tarch}/"
else
msg "Adding %s to [%s]..." "$pkgfile" "$repo"
fi
done
- arch_repo_modify add "${repo}" "${tarch}" ${pkgfiles[@]}
- repo_unlock $repo $tarch
+ arch_repo_modify add "${repo}" "${tarch}" "${pkgfiles[@]}"
+ repo_unlock "$repo" "$tarch"
done
diff --git a/db-repo-remove b/db-repo-remove
index efe3828..40c1ac8 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 (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgname> ..." "${0##*/}"
@@ -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 %s" "$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 %s from [%s]..." "$pkgname" "$repo"
done
- arch_repo_modify remove "${repo}" "${tarch}" ${pkgnames[@]}
- repo_unlock $repo $tarch
+ arch_repo_modify remove "${repo}" "${tarch}" "${pkgnames[@]}"
+ repo_unlock "$repo" "$tarch"
done
diff --git a/db-update b/db-update
index b974a30..536f7fd 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 (( $# >= 1 )); then
warning "Calling %s with a specific repository is no longer supported" "${0##*/}"
@@ -16,27 +16,27 @@ mapfile -t -d '' staging_repos < <(
)
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 %s" "$repo"
fi
pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXTS}))
if (( $? == 0 )); then
- for pkg in ${pkgs[@]}; do
+ for pkg in "${pkgs[@]}"; do
if [[ -h ${pkg} ]]; then
die "Package %s is a symbolic link" "$repo/${pkg##*/}"
fi
@@ -62,7 +62,7 @@ for repo in ${repos[@]}; do
die "Package %s was not built in a chroot" "$repo/${pkg##*/}"
fi
done
- if ! check_splitpkgs ${repo} ${pkgs[@]}; then
+ if ! check_splitpkgs "${repo}" "${pkgs[@]}"; then
die "Missing split packages for %s" "$repo"
fi
else
@@ -70,13 +70,13 @@ for repo in ${repos[@]}; do
fi
done
-for repo in ${repos[@]}; do
+for repo in "${repos[@]}"; do
msg "Updating [%s]..." "$repo"
any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXTS} 2>/dev/null))
- for pkgarch in ${ARCHES[@]}; do
+ for pkgarch in "${ARCHES[@]}"; do
add_pkgs=()
- arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXTS} 2>/dev/null))
- for pkg in ${arch_pkgs[@]} ${any_pkgs[@]}; do
+ arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*"-${pkgarch}"${PKGEXTS} 2>/dev/null))
+ for pkg in "${arch_pkgs[@]}" "${any_pkgs[@]}"; do
pkgfile="${pkg##*/}"
msg2 '%s (%s)' "$pkgfile" "$pkgarch"
# any packages might have been moved by the previous run
@@ -99,8 +99,8 @@ for repo in ${repos[@]}; do
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/testing2x b/testing2x
index 3ac687d..c2bd6d4 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 (( $# < 1 )); then
msg "usage: %s <pkgname|pkgbase> ..." "${0##*/}"
@@ -11,8 +11,8 @@ 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 pkgarch in "${ARCHES[@]}"; do
+ repo_lock "${repo}" "${pkgarch}" || exit 1
done
done
@@ -23,7 +23,7 @@ for pkgbase in "$@"; do
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
@@ -32,8 +32,8 @@ for pkgbase in "$@"; do
done
[[ $found_source = true ]] || die "%s not found in [%s]" "$pkgbase" "$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
@@ -46,15 +46,15 @@ for pkgbase in "$@"; do
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