[arch-projects] [devtools] [PATCH 9/9] Replace multiple uses of string interpolation with printf-type arguments.

Luke Shumaker LukeShu at sbcglobal.net
Sat May 10 22:22:11 EDT 2014


In some places this wasn't possible until now, brecause `stat_busy`,
`lock`, and `slock` didn't accept printf-style arguments.
---
 arch-nspawn.in   |  2 +-
 archbuild.in     |  8 ++++----
 archrelease.in   |  2 +-
 checkpkg.in      |  4 ++--
 crossrepomove.in |  8 ++++----
 lddd.in          |  4 ++--
 makechrootpkg.in |  6 +++---
 mkarchroot.in    |  2 +-
 rebuildpkgs.in   | 14 +++++++-------
 9 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/arch-nspawn.in b/arch-nspawn.in
index df3a08f..ca7edbe 100644
--- a/arch-nspawn.in
+++ b/arch-nspawn.in
@@ -32,7 +32,7 @@ while getopts 'hC:M:c:' arg; do
 		M) makepkg_conf="$OPTARG" ;;
 		c) cache_dir="$OPTARG" ;;
 		h|?) usage ;;
-		*) error "invalid argument '$arg'"; usage ;;
+		*) error "invalid argument '%s'" "$arg"; usage ;;
 	esac
 done
 shift $(($OPTIND - 1))
diff --git a/archbuild.in b/archbuild.in
index 618d0f0..64e0904 100644
--- a/archbuild.in
+++ b/archbuild.in
@@ -43,13 +43,13 @@ makechrootpkg_args+=("${@:$OPTIND}")
 check_root "$0" "$@"
 
 if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
