summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-08 21:04:43 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-08 21:19:01 -0500
commitb6e8ebd66d22abf5439485985a7851e768c71e8a (patch)
treeeec7fafd8aa2285dd3b706bb1e433a0ed10c87e5
parent1d08899c3ac82047fe614a7694e5a7235f808cfd (diff)
Be very careful about using $0.
-rwxr-xr-xany-to-ours4
-rwxr-xr-xcreate-repo8
-rwxr-xr-xcreaterepos4
-rwxr-xr-xcron-jobs/ftpdir-cleanup4
-rwxr-xr-xcron-jobs/integrity-check4
-rwxr-xr-xcron-jobs/repo-sanity-check4
-rwxr-xr-xcron-jobs/sourceballs2
-rwxr-xr-xcron-jobs/sourceballs22
-rwxr-xr-xcron-jobs/update-abs-tarballs2
-rwxr-xr-xcron-jobs/update-web-db6
-rwxr-xr-xdb-check-nonfree6
-rwxr-xr-xdb-cleanup4
-rw-r--r--db-functions14
-rwxr-xr-xdb-list-unsigned-packages8
-rwxr-xr-xdb-move6
-rwxr-xr-xdb-remove6
-rwxr-xr-xdb-repo-add6
-rwxr-xr-xdb-repo-remove6
-rwxr-xr-xdb-sync16
-rwxr-xr-xdb-update6
-rwxr-xr-xget-repos6
-rwxr-xr-xmigrate-repo2
-rwxr-xr-xmkrepo4
-rwxr-xr-xrepo-restore-to-normal4
-rwxr-xr-xtesting2x8
-rwxr-xr-xyf-update12
26 files changed, 77 insertions, 77 deletions
diff --git a/any-to-ours b/any-to-ours
index b927b82..a1697c7 100755
--- a/any-to-ours
+++ b/any-to-ours
@@ -7,8 +7,8 @@ trap_exit() {
exit 1
}
-source $(dirname $0)/config
-source $(dirname $0)/libremessages
+source "$(dirname "$(readlink -e "$0")")/config"
+source "$(dirname "$(readlink -e "$0")")/libremessages"
# From makepkg
set -E
diff --git a/create-repo b/create-repo
index 58842c3..24b890d 100755
--- a/create-repo
+++ b/create-repo
@@ -1,11 +1,11 @@
#!/bin/bash
# Creates repository structure
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
if [ $# -eq 0 ]; then
- msg "Usage: $0 repo1 [repo2 ... repoX]"
+ msg "Usage: ${0##*/} repo1 [repo2 ... repoX]"
exit 1
fi
@@ -21,4 +21,4 @@ for _repo in $@; do
done
done
-msg "Don't forget to add them to the PKGREPOS array on $(dirname $0)/config"
+msg "Don't forget to add them to the PKGREPOS array on %s/config" "$(dirname "$(readlink -e "$0")")"
diff --git a/createrepos b/createrepos
index 1840c83..a8f93e8 100755
--- a/createrepos
+++ b/createrepos
@@ -1,8 +1,8 @@
#!/bin/bash
# Creates the repo structure defined in config
-source $(dirname $0)/config
+source "$(dirname "$(readlink -e "$0")")/config"
mkdir -p -- "${FTP_BASE}"/{"${PKGPOOL}","${SRCPOOL}"} "${ARCH_BASE}" "${CLEANUP_DESTDIR}" "${SOURCE_CLEANUP_DESTDIR}" "${STAGING}"
-$(dirname $0)/create-repo "${PKGREPOS[@]}"
+"$(dirname "$(readlink -e "$0")")/create-repo" "${PKGREPOS[@]}"
diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
index 83e6e17..8d691b5 100755
--- a/cron-jobs/ftpdir-cleanup
+++ b/cron-jobs/ftpdir-cleanup
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname $0)/../db-functions"
-. "$(dirname $0)/../config"
+. "$(dirname "$(readlink -e "$0")")/../db-functions"
+. "$(dirname "$(readlink -e "$0")")/../config"
clean_pkg() {
local pkg
diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check
index d4f9694..05a56a5 100755
--- a/cron-jobs/integrity-check
+++ b/cron-jobs/integrity-check
@@ -1,6 +1,6 @@
#!/bin/bash
-dirname="$(dirname $0)"
+dirname="$(dirname "$(readlink -e "$0")")"
. "${dirname}/../db-functions"
. "${dirname}/../config"
@@ -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/repo-sanity-check b/cron-jobs/repo-sanity-check
index 1ba90a6..2aa7892 100755
--- a/cron-jobs/repo-sanity-check
+++ b/cron-jobs/repo-sanity-check
@@ -1,8 +1,8 @@
#!/bin/bash
# Solves issue165
-. "$(dirname $0)/../db-functions"
-. "$(dirname $0)/../config"
+. "$(dirname "$(readlink -e "$0")")/../db-functions"
+. "$(dirname "$(readlink -e "$0")")/../config"
# Traverse all repos
for _repo in ${PKGREPOS[@]}; do
diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs
index ee074bd..73d8432 100755
--- a/cron-jobs/sourceballs
+++ b/cron-jobs/sourceballs
@@ -1,6 +1,6 @@
#!/bin/bash
-dirname="$(dirname $(readlink -e $0))"
+dirname="$(dirname "$(readlink -e "$0")")"
. "${dirname}/../db-functions"
. "${dirname}/../config"
pushd "${WORKDIR}" >/dev/null
diff --git a/cron-jobs/sourceballs2 b/cron-jobs/sourceballs2
index 5644268..eb46579 100755
--- a/cron-jobs/sourceballs2
+++ b/cron-jobs/sourceballs2
@@ -4,7 +4,7 @@
# Makepkg --allsource every package
# Remove the old sourceballs
-dirname="$(dirname $(readlink -e $0))"
+dirname="$(dirname "$(readlink -e "$0")")"
. "${dirname}/../db-functions"
. "${dirname}/../config"
. "${MAKEPKGCONF}"
diff --git a/cron-jobs/update-abs-tarballs b/cron-jobs/update-abs-tarballs
index 824ac34..901cc4b 100755
--- a/cron-jobs/update-abs-tarballs
+++ b/cron-jobs/update-abs-tarballs
@@ -1,6 +1,6 @@
#!/bin/bash
-. "$(dirname $0)/../config"
+. "$(dirname "$(readlink -e "$0")")/../config"
rsync -av --exclude=staging/ parabolagnulinux.org::abstar/ ${FTP_BASE}/
diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db
index 6ced4c1..825eea6 100755
--- a/cron-jobs/update-web-db
+++ b/cron-jobs/update-web-db
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname $0)/../db-functions"
-. "$(dirname $0)/../config"
+. "$(dirname "$(readlink -e "$0")")/../db-functions"
+. "$(dirname "$(readlink -e "$0")")/../config"
# setup paths
SPATH="/srv/http/archweb"
@@ -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-check-nonfree b/db-check-nonfree
index ecad3b9..661daa6 100755
--- a/db-check-nonfree
+++ b/db-check-nonfree
@@ -1,10 +1,10 @@
#!/bin/bash
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
if [ $# -ge 1 ]; then
- warning "Calling $(basename $0) with a specific repository is not supported"
+ warning "Calling ${0##*/} with a specific repository is not supported"
exit 1
fi
diff --git a/db-cleanup b/db-cleanup
index abad390..57ef36e 100755
--- a/db-cleanup
+++ b/db-cleanup
@@ -15,8 +15,8 @@ trap_exit() {
exit 1
}
-source $(dirname $0)/config
-source $(dirname $0)/libremessages
+source "$(dirname "$(readlink -e "$0")")/config"
+source "$(dirname "$(readlink -e "$0")")/libremessages"
# From makepkg
set -E
diff --git a/db-functions b/db-functions
index 59e9c29..26b23e4 100644
--- a/db-functions
+++ b/db-functions
@@ -16,7 +16,7 @@ restore_umask () {
}
# set up general environment
-WORKDIR=$(mktemp -dt "$(basename $0).XXXXXXXXXX")
+WORKDIR=$(mktemp -dt "${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"
diff --git a/db-list-unsigned-packages b/db-list-unsigned-packages
index 3b5a5bd..985d1c0 100755
--- a/db-list-unsigned-packages
+++ b/db-list-unsigned-packages
@@ -20,11 +20,11 @@ set -e
# unsigned packages available for architecture $1 and specified for
# architecture $2 (usually $1 or any, default is to list all).
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
if [ $# -lt 1 ]; then
- msg "usage: $(basename $0) <architecture>"
+ msg "usage: ${0##*/} <architecture>"
exit 1
fi
@@ -34,5 +34,5 @@ shift
for repo in ${PKGREPOS[@]}
do
db="${FTP_BASE}/${repo}/os/${arch}/${repo}.db"
- [ -f "$db" ] && "$(dirname $0)/db-list-unsigned-packages.py" "$repo" "$@" < "$db"
+ [ -f "$db" ] && "$(dirname "$(readlink -e "$0")")/db-list-unsigned-packages.py" "$repo" "$@" < "$db"
done
diff --git a/db-move b/db-move
index 69f24ac..a3f1532 100755
--- a/db-move
+++ b/db-move
@@ -1,10 +1,10 @@
#!/bin/bash
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$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
diff --git a/db-remove b/db-remove
index 255aa32..4e45881 100755
--- a/db-remove
+++ b/db-remove
@@ -1,10 +1,10 @@
#!/bin/bash
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
if [ $# -lt 3 ]; then
- msg "usage: $(basename $0) <repo> <arch> <pkgname|pkgbase> ..."
+ msg "usage: ${0##*/} <repo> <arch> <pkgname|pkgbase> ..."
exit 1
fi
diff --git a/db-repo-add b/db-repo-add
index b83fb77..2b7894a 100755
--- a/db-repo-add
+++ b/db-repo-add
@@ -1,10 +1,10 @@
#!/bin/bash
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$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..09e34da 100755
--- a/db-repo-remove
+++ b/db-repo-remove
@@ -1,10 +1,10 @@
#!/bin/bash
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
if [ $# -lt 3 ]; then
- msg "usage: $(basename $0) <repo> <arch> <pkgname> ..."
+ msg "usage: ${0##*/} <repo> <arch> <pkgname> ..."
exit 1
fi
diff --git a/db-sync b/db-sync
index e8481d6..c4d495e 100755
--- a/db-sync
+++ b/db-sync
@@ -21,7 +21,7 @@ ${VERBOSE} && extra="-v"
# Returns contents of a repo
get_repos() {
- mkdir -p ${TMPDIR}/$0.$$.cache
+ mkdir -p ${TMPDIR}/${0##*/}.$$.cache
# Exclude everything but db files
rsync ${extra} -mrtlH --no-p --include="*/" \
--include="*.db" \
@@ -30,7 +30,7 @@ get_repos() {
--include="*${FILESEXT}" \
--exclude="*" \
--delete-after \
- rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/$0.$$.cache
+ rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/${0##*/}.$$.cache
}
get_repo_content() {
@@ -48,7 +48,7 @@ get_blacklist() {
# repo
# arch
get_repo_file() {
- echo "${TMPDIR}/$0.$$.cache/${1}/os/${2}/${1}"
+ echo "${TMPDIR}/${0##*/}.$$.cache/${1}/os/${2}/${1}"
}
# Process the databases and get the libre packages
@@ -118,7 +118,7 @@ init() {
rsync ${extra} -rtlH \
--delay-updates \
--safe-links \
- ${TMPDIR}/$0.$$.cache/${_repo}/os/${_arch}/ \
+ ${TMPDIR}/${0##*/}.$$.cache/${_repo}/os/${_arch}/ \
${FTP_BASE}/${_repo}/os/${_arch}/
# Cleanup
@@ -176,9 +176,9 @@ trap_exit() {
}
-source $(dirname $0)/config
-source $(dirname $0)/local_config
-source $(dirname $0)/libremessages
+source "$(dirname "$(readlink -e "$0")")/config"
+source "$(dirname "$(readlink -e "$0")")/local_config"
+source "$(dirname "$(readlink -e "$0")")/libremessages"
# From makepkg
set -E
@@ -189,4 +189,4 @@ trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
init
-rm -r ${TMPDIR}/$0.$$.cache
+rm -r ${TMPDIR}/${0##*/}.$$.cache
diff --git a/db-update b/db-update
index cdde63b..86faec3 100755
--- a/db-update
+++ b/db-update
@@ -1,10 +1,10 @@
#!/bin/bash
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$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
diff --git a/get-repos b/get-repos
index 92db9a2..a477cf2 100755
--- a/get-repos
+++ b/get-repos
@@ -9,8 +9,8 @@ trap_exit() {
exit 1
}
-source $(dirname $0)/config
-source $(dirname $0)/libremessages
+source "$(dirname "$(readlink -e "$0")")/config"
+source "$(dirname "$(readlink -e "$0")")/libremessages"
# From makepkg
set -E
@@ -19,7 +19,7 @@ trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
-TMPDIR="$(mktemp -dt "$(basename $0).XXXX")"
+TMPDIR="$(mktemp -dt "${0##*/}.XXXX")"
DBLIST=()
# Repos
diff --git a/migrate-repo b/migrate-repo
index 2e44adb..751d5bd 100755
--- a/migrate-repo
+++ b/migrate-repo
@@ -1,6 +1,6 @@
#!/bin/bash
-source $(dirname $0)/config
+source "$(dirname "$(readlink -e "$0")")/config"
#dryrun="--dry-run"
diff --git a/mkrepo b/mkrepo
index 5f704cc..10d014b 100755
--- a/mkrepo
+++ b/mkrepo
@@ -3,8 +3,8 @@
# License: GPLv3+
# Description: A script to quickly create new [repos]
-source $(dirname $0)/config
-source $(dirname $0)/local_config
+source "$(dirname "$(readlink -e "$0")")/config"
+source "$(dirname "$(readlink -e "$0")")/local_config"
# TODO it would be simpler to expand arrays to {element1,element2,etc}
for repo in $@; do
diff --git a/repo-restore-to-normal b/repo-restore-to-normal
index 9463731..3636920 100755
--- a/repo-restore-to-normal
+++ b/repo-restore-to-normal
@@ -1,8 +1,8 @@
#!/bin/bash
# Solves issue165
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
CLEANUP_DESTDIR=/home/parabolavnx/repo/pool/restore
PKGREPOS=(community)
diff --git a/testing2x b/testing2x
index 54cae11..14a45de 100755
--- a/testing2x
+++ b/testing2x
@@ -1,10 +1,10 @@
#!/bin/bash
-. "$(dirname $0)/db-functions"
-. "$(dirname $0)/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
if [ $# -lt 1 ]; then
- msg "usage: $(basename $0) <pkgname|pkgbase> ..."
+ msg "usage: ${0##*/} <pkgname|pkgbase> ..."
exit 1
fi
@@ -54,7 +54,7 @@ for repo in 'core' 'extra'; do
repo_unlock ${repo} ${pkgarch}
done
if [ -n "${pkgs[${repo}]}" ]; then
- "$(dirname $0)/db-move" 'testing' "${repo}" ${pkgs[${repo}]}
+ "$(dirname "$(readlink -e "$0")")/db-move" 'testing' "${repo}" ${pkgs[${repo}]}
fi
done
diff --git a/yf-update b/yf-update
index 9c2131e..3bce4aa 100755
--- a/yf-update
+++ b/yf-update
@@ -1,17 +1,17 @@
#!/bin/bash
-source $(dirname $0)/local_config
-source $(dirname $0)/config
-source $(dirname $0)/libremessages
+source "$(dirname "$(readlink -e "$0")")/local_config"
+source "$(dirname "$(readlink -e "$0")")/config"
+source "$(dirname "$(readlink -e "$0")")/libremessages"
blacklist_mtime=$(printf "%.0f" $(find ${blacklist} -printf "%T@"))
-last_bl_mtime=$(cat $(dirname $0)/yftime)
+last_bl_mtime=$(cat "$(dirname "$(readlink -e "$0")")/yftime")
if [ $blacklist_mtime -gt $last_bl_mtime ]; then
- pushd $(dirname $0)/yf
+ pushd "$(dirname "$(readlink -e "$0")")/yf"
makepkg -f
find . -name "*${PKGEXT}" -exec mv {} ${STAGING}/libre \;
popd
- echo ${blacklist_mtime} > $(dirname $0)/yftime
+ echo ${blacklist_mtime} > "$(dirname "$(readlink -e "$0")")/yftime"
msg2 "built and staged"
else
msg2 "nothing to do"