From 6a9ed330551e585ce887a2bb53fb022b1c92da31 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 15 Nov 2011 22:16:41 -0600 Subject: 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 --- scripts/repo-add.sh.in | 15 +++++++-------- 1 file 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 -- cgit v1.2.3-70-g09d2