summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2018-02-12 20:50:57 -0500
committerPierre Schmitz <mail@pierre-schmitz.com>2018-02-15 16:41:37 +0100
commitb61a7148eaf546a31597b74d9dd8948e4a39dea1 (patch)
tree07e74b11f48110b64dde0086309105e8bfa3d679
parentf4f9d1a0099c1f784c4a964e2b5651b56f629b82 (diff)
Use more bashisms
Fix numerous instances of POSIX `[ ... ]`, including reliance on ugly deprecated constructs like POSIX `-a`. Since we require bash regardless, it makes sense to take full advantage of it. bash `[[ ... ]]` does not require quoting variables as the shell natively recognizes them as variables rather than expanded strings. Use shell arithmetic rather than test, when checking numerical values.
-rw-r--r--config2
-rw-r--r--db-functions83
-rwxr-xr-xdb-move20
-rwxr-xr-xdb-remove6
-rwxr-xr-xdb-repo-add6
-rwxr-xr-xdb-repo-remove4
-rwxr-xr-xdb-update14
-rwxr-xr-xtesting2x12
8 files changed, 73 insertions, 74 deletions
diff --git a/config b/config
index 92cc4a5..90aa8c0 100644
--- a/config
+++ b/config
@@ -33,4 +33,4 @@ ALLOWED_LICENSES=('GPL' 'GPL1' 'GPL2' 'GPL3' 'LGPL' 'LGPL1' 'LGPL2' 'LGPL2.1' 'L
# Override default config with config.local
LOCAL_CONFIG=${DBSCRIPTS_CONFIG:-"$(dirname ${BASH_SOURCE[0]})/config.local"}
-[ -f "${LOCAL_CONFIG}" ] && . "${LOCAL_CONFIG}"
+[[ -f "${LOCAL_CONFIG}" ]] && . "${LOCAL_CONFIG}"
diff --git a/db-functions b/db-functions
index d66955b..c0af03c 100644
--- a/db-functions
+++ b/db-functions
@@ -8,8 +8,7 @@ CARCH="x86_64"
# Useful functions
UMASK=""
set_umask () {
- [ "$UMASK" == "" ] && UMASK="$(umask)"
- export UMASK
+ export UMASK="${UMASK:-$(umask)}"
umask 002
}
@@ -28,7 +27,7 @@ mv_acl() {
# set up general environment
WORKDIR=$(mktemp -d "${TMPDIR}/${0##*/}.XXXXXXXXXX")
-if [ -n "${SVNUSER}" ]; then
+if [[ -n ${SVNUSER} ]]; then
setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}"
setfacl -m d:u:"${USER}":rwx "${WORKDIR}"
setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}"
@@ -50,7 +49,7 @@ script_lock() {
script_unlock() {
local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}"
- if [ ! -d "$LOCKDIR" ]; then
+ if [[ ! -d $LOCKDIR ]]; then
warning "Script %s was not locked!" "${0##*/}"
restore_umask
return 1
@@ -70,12 +69,12 @@ cleanup() {
for l in ${LOCKS[@]}; do
repo=${l%.*}
arch=${l#*.}
- if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then
+ if [[ -d $TMPDIR/.repolock.$repo.$arch ]]; then
msg "Removing left over lock from [%s] (%s)" "$repo" "$arch"
repo_unlock $repo $arch
fi
done
- if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then
+ if [[ -d $TMPDIR/.scriptlock.${0##*/} ]]; then
msg "Removing left over lock from %s" "${0##*/}"
script_unlock
fi
@@ -85,7 +84,7 @@ cleanup() {
date +%s > "${FTP_BASE}/lastupdate"
fi
- [ "$1" ] && exit $1
+ [[ -n $1 ]] && exit $1
}
abort() {
@@ -113,22 +112,22 @@ repo_lock () {
local _owner
# This is the lock file used by repo-add and repo-remove
- if [ -f "${DBLOCKFILE}" ]; then
+ if [[ -f ${DBLOCKFILE} ]]; then
error "Repo [%s] (%s) is already locked by repo-{add,remove} process %s" "$1" "$2" "$(cat $DBLOCKFILE)"
return 1
fi
- if [ $# -eq 2 ]; then
+ if (( $# == 2 )); then
_lockblock=true
_trial=0
- elif [ $# -eq 3 ]; then
+ elif (( $# == 3 )); then
_lockblock=false
_timeout=$3
let _trial=$_timeout/$LOCK_DELAY
fi
_count=0
- while [ $_count -le $_trial ] || $_lockblock ; do
+ while (( _count <= _trial )) || $_lockblock ; do
if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then
_owner="$(/usr/bin/stat -c %U $LOCKDIR)"
warning "Repo [%s] (%s) is already locked by %s." "$1" "$2" "$_owner"
@@ -148,7 +147,7 @@ repo_lock () {
repo_unlock () { #repo_unlock <repo-name> <arch>
local LOCKDIR="$TMPDIR/.repolock.$1.$2"
- if [ ! -d "$LOCKDIR" ]; then
+ if [[ ! -d $LOCKDIR ]]; then
warning "Repo lock [%s] (%s) was not locked!" "$1" "$2"
restore_umask
return 1
@@ -180,7 +179,7 @@ getpkgbase() {
local _base
_base="$(_grep_pkginfo "$1" "pkgbase")"
- if [ -z "$_base" ]; then
+ if [[ -z $_base ]]; then
getpkgname "$1"
else
echo "$_base"
@@ -191,7 +190,7 @@ issplitpkg() {
local _base
_base="$(_grep_pkginfo "$1" "pkgbase")"
- if [ -z "$_base" ]; then
+ if [[ -z $_base ]]; then
return 1
else
return 0
@@ -203,7 +202,7 @@ getpkgname() {
local _name
_name="$(_grep_pkginfo "$1" "pkgname")"
- if [ -z "$_name" ]; then
+ if [[ -z $_name ]]; then
error "Package '%s' has no pkgname in the PKGINFO. Fail!" "$1"
exit 1
fi
@@ -216,7 +215,7 @@ getpkgver() {
local _ver
_ver="$(_grep_pkginfo "$1" "pkgver")"
- if [ -z "$_ver" ]; then
+ if [[ -z $_ver ]]; then
error "Package '%s' has no pkgver in the PKGINFO. Fail!" "$1"
exit 1
fi
@@ -228,7 +227,7 @@ getpkgarch() {
local _ver
_ver="$(_grep_pkginfo "$1" "arch")"
- if [ -z "$_ver" ]; then
+ if [[ -z $_ver ]]; then
error "Package '%s' has no arch in the PKGINFO. Fail!" "$1"
exit 1
fi
@@ -240,7 +239,7 @@ check_packager() {
local _packager
_packager=$(_grep_pkginfo "$1" "packager")
- [[ $_packager && $_packager != 'Unknown Packager' ]]
+ [[ -n $_packager && $_packager != 'Unknown Packager' ]]
}
check_buildinfo() {
@@ -251,17 +250,17 @@ check_builddir() {
local _builddir
_builddir=$(_grep_buildinfo "$1" "builddir")
- [[ $_builddir && $_builddir = '/build' ]]
+ [[ -n $_builddir && $_builddir = '/build' ]]
}
getpkgfile() {
- if [[ ${#} -ne 1 ]]; then
+ if (( $# != 1 )); then
error 'No canonical package found!'
exit 1
- elif [ ! -f "${1}" ]; then
+ elif [[ ! -f ${1} ]]; then
error "Package %s not found!" "$1"
exit 1
- elif [ ! -f "${1}.sig" ]; then
+ elif [[ ! -f ${1}.sig ]]; then
error "Package signature %s.sig not found!" "$1"
exit 1
fi
@@ -270,8 +269,8 @@ getpkgfile() {
}
getpkgfiles() {
- local f
- if [ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]; then
+ local f files
+ if [[ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]]; then
error 'Duplicate packages found!'
exit 1
fi
@@ -315,14 +314,14 @@ check_pkgsvn() {
in_array "${repo}" ${PKGREPOS[@]} || return 1
- if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then
+ if [[ ! -f ${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase} ]]; then
mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}"
arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null || return 1
fi
local svnver="$(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; get_full_version)"
- [ "${svnver}" == "${_pkgver}" ] || return 1
+ [[ "${svnver}" = "${_pkgver}" ]] || return 1
local svnnames=($(. "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo ${pkgname[@]}))
in_array "${_pkgname}" ${svnnames[@]} || return 1
@@ -349,7 +348,7 @@ check_splitpkgs() {
mkdir -p "${repo}/${_pkgarch}/${_pkgbase}"
echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging"
- if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then
+ if [[ ! -f ${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase} ]]; then
mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}"
arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null || return 1
@@ -363,10 +362,10 @@ check_splitpkgs() {
popd >/dev/null
for pkgdir in "${WORKDIR}/check_splitpkgs/${repo}"/*/*; do
- [ ! -d "${pkgdir}" ] && continue
+ [[ ! -d ${pkgdir} ]] && continue
sort -u "${pkgdir}/staging" -o "${pkgdir}/staging"
sort -u "${pkgdir}/svn" -o "${pkgdir}/svn"
- if [ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/svn")" ]; then
+ if [[ ! -z "$(comm -13 "${pkgdir}/staging" "${pkgdir}/svn")" ]]; then
return 1
fi
done
@@ -381,10 +380,10 @@ check_pkgrepos() {
local pkgver="$(getpkgver ${pkgfile})" || return 1
local pkgarch="$(getpkgarch ${pkgfile})" || return 1
- [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1
- [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1
- [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}" ] && return 1
- [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig" ] && return 1
+ [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}${PKGEXT} ]] && return 1
+ [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}${PKGEXT}.sig ]] && return 1
+ [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile##*/} ]] && return 1
+ [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig ]] && return 1
return 0
}
@@ -402,19 +401,19 @@ chk_license() {
check_repo_permission() {
local repo=$1
- [ ${#PKGREPOS[@]} -eq 0 ] && return 1
- [ -z "${PKGPOOL}" ] && return 1
+ (( ${#PKGREPOS[@]} == 0 )) && return 1
+ [[ -z "${PKGPOOL}" ]] && return 1
in_array "${repo}" ${PKGREPOS[@]} || return 1
- [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1
+ [[ -w $FTP_BASE/${PKGPOOL} ]] || return 1
local arch
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
+ [[ -w ${dir} ]] || return 1
+ [[ -f ${dir}${repo}${DBEXT} && ! -w ${dir}${repo}${DBEXT} ]] && return 1
+ [[ -f ${dir}${repo}${FILESEXT} && ! -w ${dir}${repo}${FILESEXT} ]] && return 1
done
return 0
@@ -426,7 +425,7 @@ set_repo_permission() {
local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}"
local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}"
- if [ -w "${dbfile}" ]; then
+ if [[ -w ${dbfile} ]]; then
local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")")
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"
@@ -458,7 +457,7 @@ arch_repo_remove() {
local pkgs=(${@:3})
local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}"
- if [ ! -f "${dbfile}" ]; then
+ if [[ ! -f ${dbfile} ]]; then
error "No database found at '%s'" "$dbfile"
return 1
fi
@@ -470,7 +469,7 @@ arch_repo_remove() {
}
arch_svn() {
- if [ -z "${SVNUSER}" ]; then
+ if [[ -z ${SVNUSER} ]]; then
/usr/bin/svn "${@}"
else
sudo -u "${SVNUSER}" -- /usr/bin/svn --username "${USER}" "${@}"
diff --git a/db-move b/db-move
index 71b62ea..37a9884 100755
--- a/db-move
+++ b/db-move
@@ -3,7 +3,7 @@
. "$(dirname $0)/config"
. "$(dirname $0)/db-functions"
-if [ $# -lt 3 ]; then
+if (( $# < 3 )); then
msg "usage: ${0##*/} <repo-from> <repo-to> <pkgname|pkgbase> ..."
exit 1
fi
@@ -30,18 +30,18 @@ for pkgbase in ${args[@]:2}; do
arch_svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null
for pkgarch in ${ARCHES[@]} 'any'; do
svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}"
- if [ -r "${svnrepo_from}/PKGBUILD" ]; then
+ if [[ -r ${svnrepo_from}/PKGBUILD ]]; then
pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]}))
- if [ ${#pkgnames[@]} -lt 1 ]; then
+ if (( ${#pkgnames[@]} < 1 )); then
die "Could not read pkgname"
fi
pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version)
- if [ -z "${pkgver}" ]; then
+ if [[ -z ${pkgver} ]]; then
die "Could not read pkgver"
fi
- if [ "${pkgarch}" == 'any' ]; then
+ if [[ ${pkgarch} = any ]]; then
tarches=(${ARCHES[@]})
else
tarches=("${pkgarch}")
@@ -68,8 +68,8 @@ for pkgbase in ${args[@]:2}; 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
+ if [[ -f ${svnrepo_from}/PKGBUILD ]]; then
+ if [[ ${pkgarch} = any ]]; then
tarches=(${ARCHES[@]})
else
tarches=("${pkgarch}")
@@ -78,7 +78,7 @@ for pkgbase in ${args[@]:2}; do
pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]}))
pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version)
- if [ -d "${svnrepo_to}" ]; then
+ if [[ -d ${svnrepo_to} ]]; then
for file in $(arch_svn ls "${svnrepo_to}"); do
arch_svn rm -q "${svnrepo_to}/$file@"
done
@@ -99,7 +99,7 @@ for pkgbase in ${args[@]:2}; do
pkgfile="${pkgpath##*/}"
ln -s "../../../${PKGPOOL}/${pkgfile}" ${ftppath_to}/${tarch}/
- if [ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig ]; then
+ if [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}/${pkgfile}.sig" ${ftppath_to}/${tarch}/
fi
add_pkgs[${tarch}]+="${FTP_BASE}/${PKGPOOL}/${pkgfile} "
@@ -113,7 +113,7 @@ for pkgbase in ${args[@]:2}; do
done
for tarch in ${ARCHES[@]}; do
- if [ -n "${add_pkgs[${tarch}]}" ]; then
+ 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
diff --git a/db-remove b/db-remove
index 4f7a0f7..70502bc 100755
--- a/db-remove
+++ b/db-remove
@@ -3,7 +3,7 @@
. "$(dirname $0)/config"
. "$(dirname $0)/db-functions"
-if [ $# -lt 3 ]; then
+if (( $# < 3 )); then
msg "usage: ${0##*/} <repo> <arch> <pkgname|pkgbase> ..."
exit 1
fi
@@ -19,7 +19,7 @@ if ! check_repo_permission $repo; then
die "You don't have permission to remove packages from %s" "$repo"
fi
-if [ "$arch" == "any" ]; then
+if [[ $arch = any ]]; then
tarches=(${ARCHES[@]})
else
tarches=("$arch")
@@ -34,7 +34,7 @@ for pkgbase in ${pkgbases[@]}; do
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
+ if [[ -d ${WORKDIR}/svn/$pkgbase/repos/$svnrepo ]]; then
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)"
diff --git a/db-repo-add b/db-repo-add
index f6a3d70..d7be302 100755
--- a/db-repo-add
+++ b/db-repo-add
@@ -3,7 +3,7 @@
. "$(dirname $0)/config"
. "$(dirname $0)/db-functions"
-if [ $# -lt 3 ]; then
+if (( $# < 3 )); then
msg "usage: ${0##*/} <repo> <arch> <pkgfile> ..."
exit 1
fi
@@ -18,7 +18,7 @@ if ! check_repo_permission $repo; then
die "You don't have permission to add packages to %s" "$repo"
fi
-if [ "$arch" == "any" ]; then
+if [[ $arch = any ]]; then
tarches=(${ARCHES[@]})
else
tarches=("$arch")
@@ -30,7 +30,7 @@ done
for tarch in ${tarches[@]}; do
for pkgfile in ${pkgfiles[@]}; do
- if [[ ! -f "${FTP_BASE}/${repo}/os/${tarch}/${pkgfile##*/}" ]]; then
+ 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"
diff --git a/db-repo-remove b/db-repo-remove
index 2f08ebc..32d167e 100755
--- a/db-repo-remove
+++ b/db-repo-remove
@@ -3,7 +3,7 @@
. "$(dirname $0)/config"
. "$(dirname $0)/db-functions"
-if [ $# -lt 3 ]; then
+if (( $# < 3 )); then
msg "usage: ${0##*/} <repo> <arch> <pkgname> ..."
exit 1
fi
@@ -18,7 +18,7 @@ if ! check_repo_permission $repo; then
die "You don't have permission to remove packages from %s" "$repo"
fi
-if [ "$arch" == "any" ]; then
+if [[ $arch = any ]]; then
tarches=(${ARCHES[@]})
else
tarches=("$arch")
diff --git a/db-update b/db-update
index 57c0813..45755a4 100755
--- a/db-update
+++ b/db-update
@@ -3,7 +3,7 @@
. "$(dirname $0)/config"
. "$(dirname $0)/db-functions"
-if [ $# -ge 1 ]; then
+if (( $# >= 1 )); then
warning "Calling %s with a specific repository is no longer supported" "${0##*/}"
exit 1
fi
@@ -33,9 +33,9 @@ for repo in ${repos[@]}; do
die "You don't have permission to update packages in %s" "$repo"
fi
pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT}))
- if [ $? -eq 0 ]; then
+ if (( $? == 0 )); then
for pkg in ${pkgs[@]}; do
- if [ -h "${pkg}" ]; then
+ if [[ -h ${pkg} ]]; then
die "Package %s is a symbolic link" "$repo/${pkg##*/}"
fi
if ! check_pkgfile "${pkg}"; then
@@ -78,20 +78,20 @@ for repo in ${repos[@]}; do
pkgfile="${pkg##*/}"
msg2 "${pkgfile} (${pkgarch})"
# any packages might have been moved by the previous run
- if [ -f "${pkg}" ]; then
+ if [[ -f ${pkg} ]]; then
mv "${pkg}" "$FTP_BASE/${PKGPOOL}"
fi
ln -s "../../../${PKGPOOL}/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}"
# also move signatures
- if [ -f "${pkg}.sig" ]; then
+ if [[ -f ${pkg}.sig ]]; then
mv "${pkg}.sig" "$FTP_BASE/${PKGPOOL}"
fi
- if [ -f "$FTP_BASE/${PKGPOOL}/${pkgfile}.sig" ]; then
+ if [[ -f $FTP_BASE/${PKGPOOL}/${pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "$FTP_BASE/$repo/os/${pkgarch}"
fi
add_pkgs+=("${pkgfile}")
done
- if [ ${#add_pkgs[@]} -ge 1 ]; then
+ if (( ${#add_pkgs[@]} >= 1 )); then
arch_repo_add "${repo}" "${pkgarch}" ${add_pkgs[@]}
fi
done
diff --git a/testing2x b/testing2x
index f51c4c0..f0d77cb 100755
--- a/testing2x
+++ b/testing2x
@@ -3,7 +3,7 @@
. "$(dirname $0)/config"
. "$(dirname $0)/db-functions"
-if [ $# -lt 1 ]; then
+if (( $# < 1 )); then
msg "usage: ${0##*/} <pkgname|pkgbase> ..."
exit 1
fi
@@ -19,13 +19,13 @@ done
declare -A pkgs
for pkgbase in $*; do
- if [ ! -d "${WORKDIR}/${pkgbase}" ]; then
+ 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
svnrepo_from="${WORKDIR}/${pkgbase}/${TESTING_REPO}-${pkgarch}"
- if [ -r "${svnrepo_from}/PKGBUILD" ]; then
+ if [[ -r ${svnrepo_from}/PKGBUILD ]]; then
found_source=true
break
fi
@@ -35,7 +35,7 @@ for pkgbase in $*; 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
+ if [[ -r ${svnrepo_to}/PKGBUILD ]]; then
found_target=true
pkgs[${repo}]+="${pkgbase} "
break 2
@@ -49,11 +49,11 @@ done
for pkgarch in ${ARCHES[@]}; do
repo_unlock ${TESTING_REPO} ${pkgarch}
done
-for repo in ${STABLE_REPOS[@]}; do
+for repo in ${STABLE_REPOS[@]}; do
for pkgarch in ${ARCHES[@]}; do
repo_unlock ${repo} ${pkgarch}
done
- if [ -n "${pkgs[${repo}]}" ]; then
+ if [[ -n ${pkgs[${repo}]} ]]; then
"$(dirname $0)/db-move" ${TESTING_REPO} "${repo}" ${pkgs[${repo}]}
fi
done