diff options
author | Xavier Chantry <shiningxc@gmail.com> | 2008-06-17 00:09:45 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-06-29 17:37:45 -0500 |
commit | 11695bd0d7d8efa32066c3adf25007a896661da9 (patch) | |
tree | 2e0dc2158ec31e617936cb9249a569bdb6322d31 /scripts | |
parent | b15fb504a19831200b86a43646d8def89560b61c (diff) | |
download | pacman-11695bd0d7d8efa32066c3adf25007a896661da9.tar.xz |
repo-add cleanup.
* change ln -s to ln -sf in the Makefile to prevent a failure when the link
already exists.
* make test_repo_db_file simpler and more natural, move the complexity out
of it.
* remove one $cmd = repo-remove check that wasn't needed
Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.am | 2 | ||||
-rw-r--r-- | scripts/repo-add.sh.in | 28 |
2 files changed, 15 insertions, 15 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 283556e3..7dccff9d 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -58,6 +58,6 @@ pacman-optimize: $(srcdir)/pacman-optimize.sh.in rankmirrors: $(srcdir)/rankmirrors.py.in repo-add: $(srcdir)/repo-add.sh.in repo-remove: $(srcdir)/repo-add.sh.in - ln -s repo-add repo-remove + ln -sf repo-add repo-remove # vim:set ts=2 sw=2 noet: diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index b6772db6..9ab023d6 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -84,17 +84,12 @@ There is NO WARRANTY, to the extent permitted by law.\n")" } # test if a file is a repository DB -# arg1 - command name (repo-add, repo-remove) test_repo_db_file () { - if [ -f "$REPO_DB_FILE" ]; then - if bsdtar -tf "$REPO_DB_FILE" | grep -q "/desc"; then - return 0 # YES - fi - elif [ "$1" == "repo-add" ]; then - return 0 # YES - No database file is also allowed if we are adding + if bsdtar -tf "$REPO_DB_FILE" | grep -q "/desc"; then + return 0 # YES + else + return 1 # NO fi - - return 1 # NO } # write a list entry @@ -344,12 +339,16 @@ for arg in "$@"; do elif [ -z "$REPO_DB_FILE" ]; then # store absolute path to repo DB REPO_DB_FILE=$($realpath "$arg") - if ! test_repo_db_file $cmd; then - error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE" - exit 1 - elif [ -f "$REPO_DB_FILE" ]; then + if [ -f "$REPO_DB_FILE" ]; then + if ! test_repo_db_file $cmd; then + error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE" + exit 1 + fi msg "$(gettext "Extracting database to a temporary location...")" bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" + elif [ "$cmd" == "repo-remove" ]; then + error "$(gettext "Repository file '%s' was not found.")" "$REPO_DB_FILE" + exit 1 fi else if [ "$cmd" == "repo-add" ]; then @@ -394,7 +393,8 @@ if [ $success -eq 1 ]; then esac bsdtar -c${TAR_OPT}f "$REPO_DB_FILE" * - elif [ "$cmd" == "repo-remove" ]; then + else + # we should only end up with an empty db after a remove of the last package in the database error "$(gettext "All packages have been removed from the database. Deleting '%s'.")" "$REPO_DB_FILE" rm "$REPO_DB_FILE" fi |