summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2009-02-18 16:39:31 +0100
committerDan McGee <dan@archlinux.org>2009-02-19 19:20:19 -0600
commitc590ac0997b5c82ddf9115191e9ac5c79efde227 (patch)
tree8863b31406566657eb6f0f16737693d330a6470a
parent1c4633ea2cbc01cfd7929509724951615827c482 (diff)
downloadpacman-c590ac0997b5c82ddf9115191e9ac5c79efde227.tar.xz
repo-add : remove the need of realpath for REPO_DB_FILE
REPO_DB_FILE does not need to be an absolute path anymore so no need to call realpath. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--scripts/repo-add.sh.in33
1 files changed, 16 insertions, 17 deletions
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index b4ae7d35..7638f455 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -319,8 +319,7 @@ for arg in "$@"; do
elif [ "$arg" == "--quiet" -o "$arg" == "-q" ]; then
QUIET=1
elif [ -z "$REPO_DB_FILE" ]; then
- # store absolute path to repo DB
- REPO_DB_FILE=$($realpath "$arg")
+ REPO_DB_FILE="$arg"
if [ -f "$REPO_DB_FILE" ]; then
if ! (bsdtar -tf "$REPO_DB_FILE" | grep -q "/desc"); then
error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE"
@@ -362,27 +361,27 @@ 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"
- pushd "$gstmpdir" 2>&1 >/dev/null
- if [ -n "$(ls)" ]; then
- [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old"
- [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old"
-
- case "$REPO_DB_FILE" in
- *tar.gz) TAR_OPT="z" ;;
- *tar.bz2) TAR_OPT="j" ;;
- *) warning "$(gettext "'%s' does not have a valid archive extension.")" \
- "$REPO_DB_FILE" ;;
- esac
+ case "$REPO_DB_FILE" in
+ *tar.gz) TAR_OPT="z" ;;
+ *tar.bz2) TAR_OPT="j" ;;
+ *) warning "$(gettext "'%s' does not have a valid archive extension.")" \
+ "$REPO_DB_FILE" ;;
+ esac
+
+ filename=$(basename "$REPO_DB_FILE")
- bsdtar -c${TAR_OPT}f "$REPO_DB_FILE" *
+ pushd "$gstmpdir" 2>&1 >/dev/null
+ if [ -n "$(ls)" ]; then
+ bsdtar -c${TAR_OPT}f "$filename" *
else
- # we should only end up with an empty db after a remove of the last package in the database
+ # the database will be moved to .old below, and there will be no new one to replace it
error "$(gettext "All packages have been removed from the database. Deleting '%s'.")" "$REPO_DB_FILE"
- rm "$REPO_DB_FILE"
fi
-
popd 2>&1 >/dev/null
+
+ [ -f "$REPO_DB_FILE" ] && mv -f "$REPO_DB_FILE" "${REPO_DB_FILE}.old"
+ [ -f "$gstmpdir/$filename" ] && mv "$gstmpdir/$filename" "$REPO_DB_FILE"
else
msg "$(gettext "No packages modified, nothing to do.")"
fi