summaryrefslogtreecommitdiffstats
path: root/db-move
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2008-08-31 04:21:43 +0200
committerAaron Griffin <aaronmgriffin@gmail.com>2008-08-31 04:21:43 +0200
commitafc6b5b5977fe77e699af8f02f7c8c4c3df603de (patch)
treec237e2bf8a41cde6a1ce3c981cacc8a1c282e262 /db-move
parent01d2e01a129a4ded9ccba2659250a94cb3fddd36 (diff)
downloaddbscripts-afc6b5b5977fe77e699af8f02f7c8c4c3df603de.tar.gz
dbscripts-afc6b5b5977fe77e699af8f02f7c8c4c3df603de.tar.xz
Create a "common functions" file for DB scripts
Common functions, such as sourcing makepkg, and locking a repo Additionally, repo-locking has been unified to prevent multiple users from corrupting a repo (i.e. db-move run while db-remove in progress) Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Diffstat (limited to 'db-move')
-rwxr-xr-xdb-move26
1 files changed, 9 insertions, 17 deletions
diff --git a/db-move b/db-move
index f8adfc1..13f2c4e 100755
--- a/db-move
+++ b/db-move
@@ -6,13 +6,9 @@ if [ $# -ne 4 ]; then
exit 1
fi
-if [ -f "/etc/makepkg.conf" ]; then
- #Get some config info
- . /etc/makepkg.conf
-else
- echo "/etc/makepkg.conf does not exist!"
- exit 1
-fi
+. "$(dirname $0)/db-functions"
+
+source_makepkg
packagename="$1"
repofrom="$2"
@@ -32,11 +28,11 @@ svnrepo_to="$repoto-$arch"
[ "$UID" = "" ] && UID=$(uid)
WORKDIR="/tmp/db-move.$svnrepo_from.$svnrepo_to.$UID"
-LOCKFILE="/tmp/.repolck.$arch.$reponame"
cleanup() {
# unlock
- rm -f "$LOCKFILE"
+ repo_unlock $repoto $arch
+ repo_unlock $repofrom $arch
rm -rf "$WORKDIR"
[ "$1" ] && exit $1
}
@@ -51,16 +47,12 @@ die() {
cleanup 1
}
-# check for locks
-if [ -f "$LOCKFILE" ]; then
- owner="$(/usr/bin/stat -c %U $LOCKFILE)"
- die "error: db generation is already in progress (started by $owner)"
-fi
-
trap ctrl_c 2
-trap cleanup 0
+trap cleanup 0 1
+
+repo_lock $repoto $arch
+repo_lock $repofrom $arch
-/bin/touch "$LOCKFILE"
/bin/mkdir -p "$WORKDIR"
cd "$WORKDIR"