diff options
author | Judd Vinet <judd@archlinux.org> | 2003-08-16 23:56:46 +0000 |
---|---|---|
committer | Judd Vinet <judd@archlinux.org> | 2003-08-16 23:56:46 +0000 |
commit | cd3590946ac66b7adcfa95f51f00f917327bf20a (patch) | |
tree | a08dd50987c50c79ea498488a79279f2834d2538 | |
parent | 401e01f8411179d8aa9598a07e4621b2fb19e986 (diff) |
added locking
-rwxr-xr-x | db-arch | 15 | ||||
-rwxr-xr-x | db-unstable | 15 | ||||
-rwxr-xr-x | pkgdb | 14 |
3 files changed, 37 insertions, 7 deletions
@@ -1,8 +1,19 @@ #!/bin/bash -# $Id: db-arch,v 1.9 2003/06/05 00:01:24 judd Exp $ +# $Id: db-arch,v 1.10 2003/08/16 23:56:46 judd Exp $ uid=`id -u` TMPDIR="/tmp/archpkg.$uid" +repoid=1 + +# check for locks +if [ -f /tmp/.repolck.$repoid ]; then + owner=`/bin/ls -l /tmp/.repolck.$repoid | awk '{print $3}'` + echo "error: db generation is already in progress (started by $owner)" + exit 1 +fi + +# lock +touch /tmp/.repolck.$repoid # RedHat's mktemp is broken... if [ -d /tmp/archpkg.$uid ]; then @@ -24,3 +35,5 @@ echo "==> Generating Text Package List..." >&2 mv packages.txt /home/ftp/current/setup/packages.txt rm -rf $TMPDIR +# unlock +rm -f /tmp/.repolck.$repoid diff --git a/db-unstable b/db-unstable index 18554c0..93ea565 100755 --- a/db-unstable +++ b/db-unstable @@ -1,8 +1,19 @@ #!/bin/bash -# $Id: db-unstable,v 1.5 2003/05/25 23:50:02 judd Exp $ +# $Id: db-unstable,v 1.6 2003/08/16 23:56:46 judd Exp $ uid=`id -u` TMPDIR="/tmp/archpkg.$uid" +repoid=3 + +# check for locks +if [ -f /tmp/.repolck.$repoid ]; then + owner=`/bin/ls -l /tmp/.repolck.$repoid | awk '{print $3}'` + echo "error: db generation is already in progress (started by $owner)" + exit 1 +fi + +# lock +touch /tmp/.repolck.$repoid # RedHat's mktemp is broken... if [ -d $TMPDIR ]; then @@ -20,4 +31,6 @@ CVS_RSH=ssh CVSROOT=:ext:cvs.archlinux.org:/home/cvs-unstable cvs -q export -r C cd $TMPDIR/unstable && /arch/pkgdb 3 rm -rf $TMPDIR +# unlock +rm -f /tmp/.repolck.$repoid @@ -1,5 +1,5 @@ #!/bin/bash -# $Id: pkgdb,v 1.7 2003/05/26 17:25:59 judd Exp $ +# $Id: pkgdb,v 1.8 2003/08/16 23:56:46 judd Exp $ tl=`pwd` @@ -10,7 +10,7 @@ TMPFILE="/tmp/.mysqltmp.$uid" repoid=$1 dbuser='archweb' dbname='archweb' -dbpass='14xuk0Gi' +dbpass='YWkrOjqm' if [ "$repoid" = "" ]; then me=`basename $0` @@ -30,7 +30,7 @@ updatepkg() { echo "Updating $pkgname" mysql -u $dbuser -p$dbpass $dbname <<_EOF -UPDATE packages SET category='$category',pkgname='$pkgname',pkgver='$pkgver', +UPDATE packages SET categoryid='$categoryid',pkgname='$pkgname',pkgver='$pkgver', pkgrel='$pkgrel',pkgdesc='$pkgdesc',url='$url',sources='$sources', depends='$deplist',lastupdate=NOW() WHERE id='$id'; _EOF @@ -40,9 +40,9 @@ insertpkg() { echo "Inserting $pkgname" mysql -u $dbuser -p$dbpass $dbname <<_EOF -INSERT INTO packages (id,repoid,category,pkgname,pkgver,pkgrel, +INSERT INTO packages (id,repoid,categoryid,pkgname,pkgver,pkgrel, pkgdesc,url,sources,depends,lastupdate) VALUES (NULL,$repoid, -'$category','$pkgname','$pkgver','$pkgrel','$pkgdesc','$url', +'$categoryid','$pkgname','$pkgver','$pkgrel','$pkgdesc','$url', '$sources','$deplist',NOW()); _EOF } @@ -70,6 +70,10 @@ process() { # tag it touch .tag category=`pwd | sed "s|$tl/||" | sed 's|/.*$||'` + mysql --skip-column-names -u $dbuser -p$dbpass $dbname >$TMPFILE <<_EOF +SELECT id FROM categories WHERE category='$category'; +_EOF + categoryid=`cat $TMPFILE | awk '{print $1}'` cd - &>/dev/null deplist=${depends[@]} deplist=`php -r "echo addslashes(\"$deplist\");"` |