summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-08-15 20:56:12 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-08-15 20:56:12 +0200
commit6f6ed4dc9f1bbce3638824def5d07b78aff44cde (patch)
treeae8542b9d5acf09cfad50dedf76fad68ba79a0b9
parentb5fb2927cde513dc0fd82e4fd4dfe3836cf35728 (diff)
Fix locking in db-remove
-rwxr-xr-xdb-remove56
1 files changed, 25 insertions, 31 deletions
diff --git a/db-remove b/db-remove
index 5afd858..188cc60 100755
--- a/db-remove
+++ b/db-remove
@@ -1,58 +1,52 @@
#!/bin/bash
if [ $# -ne 3 ]; then
- msg "usage: $(basename $0) <pkgname|packagebase> <reponame> <arch>"
+ msg "usage: $(basename $0) <pkgname|pkgbase> <repo> <arch>"
exit 1
fi
. "$(dirname $0)/db-functions"
. "$(dirname $0)/config"
-packagebase="$1"
-reponame="$2"
+pkgbase="$1"
+repo="$2"
arch="$3"
-ftppath="$FTP_BASE/$reponame/os"
-svnrepo="$reponame-$arch"
+ftppath="$FTP_BASE/$repo/os"
+svnrepo="$repo-$arch"
-if ! check_repo_permission $reponame; then
- error "You don't have permission to remove packages from ${reponam}"
- exit 1
+if ! check_repo_permission $repo; then
+ die "You don't have permission to remove packages from ${reponam}"
fi
-repo_lock $reponame $arch || exit 1
-
-msg "Removing $packagebase from [$reponame]..."
-cd "$WORKDIR"
-/usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null
-cd checkout
-
-/usr/bin/svn up -q $packagebase
-if [ -d "$packagebase/repos/$svnrepo" ]; then
- pkgname=($(. "$packagebase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]}))
- /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo"
- /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by $(id -un)"
+if [ "$arch" == "any" ]; then
+ tarches=(${ARCHES[@]})
else
- die "$packagebase not found in $svnrepo"
+ tarches=("$arch")
fi
-cd "$WORKDIR"
+for tarch in ${tarches[@]}; do
+ repo_lock $repo $tarch || exit 1
+done
-if [ "$arch" == "any" ]; then
- tarches=(${ARCHES[@]})
+msg "Removing $pkgbase from [$repo]..."
+/usr/bin/svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null
+
+if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then
+ pkgnames=($(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]}))
+ /usr/bin/svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo"
+ /usr/bin/svn commit -q "${WORKDIR}/svn/$pkgbase" -m "$(basename $0): $pkgbase removed by $(id -un)"
else
- tarches=("$arch")
+ die "$pkgbase not found in $svnrepo"
fi
+
# copy the db file into our working area
for tarch in ${tarches[@]}; do
- if [ ! -f "$ftppath/$tarch/$reponame$DBEXT" ]; then
+ if [ ! -f "$ftppath/$tarch/$repo$DBEXT" ]; then
die "No database found at '$ftppath/$tarch', nothing more to do"
fi
- /usr/bin/repo-remove -q "$ftppath/$tarch/$reponame$DBEXT" ${pkgname[@]} >/dev/null
+ /usr/bin/repo-remove -q "$ftppath/$tarch/$repo$DBEXT" ${pkgnames[@]} >/dev/null
+ repo_unlock $repo $tarch
done
-
-repo_unlock $reponame $arch || exit 1
-
-# vim: set ts=4 sw=4 noet ft=sh: