summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2008-04-08 19:07:18 +0200
committerAaron Griffin <aaronmgriffin@gmail.com>2008-04-08 19:16:57 +0200
commit662fb163936fbe55b67159496ab86c5b34ff6351 (patch)
tree4953c84b0f60b33e37bacb382a723ad23361d73e
parentd2fa8ca9ef201b25d0a7af2c8ac5dc8ae8051162 (diff)
downloaddbscripts-662fb163936fbe55b67159496ab86c5b34ff6351.tar.gz
dbscripts-662fb163936fbe55b67159496ab86c5b34ff6351.tar.xz
Correct lockfile usage
We want a lock per repo not per user. Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
-rw-r--r--db-inc13
1 files changed, 7 insertions, 6 deletions
diff --git a/db-inc b/db-inc
index 7f5a66a..3f0e286 100644
--- a/db-inc
+++ b/db-inc
@@ -19,7 +19,7 @@ fi
WORKDIR="~/.dbscripts"
CHECKOUTDIR="$WORKDIR/checkout"
-LOCKFILE="$WORKDIR/lock"
+LOCKFILE="/tmp/.repolck.$arch.$repoid"
DBFILE="$WORKDIR/$reponame.db.tar.gz"
if [ ! `type -p fakeroot` ]; then
@@ -46,7 +46,7 @@ getpkgname() {
cleanup() {
# unlock
- rm -f "~/.dbscripts/lock"
+ rm -f "$LOCKFILE"
[ "$1" ] && exit $1
}
@@ -61,15 +61,16 @@ die() {
}
# check for locks
-if [ -f ~/.dbscripts/lock ]; then
- echo "error: db generation is already in progress"
- exit 1
+if [ -f "$LOCKFILE" ]; then
+ owner=$(/bin/ls -l $LOCKFILE | /bin/awk '{print $3}')
+ echo "error: db generation is already in progress (started by $owner)"
+ exit 1
fi
# catch ^C breaks
trap ctrl_c SIGINT
# lock
-touch ~/.dbscripts/lock
+touch "$LOCKFILE"
if [ -d $CHECKOUTDIR ]; then
cd $CHECKOUTDIR