summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-06-18 00:32:24 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-06-18 00:32:24 -0400
commit43f8af33f08924092826e2094d15be704e842f3a (patch)
tree73b982bf9356c397085b3a0d0f1360708a799288
parent426c14d9a8364193dec631a389470fb4465ef9ce (diff)
more quoting and printf fixes
-rw-r--r--db-functions52
-rwxr-xr-xdb-move34
-rwxr-xr-xdb-remove16
-rwxr-xr-xdb-repo-add26
-rwxr-xr-xdb-repo-remove24
5 files changed, 76 insertions, 76 deletions
diff --git a/db-functions b/db-functions
index 006dde9..6e27148 100644
--- a/db-functions
+++ b/db-functions
@@ -40,7 +40,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 %s is already locked by $_owner." "${0##*/}"
+ error "Script %s is already locked by %s." "${0##*/}" "$_owner"
exit 1
else
set_umask
@@ -136,7 +136,7 @@ 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 [%s] (%s) is already locked by %s. " "${1}" "${2}" "$_owner"
+ warning "Repo [%s] (%s) is already locked by %s." "${1}" "${2}" "$_owner"
msg2 "Retrying in %d seconds..." "$LOCK_DELAY"
else
LOCKS+=("$1.$2")
@@ -239,10 +239,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
@@ -258,10 +258,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
@@ -290,13 +290,13 @@ check_pkgfile() {
check_pkgxbs() {
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}"
@@ -324,10 +324,10 @@ check_splitpkgs() {
for pkgfile in "${pkgfiles[@]}"; do
issplitpkg "${pkgfile}" || continue
- local _pkgbase="$(getpkgbase ${pkgfile})"
+ local _pkgbase="$(getpkgbase "${pkgfile}")"
msg2 "Checking %s" "$_pkgbase"
- local _pkgname="$(getpkgname ${pkgfile})"
- local _pkgarch="$(getpkgarch ${pkgfile})"
+ local _pkgname="$(getpkgname "${pkgfile}")"
+ local _pkgarch="$(getpkgarch "${pkgfile}")"
mkdir -p "${repo}/${_pkgarch}/${_pkgbase}"
echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging"
@@ -353,11 +353,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
@@ -389,11 +389,11 @@ 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
- [ -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
@@ -407,12 +407,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
}
@@ -424,9 +424,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[@]}" >/dev/null \
- || 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}"
diff --git a/db-move b/db-move
index fe94883..f6588c3 100755
--- a/db-move
+++ b/db-move
@@ -4,7 +4,7 @@
. "$(dirname "$(readlink -e "$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
@@ -14,14 +14,14 @@ 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
+ repo_lock "${repo_to}" "${pkgarch}" || exit 1
+ repo_lock "${repo_from}" "${pkgarch}" || exit 1
done
# First loop is to check that all necessary files exist
@@ -41,30 +41,30 @@ for pkgbase in "${args[@]:2}"; do
fi
for pkgname in "${pkgnames[@]}"; do
- pkgver=$(. "${xbsrepo_from}/PKGBUILD"; get_full_version ${pkgname})
+ pkgver=$(. "${xbsrepo_from}/PKGBUILD"; get_full_version "${pkgname}")
if [ -z "${pkgver}" ]; then
die "Could not read pkgver"
fi
for tarch in "${tarches[@]}"; do
- getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT} >/dev/null
+ getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} >/dev/null
done
done
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
for pkgbase in "${args[@]:2}"; do
# move the package in xbs
- arches=($(xbs move ${repo_from} ${repo_to} ${pkgbase}))
+ arches=($(xbs move "${repo_from}" "${repo_to}" "${pkgbase}"))
# move the package in ftp
for pkgarch in "${arches[@]}"; do
- dir_to="$(xbs releasepath $pkgbase $repo_to $pkgarch)"
+ dir_to="$(xbs releasepath "$pkgbase" "$repo_to" "$pkgarch")"
if true; then # to add in indent level to make merging easier
if [ "${pkgarch}" == 'any' ]; then
tarches=("${ARCHES[@]}")
@@ -74,14 +74,14 @@ for pkgbase in "${args[@]:2}"; do
eval "pkgnames=($(. "${dir_to}/PKGBUILD"; printf '%q ' "${pkgname[@]}"))"
for pkgname in "${pkgnames[@]}"; do
- pkgver=$(. "${dir_to}/PKGBUILD"; get_full_version ${pkgname})
+ pkgver=$(. "${dir_to}/PKGBUILD"; get_full_version "${pkgname}")
for tarch in "${tarches[@]}"; do
- pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT})
+ 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} "
@@ -99,6 +99,6 @@ for tarch in "${ARCHES[@]}"; do
done
for pkgarch in "${ARCHES[@]}"; do
- repo_unlock ${repo_from} ${pkgarch}
- repo_unlock ${repo_to} ${pkgarch}
+ repo_unlock "${repo_from}" "${pkgarch}"
+ repo_unlock "${repo_to}" "${pkgarch}"
done
diff --git a/db-remove b/db-remove
index 73919be..970d252 100755
--- a/db-remove
+++ b/db-remove
@@ -4,7 +4,7 @@
. "$(dirname "$(readlink -e "$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
@@ -12,8 +12,8 @@ repo="$1"
arch="$2"
pkgbases=("${@:3}")
-if ! check_repo_permission $repo; then
- die "You don't have permission to remove packages from ${repo}"
+if ! check_repo_permission "$repo"; then
+ die "You don't have permission to remove packages from %s" "${repo}"
fi
if [ "$arch" == "any" ]; then
@@ -23,19 +23,19 @@ else
fi
for tarch in "${tarches[@]}"; do
- repo_lock $repo $tarch || exit 1
+ repo_lock "$repo" "$tarch" || exit 1
done
remove_pkgs=()
for pkgbase in "${pkgbases[@]}"; do
- msg "Removing $pkgbase from [$repo]..."
+ msg "Removing %s from [%s]..." "$pkgbase" "$repo"
path="$(xbs releasepath "$pkgbase" "$repo" "$arch")"
if [ -d "$path" ]; then
eval "remove_pkgs+=($(. "$path/PKGBUILD"; printf '%q ' "${pkgname[@]}"))"
xbs unrelease "$pkgbase" "$repo" "$arch"
else
- warning "$pkgbase not found in XBS $repo-$arch"
- warning "Removing only $pkgbase from the repo"
+ warning "%s not found in XBS %s" "$pkgbase" "$repo-$arch"
+ warning "Removing only %s from the repo" "$pkgbase"
warning "If it was a split package you have to remove the others yourself!"
remove_pkgs+=("$pkgbase")
fi
@@ -43,5 +43,5 @@ done
for tarch in "${tarches[@]}"; do
arch_repo_remove "${repo}" "${tarch}" "${remove_pkgs[@]}"
- repo_unlock $repo $tarch
+ repo_unlock "$repo" "$tarch"
done
diff --git a/db-repo-add b/db-repo-add
index a6355a1..4611bdf 100755
--- a/db-repo-add
+++ b/db-repo-add
@@ -4,38 +4,38 @@
. "$(dirname "$(readlink -e "$0")")/db-functions"
if [ $# -lt 3 ]; then
- msg "usage: ${0##*/} <repo> <arch> <pkgfile> ..."
+ msg "usage: %s <repo> <arch> <pkgfile> ..." "${0##*/}"
exit 1
fi
repo="$1"
arch="$2"
-pkgfiles=(${@:3})
+pkgfiles=("${@:3}")
ftppath="$FTP_BASE/$repo/os"
-if ! check_repo_permission $repo; then
- die "You don't have permission to add packages to ${repo}"
+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/${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[@]}
- 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 7077d62..aadc4ce 100755
--- a/db-repo-remove
+++ b/db-repo-remove
@@ -4,34 +4,34 @@
. "$(dirname "$(readlink -e "$0")")/db-functions"
if [ $# -lt 3 ]; then
- msg "usage: ${0##*/} <repo> <arch> <pkgname> ..."
+ msg "usage: %s <repo> <arch> <pkgname> ..." "${0##*/}"
exit 1
fi
repo="$1"
arch="$2"
-pkgnames=(${@:3})
+pkgnames=("${@:3}")
ftppath="$FTP_BASE/$repo/os"
-if ! check_repo_permission $repo; then
- die "You don't have permission to remove packages from ${repo}"
+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
- msg "Removing $pkgname from [$repo]..."
+for tarch in "${tarches[@]}"; do
+ for pkgname in "${pkgnames[@]}"; do
+ msg "Removing %s from [%s]..." "$pkgname" "$repo"
done
- arch_repo_remove "${repo}" "${tarch}" ${pkgnames[@]}
- repo_unlock $repo $tarch
+ arch_repo_remove "${repo}" "${tarch}" "${pkgnames[@]}"
+ repo_unlock "$repo" "$tarch"
done