-	msg "Creating chroot for [${repo}] (${arch})..."
+	msg "Creating chroot for [%s] (%s)..." "${repo}" "${arch}"
 
 	for copy in "${chroots}/${repo}-${arch}"/*; do
 		[[ -d $copy ]] || continue
-		msg2 "Deleting chroot copy '$(basename "${copy}")'..."
+		msg2 "Deleting chroot copy '%s'..." "$(basename "${copy}")"
 
-		lock 9 "$copy.lock" "Locking chroot copy '$copy'"
+		lock 9 "$copy.lock" "Locking chroot copy '%s'" "$copy"
 
 		if [[ "$(stat -f -c %T "${copy}")" == btrfs ]]; then
 			{ type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null
@@ -74,5 +74,5 @@ else
                 pacman -Syu --noconfirm || abort
 fi
 
-msg "Building in chroot for [${repo}] (${arch})..."
+msg "Building in chroot for [%s] (%s)..." "${repo}" "${arch}"
 exec makechrootpkg -r "${chroots}/${repo}-${arch}" "${makechrootpkg_args[@]}"
diff --git a/archrelease.in b/archrelease.in
index 6f52dbc..4ac55db 100644
--- a/archrelease.in
+++ b/archrelease.in
@@ -58,7 +58,7 @@ done
 known_files=("${known_files[@]/%/@}")
 
 for tag in "$@"; do
-	stat_busy "Copying ${trunk} to ${tag}"
+	stat_busy "Copying %s to %s" "${trunk}" "${tag}"
 
 	if [[ -d repos/$tag ]]; then
 		declare -a trash
diff --git a/checkpkg.in b/checkpkg.in
index ccbbecd..81e7184 100644
--- a/checkpkg.in
+++ b/checkpkg.in
@@ -70,8 +70,8 @@ for _pkgname in "${pkgname[@]}"; do
 			echo "${i}: " "$(objdump -p "$TEMPDIR/$i" | grep SONAME)"
 		done
 	else
-		msg "No soname differences for $_pkgname."
+		msg "No soname differences for %s." "$_pkgname"
 	fi
 done
 
-msg "Files saved to $TEMPDIR"
+msg "Files saved to %s" "$TEMPDIR"
diff --git a/crossrepomove.in b/crossrepomove.in
index 912504f..ac08c67 100644
--- a/crossrepomove.in
+++ b/crossrepomove.in
@@ -39,13 +39,13 @@ setup_workdir
 
 pushd $WORKDIR >/dev/null
 
-msg "Downloading sources for ${pkgbase}"
+msg "Downloading sources for %s" "${pkgbase}"
 svn -q checkout -N "${target_svn}" target_checkout
 mkdir -p "target_checkout/${pkgbase}/repos"
 svn -q export "${source_svn}/${pkgbase}/trunk" "target_checkout/${pkgbase}/trunk" || die
 . "target_checkout/${pkgbase}/trunk/PKGBUILD"
 
-msg "Downloading packages for ${pkgbase}"
+msg "Downloading packages for %s" "${pkgbase}"
 for _arch in ${arch[@]}; do
 	if [[ "${_arch[*]}" == 'any' ]]; then
 		repo_arch='x86_64'
@@ -59,7 +59,7 @@ for _arch in ${arch[@]}; do
 	done
 done
 
-msg "Adding ${pkgbase} to ${target_repo}"
+msg "Adding %s to %s" "${pkgbase}" "${target_repo}"
 svn -q add "target_checkout/${pkgbase}"
 svn -q propset svn:keywords 'Id' "target_checkout/${pkgbase}/trunk/PKGBUILD"
 svn -q commit -m"${scriptname}: Moving ${pkgbase} from ${source_repo} to ${target_repo}" target_checkout
@@ -69,7 +69,7 @@ popd >/dev/null
 
 ssh "${server}" "${target_dbscripts}/db-update" || die
 
-msg "Removing ${pkgbase} from ${source_repo}"
+msg "Removing %s from %s" "${pkgbase}" "${source_repo}"
 for _arch in ${arch[@]}; do
 	ssh "${server}" "${source_dbscripts}/db-remove ${source_repo} ${_arch} ${pkgbase}"
 done
diff --git a/lddd.in b/lddd.in
index 43aa8c1..f111d67 100644
--- a/lddd.in
+++ b/lddd.in
@@ -16,7 +16,7 @@ TEMPDIR=$(mktemp -d --tmpdir lddd-script.XXXX)
 msg 'Go out and drink some tea, this will take a while :) ...'
 #  Check ELF binaries in the PATH and specified dir trees.
 for tree in $PATH $libdirs $extras; do
-	msg2 "DIR $tree"
+	msg2 "DIR %s" "$tree"
 
 	#  Get list of files in tree.
 	files=$(find $tree -type f ! -name '*.a' ! -name '*.la' ! -name '*.py*' ! -name '*.txt' ! -name '*.h' ! -name '*.ttf' ! \
@@ -45,4 +45,4 @@ done
 # clean list
 sort -u $TEMPDIR/pacman.txt >> $TEMPDIR/possible-rebuilds.txt
 
-msg "Files saved to $TEMPDIR"
+msg "Files saved to %s" "$TEMPDIR"
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 731b560..6a99408 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -133,14 +133,14 @@ load_vars() {
 
 create_chroot() {
 	# Lock the chroot we want to use. We'll keep this lock until we exit.
-	lock 9 "$copydir.lock" "Locking chroot copy [$copy]"
+	lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
 
 	if [[ ! -d $copydir ]] || $clean_first; then
 		# Get a read lock on the root chroot to make
 		# sure we don't clone a half-updated chroot
 		slock 8 "$chrootdir/root.lock" "Locking clean chroot"
 
-		stat_busy "Creating clean working copy [$copy]"
+		stat_busy "Creating clean working copy [%s]" "$copy"
 		if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
 			if [[ -d $copydir ]]; then
 				btrfs subvolume delete "$copydir" >/dev/null ||
@@ -163,7 +163,7 @@ create_chroot() {
 }
 
 clean_temporary() {
-	stat_busy "Removing temporary copy [$copy]"
+	stat_busy "Removing temporary copy [%s]" "$copy"
 	if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
 		btrfs subvolume delete "$copydir" >/dev/null ||
 			die "Unable to delete subvolume %s" "$copydir"
diff --git a/mkarchroot.in b/mkarchroot.in
index 5f3d6fe..09ba64f 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -30,7 +30,7 @@ while getopts 'hC:M:c:' arg; do
 		M) makepkg_conf="$OPTARG" ;;
 		c) cache_dir="$OPTARG" ;;
 		h|?) usage ;;
-		*) error "invalid argument '$arg'"; usage ;;
+		*) error "invalid argument '%s'" "$arg"; usage ;;
 	esac
 done
 shift $(($OPTIND - 1))
diff --git a/rebuildpkgs.in b/rebuildpkgs.in
index 2f71c40..1a02954 100644
--- a/rebuildpkgs.in
+++ b/rebuildpkgs.in
@@ -49,7 +49,7 @@ pkgs="$@"
 
 SVNPATH='svn+ssh://nymeria.archlinux.org/srv/repos/svn-packages/svn'
 
-msg "Work will be done in $(pwd)/rebuilds"
+msg "Work will be done in %s" "$(pwd)/rebuilds"
 
 REBUILD_ROOT="$(pwd)/rebuilds"
 mkdir -p "$REBUILD_ROOT"
@@ -61,11 +61,11 @@ FAILED=""
 for pkg in $pkgs; do
 	cd "$REBUILD_ROOT/svn-packages"
 
-	msg2 "Building '$pkg'"
+	msg2 "Building '%s'" "$pkg"
 	/usr/bin/svn update "$pkg"
 	if [[ ! -d "$pkg/trunk" ]]; then
 		FAILED="$FAILED $pkg"
-		warning "$pkg does not exist in SVN"
+		warning "%s does not exist in SVN" "$pkg"
 		continue
 	fi
 	cd "$pkg/trunk/"
@@ -74,14 +74,14 @@ for pkg in $pkgs; do
 
 	if ! sudo makechrootpkg -u -d -r "$chrootdir" -- --noconfirm; then
 		FAILED="$FAILED $pkg"
-		error "$pkg Failed!"
+		error "%s Failed!" "$pkg"
 	else
 		pkgfile=$(pkg_from_pkgbuild)
 		if [[ -e $pkgfile ]]; then
-			msg2 "$pkg Complete"
+			msg2 "%s Complete" "$pkg"
 		else
 			FAILED="$FAILED $pkg"
-			error "$pkg Failed, no package built!"
+			error "%s Failed, no package built!" "$pkg"
 		fi
 	fi
 done
@@ -90,7 +90,7 @@ cd "$REBUILD_ROOT"
 if [[ -n $FAILED ]]; then
 	msg 'Packages failed:'
 	for pkg in $FAILED; do
-		msg2 "$pkg"
+		msg2 "%s" "$pkg"
 	done
 fi
 
-- 
1.9.2



More information about the arch-projects mailing list