diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-12-19 14:40:07 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-12-19 14:40:07 +0100 |
commit | 5c7220a4aa370d1f726eb27d99d8f9294646433d (patch) | |
tree | 699c4f1643fa94c26eb75c683ca995f890108d8d | |
parent | 2b7bb0c6b7aa4f7a43c82db1cf9a18d27600c62e (diff) |
Avoid calls to basename
-rwxr-xr-x | cron-jobs/ftpdir-cleanup | 2 | ||||
-rwxr-xr-x | cron-jobs/integrity-check | 2 | ||||
-rwxr-xr-x | cron-jobs/update-web-db | 2 | ||||
-rw-r--r-- | db-functions | 24 | ||||
-rwxr-xr-x | db-move | 6 | ||||
-rwxr-xr-x | db-remove | 4 | ||||
-rwxr-xr-x | db-repo-add | 2 | ||||
-rwxr-xr-x | db-repo-remove | 2 | ||||
-rwxr-xr-x | db-update | 14 | ||||
-rw-r--r-- | test/lib/common.inc | 8 | ||||
-rwxr-xr-x | test/test.d/db-move.sh | 4 | ||||
-rwxr-xr-x | test/test.d/db-update.sh | 2 | ||||
-rwxr-xr-x | test/test.d/ftpdir-cleanup.sh | 2 | ||||
-rwxr-xr-x | test/test.d/pool-transition.sh | 12 | ||||
-rwxr-xr-x | testing2x | 2 |
15 files changed, 44 insertions, 44 deletions
diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index bb1661a..7839d50 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -16,7 +16,7 @@ clean_pkg() { if [ -e "$pkg.sig" ]; then mv -f "$pkg.sig" "$CLEANUP_DESTDIR" fi - touch "${CLEANUP_DESTDIR}/$(basename ${pkg})" + touch "${CLEANUP_DESTDIR}/${pkg##*/}" fi done fi diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check index d4f9694..044f093 100755 --- a/cron-jobs/integrity-check +++ b/cron-jobs/integrity-check @@ -8,7 +8,7 @@ dirname="$(dirname $0)" script_lock if [ $# -ne 1 ]; then - die "usage: $(basename $0) <mailto>" + die "usage: ${0##*/} <mailto>" fi mailto=$1 diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db index 6ced4c1..b1767ca 100755 --- a/cron-jobs/update-web-db +++ b/cron-jobs/update-web-db @@ -14,7 +14,7 @@ REPOS=('community-testing' 'multilib-testing' 'multilib' 'community' 'extra' 'te LOGOUT="/tmp/archweb_update.log" # figure out what operation to perform -cmd="$(basename $0)" +cmd="${0##*/}" if [[ $cmd != "update-web-db" && $cmd != "update-web-files-db" ]]; then die "Invalid command name '$cmd' specified!" fi diff --git a/db-functions b/db-functions index 7c4a7fe..3100e31 100644 --- a/db-functions +++ b/db-functions @@ -16,7 +16,7 @@ restore_umask () { } # set up general environment -WORKDIR=$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX) +WORKDIR=$(mktemp -d /tmp/${0##*/}.XXXXXXXXXX) LOCKS=() # check if messages are to be printed using color @@ -85,10 +85,10 @@ get_full_version() { } script_lock() { - local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" + local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then local _owner="$(/usr/bin/stat -c %U $LOCKDIR)" - error "Script $(basename $0) is already locked by $_owner." + error "Script ${0##*/} is already locked by $_owner." exit 1 else set_umask @@ -97,9 +97,9 @@ script_lock() { } script_unlock() { - local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" + local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" if [ ! -d "$LOCKDIR" ]; then - warning "Script $(basename $0) was not locked!" + warning "Script ${0##*/} was not locked!" restore_umask return 1 else @@ -123,8 +123,8 @@ cleanup() { repo_unlock $repo $arch fi done - if [ -d "$TMPDIR/.scriptlock.$(basename $0)" ]; then - msg "Removing left over lock from $(basename $0)" + if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then + msg "Removing left over lock from ${0##*/}" script_unlock fi rm -rf "$WORKDIR" @@ -324,7 +324,7 @@ check_pkgfile() { in_array "${pkgarch}" ${ARCHES[@]} 'any' || return 1 - if echo "$(basename ${pkgfile})" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then + if echo "${pkgfile##*/}" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then return 0 else return 1 @@ -418,8 +418,8 @@ check_pkgrepos() { [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1 - [ -f "${FTP_BASE}/${PKGPOOL}/$(basename ${pkgfile})" ] && return 1 - [ -f "${FTP_BASE}/${PKGPOOL}/$(basename ${pkgfile}).sig" ] && return 1 + [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}" ] && return 1 + [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig" ] && return 1 local repo local arch @@ -427,8 +427,8 @@ check_pkgrepos() { for arch in ${ARCHES[@]}; do [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1 - [ -f "${FTP_BASE}/${repo}/os/${arch}/$(basename ${pkgfile})" ] && return 1 - [ -f "${FTP_BASE}/${repo}/os/${arch}/$(basename ${pkgfile}).sig" ] && return 1 + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}" ] && return 1 + [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}.sig" ] && return 1 done done @@ -4,7 +4,7 @@ . "$(dirname $0)/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) <repo-from> <repo-to> <pkgname|pkgbase> ..." + msg "usage: ${0##*/} <repo-from> <repo-to> <pkgname|pkgbase> ..." exit 1 fi @@ -90,12 +90,12 @@ for pkgbase in ${args[@]:2}; do /usr/bin/svn mv -q -r HEAD "${svnrepo_from}/$file" "${svnrepo_to}/" done /usr/bin/svn rm --force -q "${svnrepo_from}" - /usr/bin/svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "$(basename $0): moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${pkgarch})" + /usr/bin/svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "${0##*/}: moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${pkgarch})" for pkgname in ${pkgnames[@]}; do for tarch in ${tarches[@]}; do pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) - pkgfile=$(basename "${pkgpath}") + pkgfile="${pkgpath##*/}" # copy package to pool if needed # TODO: can be removed once every package has been moved to the package pool @@ -4,7 +4,7 @@ . "$(dirname $0)/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) <repo> <arch> <pkgname|pkgbase> ..." + msg "usage: ${0##*/} <repo> <arch> <pkgname|pkgbase> ..." exit 1 fi @@ -37,7 +37,7 @@ for pkgbase in ${pkgbases[@]}; do if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then remove_pkgs=(${remove_pkgs[@]} $(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) /usr/bin/svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" - /usr/bin/svn commit -q "${WORKDIR}/svn/$pkgbase" -m "$(basename $0): $pkgbase removed by $(id -un)" + /usr/bin/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" diff --git a/db-repo-add b/db-repo-add index b83fb77..99bb4b5 100755 --- a/db-repo-add +++ b/db-repo-add @@ -4,7 +4,7 @@ . "$(dirname $0)/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) <repo> <arch> <pkgfile> ..." + msg "usage: ${0##*/} <repo> <arch> <pkgfile> ..." exit 1 fi diff --git a/db-repo-remove b/db-repo-remove index 4f04ed1..43be772 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -4,7 +4,7 @@ . "$(dirname $0)/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) <repo> <arch> <pkgname> ..." + msg "usage: ${0##*/} <repo> <arch> <pkgname> ..." exit 1 fi @@ -4,7 +4,7 @@ . "$(dirname $0)/config" if [ $# -ge 1 ]; then - warning "Calling $(basename $0) with a specific repository is no longer supported" + warning "Calling ${0##*/} with a specific repository is no longer supported" exit 1 fi @@ -30,19 +30,19 @@ for repo in ${repos[@]}; do if [ $? -eq 0 ]; then for pkg in ${pkgs[@]}; do if [ -h "${pkg}" ]; then - die "Package ${repo}/$(basename ${pkg}) is a symbolic link" + die "Package ${repo}/${pkg##*/} is a symbolic link" fi if ! check_pkgfile "${pkg}"; then - die "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" + die "Package ${repo}/${pkg##*/} is not consistent with its meta data" fi if ${REQUIRE_SIGNATURE} && ! check_pkgsig "${pkg}.sig"; then - die "Package ${repo}/$(basename ${pkg}) does not have a valid signature" + die "Package ${repo}/${pkg##*/} does not have a valid signature" fi if ! check_pkgsvn "${pkg}" "${repo}"; then - die "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" + die "Package ${repo}/${pkg##*/} is not consistent with svn repository" fi if ! check_pkgrepos "${pkg}"; then - die "Package ${repo}/$(basename ${pkg}) already exists in another repository" + die "Package ${repo}/${pkg##*/} already exists in another repository" fi done if ! check_splitpkgs ${repo} ${pkgs[@]}; then @@ -60,7 +60,7 @@ for repo in ${repos[@]}; do add_pkgs=() arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXT} 2>/dev/null)) for pkg in ${arch_pkgs[@]} ${any_pkgs[@]}; do - pkgfile="$(basename ${pkg})" + pkgfile="${pkg##*/}" msg2 "${pkgfile} (${pkgarch})" # any packages might have been moved by the previous run if [ -f "${pkg}" ]; then diff --git a/test/lib/common.inc b/test/lib/common.inc index e0e7048..3eab68e 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -26,7 +26,7 @@ oneTimeSetUp() { local pkgarch local pkgversion local build - pkgdir="$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX)" + pkgdir="$(mktemp -d /tmp/${0##*/}.XXXXXXXXXX)" cp -Lr $(dirname ${BASH_SOURCE[0]})/../packages/* "${pkgdir}" msg 'Building packages...' for d in "${pkgdir}"/*; do @@ -52,7 +52,7 @@ oneTimeSetUp() { fi for a in ${pkgarch[@]}; do for p in ${pkgname[@]}; do - cp ${p}-${pkgversion}-${a}${PKGEXT} $(dirname ${BASH_SOURCE[0]})/../packages/$(basename ${d}) + cp ${p}-${pkgversion}-${a}${PKGEXT} $(dirname ${BASH_SOURCE[0]})/../packages/${d##*/} done done fi @@ -71,7 +71,7 @@ setUp() { local a [ -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" ] && die "$(dirname ${BASH_SOURCE[0]})/../../config.local exists" - TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" + TMP="$(mktemp -d /dev/shm/${0##*/}.XXXXXXXXXX)" #msg "Using ${TMP}" PKGREPOS=('core' 'extra' 'testing') @@ -92,7 +92,7 @@ setUp() { svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy" for p in "${pkgdir}"/*; do - pkg=$(basename $p) + pkg=${p##*/} mkdir -p "${TMP}/svn-packages-copy/${pkg}"/{trunk,repos} cp "${p}"/* "${TMP}/svn-packages-copy"/${pkg}/trunk/ svn add -q "${TMP}/svn-packages-copy"/${pkg} diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 9d7c1f6..890ffc4 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -107,12 +107,12 @@ testMoveSplitPackages() { for arch in ${arches[@]}; do for pkg in "${pkgdir}/pkg-split-a"/*-${arch}${PKGEXT}; do - checkPackage extra $(basename ${pkg}) ${arch} + checkPackage extra ${pkg##*/} ${arch} done done for arch in ${arches[@]}; do for pkg in "${pkgdir}/pkg-split-b"/*-${arch}${PKGEXT}; do - checkPackage testing $(basename ${pkg}) ${arch} + checkPackage testing ${pkg##*/} ${arch} done done diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index e38c328..2021993 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -69,7 +69,7 @@ testAddSplitPackages() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgbase}"/*-${arch}${PKGEXT}; do - checkPackage extra $(basename ${pkg}) ${arch} + checkPackage extra ${pkg##*/} ${arch} done done done diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 20026b4..bfea7ea 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -113,7 +113,7 @@ testCleanupSplitPackages() { done for pkg in "${pkgdir}/${pkgs[1]}"/*-${arch}${PKGEXT}; do - checkPackage extra $(basename ${pkg}) ${arch} + checkPackage extra ${pkg##*/} ${arch} done done } diff --git a/test/test.d/pool-transition.sh b/test/test.d/pool-transition.sh index 5873f00..4912968 100755 --- a/test/test.d/pool-transition.sh +++ b/test/test.d/pool-transition.sh @@ -23,7 +23,7 @@ testMovePackagesWithoutPool() { for arch in ${arches[@]}; do for old in 0 2; do for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}${PKGEXT}; do - pkg=$(basename $pkg) + pkg=${pkg##*/} mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done done @@ -38,7 +38,7 @@ testMovePackagesWithoutPool() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgbase}"/*-${arch}${PKGEXT}; do - checkPackage extra $(basename ${pkg}) ${arch} + checkPackage extra ${pkg##*/} ${arch} done checkRemovedPackage testing ${pkgbase} ${arch} done @@ -95,7 +95,7 @@ testMoveAnyPackagesWithoutPool() { # transform a package to old style layout for pkg in "${pkgdir}/${pkgs[0]}"/*-any${PKGEXT}; do - pkg=$(basename $pkg) + pkg=${pkg##*/} mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" for arch in i686 x86_64; do ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" @@ -110,13 +110,13 @@ testMoveAnyPackagesWithoutPool() { for pkgbase in ${pkgs[@]}; do for pkg in "${pkgdir}/${pkgbase}"/*-any${PKGEXT}; do - checkAnyPackage extra $(basename ${pkg}) + checkAnyPackage extra ${pkg##*/} done checkRemovedAnyPackage testing ${pkgbase} done for pkg in "${pkgdir}/${pkgs[0]}"/*-any${PKGEXT}; do - pkg=$(basename $pkg) + pkg=${pkg##*/} for arch in any i686 x86_64; do [ -f "${FTP_BASE}/testing/os/${arch}/${pkg}" ] && fail "testing/os/${arch}/${pkg} found" done @@ -132,7 +132,7 @@ testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { # transform a package to old style layout for pkg in "${pkgdir}/pkg-any-a"/*-any${PKGEXT}; do - pkg=$(basename $pkg) + pkg=${pkg##*/} mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" for arch in i686 x86_64; do ln -sf "../any/${pkg}" "${FTP_BASE}/extra/os/${arch}/${pkg}" @@ -4,7 +4,7 @@ . "$(dirname $0)/config" if [ $# -lt 1 ]; then - msg "usage: $(basename $0) <pkgname|pkgbase> ..." + msg "usage: ${0##*/} <pkgname|pkgbase> ..." exit 1 fi |