Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts/repo-add.sh.in
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2009-02-26 18:16:23 +0100
committerDan McGee <dan@archlinux.org>2009-05-23 12:27:32 -0500
commit30e2496775897644fb397b32e8bdf0ae2f827216 (patch)
treef0a9dd7fe44526acaa56e3d057d4307fdfdd359a /scripts/repo-add.sh.in
parent35b9dfc3805821cb504231a5e5ce5a8694278fb7 (diff)
repo-add: fail early if repo can not be created
Before this commit, the repo creation could fail after all packages have been added to the database. Now this will be detected before adding anything. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts/repo-add.sh.in')
-rw-r--r--scripts/repo-add.sh.in14
1 files changed, 12 insertions, 2 deletions
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 14bd00e4..7c12aaf2 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -312,10 +312,20 @@ check_repo_db()
msg "$(gettext "Extracting database to a temporary location...")"
bsdtar -xf "$REPO_DB_FILE" -C "$tmpdir"
else
- if [ "$cmd" == "repo-remove" ]; then
+ case "$cmd" in
+ repo-remove)
error "$(gettext "Repository file '%s' was not found.")" "$REPO_DB_FILE"
exit 1
- fi
+ ;;
+ repo-add)
+ # check if the file can be created (write permission, directory existence, etc)
+ if ! touch "$REPO_DB_FILE"; then
+ error "$(gettext "Repository file '%s' could not be created.")" "$REPO_DB_FILE"
+ exit 1
+ fi
+ rm -f "$REPO_DB_FILE"
+ ;;
+ esac
fi
}