summaryrefslogtreecommitdiffstats
path: root/scripts/repo-add.sh.in
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-06-14 17:48:28 +0200
committerDan McGee <dan@archlinux.org>2008-06-14 17:48:28 +0200
commit89819b3f9268062ee54c35a16876474414d94bf5 (patch)
treebd9b7d62c2a979dc6561507257e266b469cb297d /scripts/repo-add.sh.in
parentc11bdf19b1b8ab40468561dc592b9c6bd7f86acf (diff)
downloadpacman-89819b3f9268062ee54c35a16876474414d94bf5.tar.gz
pacman-89819b3f9268062ee54c35a16876474414d94bf5.tar.xz
repo-*: allow use of readlink or realpath
Linux coreutils provides readlink, and BSD systems tend to have realpath available. Both commands provide similar functionality but of course have different names. Add a check for either and use what is available. While doing this, also unify some of the differences that have cropped up between repo-add and repo-remove. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts/repo-add.sh.in')
-rw-r--r--scripts/repo-add.sh.in23
1 files changed, 17 insertions, 6 deletions
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index e90f0e89..53a7da50 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -103,8 +103,8 @@ write_list_entry() {
# arg1 - path to delta
db_write_delta()
{
- # blank out all variables and set deltafile
- local deltafile=$(readlink -f "$1")
+ # blank out all variables and set deltafile to absolute path
+ local deltafile=$($realpath "$1")
local filename=$(basename "$deltafile")
local deltavars pkgname fromver tover arch csize md5sum
@@ -134,8 +134,8 @@ db_write_delta()
# arg1 - path to package
db_write_entry()
{
- # blank out all variables and set pkgfile
- local pkgfile=$(readlink -f "$1")
+ # blank out all variables and set pkgfile to an absolute path
+ local pkgfile=$($realpath "$1")
local pkgname pkgver pkgdesc url builddate packager csize size \
group depend backup license replaces provides conflict force \
_groups _depends _backups _licenses _replaces _provides _conflicts \
@@ -278,6 +278,16 @@ if [ $# -lt 2 ]; then
exit 1
fi
+# check for and store the name of a realpath-like program
+if [ $(type -t realpath) ]; then
+ realpath='realpath'
+elif [ $(type -t readlink) ]; then
+ realpath='readlink -f'
+else
+ error "$(gettext "Either realpath or readlink are required by repo-add.")"
+ exit 1 # $E_MISSING_PROGRAM
+fi
+
# source system and user makepkg.conf
if [ -r "$confdir/makepkg.conf" ]; then
source "$confdir/makepkg.conf"
@@ -304,7 +314,8 @@ for arg in "$@"; do
elif [ "$arg" == "--quiet" -o "$arg" == "-q" ]; then
QUIET=1
elif [ -z "$REPO_DB_FILE" ]; then
- REPO_DB_FILE=$(readlink -f "$arg")
+ # store absolute path to repo DB
+ REPO_DB_FILE=$($realpath "$arg")
if ! test_repo_db_file; then
error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE"
exit 1
@@ -331,7 +342,7 @@ done
# if all operations were a success, re-zip database
if [ $success -eq 1 ]; then
- msg "$(gettext "Creating updated database file %s")" "$REPO_DB_FILE"
+ msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE"
pushd "$gstmpdir" 2>&1 >/dev/null
if [ -n "$(ls)" ]; then