Skip to content

Commit

Permalink
Update messages to make fuller use of printf formatters
Browse files Browse the repository at this point in the history
These are things that were (IMO) missed in 5afac1e.  I found them using:

    git grep -E '(plain|msg|msg2|warning|error|die) "[^"]*\$'

I went a little above-and-beyond for escaping strings for the error
messages in db-functions' arch_repo_add and arch_repo_remove.  The
code should explain itself, but I wanted to point it out, as it's more than
the usual "slap %s in there, and move the ${...} to the right".
  • Loading branch information
LukeShu authored and eli-schwartz committed Mar 16, 2018
1 parent f22f155 commit 33aae31
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions cron-jobs/ftpdir-cleanup
Expand Up @@ -50,15 +50,15 @@ for repo in ${PKGREPOS[@]}; do
if (( ${#missing_pkgs[@]} >= 1 )); then
error "Missing packages in [%s] (%s)..." "$repo" "$arch"
for missing_pkg in ${missing_pkgs[@]}; do
msg2 "${missing_pkg}"
msg2 '%s' "${missing_pkg}"
done
fi

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
msg2 "${old_pkg}"
msg2 '%s' "${old_pkg}"
clean_pkg "${FTP_BASE}/${repo}/os/${arch}/${old_pkg}"
done
fi
Expand All @@ -76,7 +76,7 @@ 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
msg2 "${old_pkg}"
msg2 '%s' "${old_pkg}"
clean_pkg "$FTP_BASE/${PKGPOOL}/${old_pkg}"
done
fi
Expand All @@ -91,7 +91,7 @@ done
if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old packages from the cleanup directory..."
for old_pkg in ${old_pkgs[@]}; do
msg2 "${old_pkg}"
msg2 '%s' "${old_pkg}"
if ! ${CLEANUP_DRYRUN}; then
rm -f "${CLEANUP_DESTDIR}/${old_pkg}"
rm -f "${CLEANUP_DESTDIR}/${old_pkg}.sig"
Expand Down
2 changes: 1 addition & 1 deletion cron-jobs/integrity-check
Expand Up @@ -8,7 +8,7 @@ dirname="$(dirname $0)"
script_lock

if (( $# != 1 )); then
die "usage: ${0##*/} <mailto>"
die "usage: %s <mailto>" "${0##*/}"
fi
mailto=$1

Expand Down
8 changes: 4 additions & 4 deletions cron-jobs/sourceballs
Expand Up @@ -109,13 +109,13 @@ for repo in ${PKGREPOS[@]}; do
if [ ${#newpkgs[@]} -ge 1 ]; then
msg "Adding source packages for [%s]..." "$repo"
for new_pkg in ${newpkgs[@]}; do
msg2 "${new_pkg}"
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
msg2 "${failed_pkg}"
msg2 '%s' "${failed_pkg}"
done
fi
done
Expand All @@ -129,7 +129,7 @@ if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old source packages..."
${SOURCE_CLEANUP_DRYRUN} && warning 'dry run mode is active'
for old_pkg in ${old_pkgs[@]}; do
msg2 "${old_pkg}"
msg2 '%s' "${old_pkg}"
if ! ${SOURCE_CLEANUP_DRYRUN}; then
mv_acl "$FTP_BASE/${SRCPOOL}/${old_pkg}" "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}"
touch "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}"
Expand All @@ -148,7 +148,7 @@ done
if (( ${#old_pkgs[@]} >= 1 )); then
msg "Removing old source packages from the cleanup directory..."
for old_pkg in ${old_pkgs[@]}; do
msg2 "${old_pkg}"
msg2 '%s' "${old_pkg}"
${SOURCE_CLEANUP_DRYRUN} || rm -f "${SOURCE_CLEANUP_DESTDIR}/${old_pkg}"
done
fi
Expand Down
2 changes: 1 addition & 1 deletion db-functions
Expand Up @@ -457,7 +457,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[@]} \
|| error "repo-${action} ${dbfile} ${pkgs[@]}"
|| error "repo-${action} %s %s " "${dbfile@Q}" "${pkgs[@]@Q}"
set_repo_permission "${repo}" "${arch}"
popd >/dev/null

Expand Down
4 changes: 2 additions & 2 deletions db-move
Expand Up @@ -4,7 +4,7 @@
. "$(dirname $0)/db-functions"

if (( $# < 3 )); then
msg "usage: ${0##*/} <repo-from> <repo-to> <pkgname|pkgbase> ..."
msg "usage: %s <repo-from> <repo-to> <pkgname|pkgbase> ..." "${0##*/}"
exit 1
fi

Expand Down Expand Up @@ -74,7 +74,7 @@ for pkgbase in ${args[@]:2}; do
else
tarches=("${pkgarch}")
fi
msg2 "${pkgbase} ($(echo ${tarches[@]}))"
msg2 "%s (%s)" "$pkgbase" "${tarches[*]}"
pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]}))
pkgver=$(. "${svnrepo_from}/PKGBUILD"; get_full_version)

Expand Down
2 changes: 1 addition & 1 deletion db-remove
Expand Up @@ -4,7 +4,7 @@
. "$(dirname $0)/db-functions"

if (( $# < 3 )); then
msg "usage: ${0##*/} <repo> <arch> <pkgname|pkgbase> ..."
msg "usage: %s <repo> <arch> <pkgname|pkgbase> ..." "${0##*/}"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion db-repo-add
Expand Up @@ -4,7 +4,7 @@
. "$(dirname $0)/db-functions"

if (( $# < 3 )); then
msg "usage: ${0##*/} <repo> <arch> <pkgfile> ..."
msg "usage: %s <repo> <arch> <pkgfile> ..." "${0##*/}"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion db-repo-remove
Expand Up @@ -4,7 +4,7 @@
. "$(dirname $0)/db-functions"

if (( $# < 3 )); then
msg "usage: ${0##*/} <repo> <arch> <pkgname> ..."
msg "usage: %s <repo> <arch> <pkgname> ..." "${0##*/}"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion db-update
Expand Up @@ -78,7 +78,7 @@ for repo in ${repos[@]}; do
arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXTS} 2>/dev/null))
for pkg in ${arch_pkgs[@]} ${any_pkgs[@]}; do
pkgfile="${pkg##*/}"
msg2 "${pkgfile} (${pkgarch})"
msg2 '%s (%s)' "$pkgfile" "$pkgarch"
# any packages might have been moved by the previous run
if [[ -f ${pkg} ]]; then
mv "${pkg}" "$FTP_BASE/${PKGPOOL}"
Expand Down
2 changes: 1 addition & 1 deletion testing2x
Expand Up @@ -4,7 +4,7 @@
. "$(dirname $0)/db-functions"

if (( $# < 1 )); then
msg "usage: ${0##*/} <pkgname|pkgbase> ..."
msg "usage: %s <pkgname|pkgbase> ..." "${0##*/}"
exit 1
fi

Expand Down

0 comments on commit 33aae31

Please sign in to comment.