summaryrefslogtreecommitdiff
path: root/db-functions
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-06-18 20:33:06 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-04-16 13:51:18 -0400
commit6638878c5eb6d5116580d06cc3042a5e9beacb7e (patch)
tree92476d6e2ec6fada6b6e3bedb1cfcffcc7988065 /db-functions
parent7850874b1ef1b18de585be108e3be899d95a3a2a (diff)
Use printf-formatters instead of string interpolation on msg, error, etc.
Diffstat (limited to 'db-functions')
-rw-r--r--db-functions51
1 files changed, 25 insertions, 26 deletions
diff --git a/db-functions b/db-functions
index 39173f3..9845e45 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"
@@ -177,7 +177,7 @@ 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
@@ -194,8 +194,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
@@ -205,14 +205,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
@@ -267,7 +267,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
@@ -280,7 +280,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
@@ -292,7 +292,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
@@ -322,10 +322,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
@@ -341,10 +341,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
@@ -428,8 +428,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
@@ -502,12 +501,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
}
@@ -519,7 +518,7 @@ 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[*]}"
popd >/dev/null
set_repo_permission "${repo}" "${arch}"
@@ -533,11 +532,11 @@ arch_repo_remove() {
local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}"
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[*]}"
set_repo_permission "${repo}" "${arch}"
REPO_MODIFIED=1