From 43f8af33f08924092826e2094d15be704e842f3a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 00:32:24 -0400 Subject: more quoting and printf fixes --- db-functions | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'db-functions') 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}" -- cgit v1.2.3-2-g168b