[arch-projects] [dbscripts] [PATCH 6/8] Consistently use "$(dirname "$(readlink -e "$0")")"
Luke Shumaker
lukeshu at lukeshu.com
Wed Mar 14 01:52:03 UTC 2018
From: Luke Shumaker <lukeshu at parabola.nu>
This does correct handling of
- executing a program by symlink
- any weird characters in the full path
- I'm sure there's another case I thought about when I originally did
this.
---
cron-jobs/ftpdir-cleanup | 4 ++--
cron-jobs/integrity-check | 2 +-
cron-jobs/update-web-db | 4 ++--
db-move | 4 ++--
db-remove | 4 ++--
db-repo-add | 4 ++--
db-repo-remove | 4 ++--
db-update | 4 ++--
testing2x | 6 +++---
9 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
index 62a2903..548b839 100755
--- a/cron-jobs/ftpdir-cleanup
+++ b/cron-jobs/ftpdir-cleanup
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname "$0")/../config"
-. "$(dirname "$0")/../db-functions"
+. "$(dirname "$(readlink -e "$0")")/../config"
+. "$(dirname "$(readlink -e "$0")")/../db-functions"
clean_pkg() {
local pkg
diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check
index 17153c7..904dfc1 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}/../config"
. "${dirname}/../db-functions"
diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db
index 87e8bb0..39ed765 100755
--- a/cron-jobs/update-web-db
+++ b/cron-jobs/update-web-db
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname "$0")/../config"
-. "$(dirname "$0")/../db-functions"
+. "$(dirname "$(readlink -e "$0")")/../config"
+. "$(dirname "$(readlink -e "$0")")/../db-functions"
# setup paths
SPATH="/srv/http/archweb"
diff --git a/db-move b/db-move
index ab05d57..8308cb5 100755
--- a/db-move
+++ b/db-move
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname "$0")/config"
-. "$(dirname "$0")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
if (( $# < 3 )); then
msg "usage: %s <repo-from> <repo-to> <pkgname|pkgbase> ..." "${0##*/}"
diff --git a/db-remove b/db-remove
index bf19d6a..87f41bc 100755
--- a/db-remove
+++ b/db-remove
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname "$0")/config"
-. "$(dirname "$0")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
if (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgname|pkgbase> ..." "${0##*/}"
diff --git a/db-repo-add b/db-repo-add
index 7e68221..3ee3528 100755
--- a/db-repo-add
+++ b/db-repo-add
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname "$0")/config"
-. "$(dirname "$0")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
if (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgfile> ..." "${0##*/}"
diff --git a/db-repo-remove b/db-repo-remove
index 87f01f8..a0b8c1c 100755
--- a/db-repo-remove
+++ b/db-repo-remove
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname "$0")/config"
-. "$(dirname "$0")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
if (( $# < 3 )); then
msg "usage: %s <repo> <arch> <pkgname> ..." "${0##*/}"
diff --git a/db-update b/db-update
index 2898b1c..c7018c7 100755
--- a/db-update
+++ b/db-update
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname "$0")/config"
-. "$(dirname "$0")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
if (( $# >= 1 )); then
warning "Calling %s with a specific repository is no longer supported" "${0##*/}"
diff --git a/testing2x b/testing2x
index 606c003..d2cc9fc 100755
--- a/testing2x
+++ b/testing2x
@@ -1,7 +1,7 @@
#!/bin/bash
-. "$(dirname "$0")/config"
-. "$(dirname "$0")/db-functions"
+. "$(dirname "$(readlink -e "$0")")/config"
+. "$(dirname "$(readlink -e "$0")")/db-functions"
if (( $# < 1 )); then
msg "usage: %s <pkgname|pkgbase> ..." "${0##*/}"
@@ -54,7 +54,7 @@ for repo in "${STABLE_REPOS[@]}"; do
repo_unlock "${repo}" "${pkgarch}"
done
if [[ -n ${pkgs[${repo}]} ]]; then
- "$(dirname "$0")/db-move" "${TESTING_REPO}" "${repo}" ${pkgs[${repo}]}
+ "$(dirname "$(readlink -e "$0")")/db-move" "${TESTING_REPO}" "${repo}" ${pkgs[${repo}]}
fi
done
--
2.16.1
More information about the arch-projects
mailing list