diff options
author | Dan McGee <dan@archlinux.org> | 2011-11-15 22:16:41 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-11-20 21:36:30 -0600 |
commit | 6a9ed330551e585ce887a2bb53fb022b1c92da31 (patch) | |
tree | 733e110439e9cc0ad16b7c83b0eae6ce91ac26fd /scripts/repo-add.sh.in | |
parent | 2752932d1966488c5bcc0c45282b0de5c8bf561e (diff) | |
download | pacman-6a9ed330551e585ce887a2bb53fb022b1c92da31.tar.xz |
repo-add: ensure path to LOCKFILE is always absolute
Given our semi-frequent use of pushd/popd, if we are in any directory
but the original and the database path given was relative, we won't
unlock the database file when cleaning up after an error.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts/repo-add.sh.in')
-rw-r--r-- | scripts/repo-add.sh.in | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index fc008fc4..280c0240 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -411,13 +411,8 @@ elephant() { check_repo_db() { local repodir - # ensure the path to the DB exists - if [[ "$LOCKFILE" == /* ]]; then - repodir=${LOCKFILE%/*}/ - else - repodir=$PWD/$LOCKFILE - repodir=${repodir%/*}/ - fi + # ensure the path to the DB exists; $LOCKFILE is always an absolute path + repodir=${LOCKFILE%/*}/ if [[ ! -d "$repodir" ]]; then error "$(gettext "%s does not exist or is not a directory.")" "$repodir" @@ -624,7 +619,11 @@ if [[ -z $REPO_DB_FILE ]]; then exit 1 fi -LOCKFILE=$REPO_DB_FILE.lck +if [[ $REPO_DB_FILE == /* ]]; then + LOCKFILE=$REPO_DB_FILE.lck +else + LOCKFILE=$PWD/$REPO_DB_FILE.lck +fi verify_repo_extension "$REPO_DB_FILE" >/dev/null check_repo_db |