index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
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/repo-add.sh.in | |
parent | b15fb504a19831200b86a43646d8def89560b61c (diff) |
-rw-r--r-- | scripts/repo-add.sh.in | 28 |
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 |