summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2018-02-12 17:53:10 -0500
committerPierre Schmitz <mail@pierre-schmitz.com>2018-02-15 16:41:37 +0100
commit5afac1ed83479c5ff7aab134b54245ec4f5b59fe (patch)
tree5fb93d7d036a68a901ab6ffb1703b84b87698bfb
parenteec8e35eba84658bdd03230c83f449d2bb437b10 (diff)
Update messages to make full use of printf formatters
libmakepkg messaging functions provide automatic access to gettext (which we do not currently make use of) in addition to cleanly separating data from message strings. In order for this to work properly, pass argv correctly from die() to libmakepkg's error()
-rwxr-xr-xcron-jobs/ftpdir-cleanup4
-rwxr-xr-xcron-jobs/sourceballs4
-rwxr-xr-xcron-jobs/update-web-db4
-rw-r--r--db-functions48
-rwxr-xr-xdb-move6
-rwxr-xr-xdb-remove8
-rwxr-xr-xdb-repo-add6
-rwxr-xr-xdb-repo-remove4
-rwxr-xr-xdb-update28
-rwxr-xr-xtesting2x4
10 files changed, 58 insertions, 58 deletions
diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
index 2683676..2f3d5aa 100755
--- a/cron-jobs/ftpdir-cleanup
+++ b/cron-jobs/ftpdir-cleanup
@@ -44,7 +44,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})..."
+ error "Missing packages in [%s] (%s)..." "$repo" "$arch"
for missing_pkg in ${missing_pkgs[@]}; do
msg2 "${missing_pkg}"
done
@@ -52,7 +52,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})..."
+ msg "Removing old packages from [%s] (%s)..." "$repo" "$arch"
for old_pkg in ${old_pkgs[@]}; do
msg2 "${old_pkg}"
clean_pkg "${FTP_BASE}/${repo}/os/${arch}/${old_pkg}"
diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs
index 4126c37..e9c5586 100755
--- a/cron-jobs/sourceballs
+++ b/cron-jobs/sourceballs
@@ -103,13 +103,13 @@ 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}"
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}"
done
diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db
index 195d1fc..23af067 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
@@ -24,7 +24,7 @@ script_lock
# run at nice 5. it can churn quite a bit of cpu after all.
renice +5 -p $$ > /dev/null
-echo "$cmd: Updating DB at $(date)" >> "${LOGOUT}"
+echo "%s: Updating DB at %s" "$cmd" "$(date)" >> "${LOGOUT}"
# source our virtualenv if it exists
if [ -f "$ENVPATH" ]; then
diff --git a/db-functions b/db-functions
index f0bf43f..f8e058a 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 ${0##*/} is already locked by $_owner."
+ error "Script %s is already locked by %s." "${0##*/}" "$_owner"
exit 1
else
set_umask
@@ -51,7 +51,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
@@ -71,12 +71,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"
@@ -94,7 +94,7 @@ abort() {
}
die() {
- error "$*"
+ error "$@"
cleanup 1
}
@@ -114,7 +114,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" "$(cat $DBLOCKFILE)"
return 1
fi
@@ -131,8 +131,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 %s seconds..." "$LOCK_DELAY"
else
LOCKS[${#LOCKS[*]}]="$1.$2"
set_umask
@@ -142,14 +142,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
@@ -204,7 +204,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
@@ -217,7 +217,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
@@ -229,7 +229,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
@@ -259,10 +259,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 [ ! -f "${1}.sig" ]; then
- error "Package signature ${1}.sig not found!"
+ error "Package signature %s.sig not found!" "$1"
exit 1
fi
@@ -278,10 +278,10 @@ getpkgfiles() {
for f in ${@}; do
if [ ! -f "${f}" ]; then
- error "Package ${f} not found!"
+ error "Package %s not found!" "$f"
exit 1
elif [ ! -f "${f}.sig" ]; then
- error "Package signature ${f}.sig not found!"
+ error "Package signature %s.sig not found!" "$f"
exit 1
fi
done
@@ -392,7 +392,7 @@ check_pkgrepos() {
#usage: chk_license ${license[@]}"
chk_license() {
local l
- for l in ${@}; do
+ for l in "${@}"; do
in_array ${l} ${ALLOWED_LICENSES[@]} && return 0
done
@@ -428,12 +428,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
}
@@ -459,7 +459,7 @@ 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[@]} \
diff --git a/db-move b/db-move
index ce3fcf9..e41e488 100755
--- a/db-move
+++ b/db-move
@@ -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
diff --git a/db-remove b/db-remove
index 25cb9a7..b1d6409 100755
--- a/db-remove
+++ b/db-remove
@@ -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 78f387f..f6a3d70 100755
--- a/db-repo-add
+++ b/db-repo-add
@@ -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/${tarch}/${pkgfile##*/}" ]]; then
- die "Package file ${pkgfile##*/} not found in ${FTP_BASE}/${repo}/os/${tarch}/"
+ die "Package file %s not found in %s" "${pkgfile##*/}" "${FTP_BASE}/${repo}/os/${tarch}/"
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 2a693f4..2f08ebc 100755
--- a/db-repo-remove
+++ b/db-repo-remove
@@ -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 f473f45..4640b05 100755
--- a/db-update
+++ b/db-update
@@ -4,13 +4,13 @@
. "$(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
if ! staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u)); then
- die "Could not read ${STAGING}"
+ die "Could not read %s" "$STAGING"
fi
repos=()
@@ -30,46 +30,46 @@ 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 ! 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"
+ die "Package %s does not have a valid packager" "$repo/${pkg##*/}"
fi
if ! check_buildinfo "${pkg}"; then
- die "Package ${repo}/${pkg##*/} does not have a .BUILDINFO file"
+ die "Package %s does not have a .BUILDINFO file" "$repo/${pkg##*/}"
fi
if ! check_builddir "${pkg}"; then
- die "Package ${repo}/${pkg##*/} was not built in a chroot"
+ die "Package %s was not built in a chroot" "$repo/${pkg##*/}"
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=()
diff --git a/testing2x b/testing2x
index 369857f..f51c4c0 100755
--- a/testing2x
+++ b/testing2x
@@ -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: %s" "$pkgbase" "${STABLE_REPOS[*]}"
fi
done