From 63b99d1562607f89d4a3edc0eb0f5c971312d8db Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Tue, 6 Jan 2004 02:50:53 +0000 Subject: trapped SIGINT to cleanly remove lock files --- db-arch | 19 +++++++++++++------ db-extra | 17 ++++++++++++----- db-unstable | 18 ++++++++++++------ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/db-arch b/db-arch index e0dcf0e..d2c93b8 100755 --- a/db-arch +++ b/db-arch @@ -1,10 +1,17 @@ #!/bin/bash -# $Id: db-arch,v 1.12 2003/11/25 01:28:26 judd Exp $ +# $Id: db-arch,v 1.13 2004/01/06 02:50:53 judd Exp $ uid=`id -u` TMPDIR="/tmp/archpkg.$uid" repoid=1 +cleanup() { + rm -rf $TMPDIR + # unlock + rm -f /tmp/.repolck.$repoid + exit 0 +} + # check for locks if [ -f /tmp/.repolck.$repoid ]; then owner=`/bin/ls -l /tmp/.repolck.$repoid | awk '{print $3}'` @@ -16,6 +23,8 @@ if [ -d /tmp/.gensync ]; then exit 1 fi +# catch ^C breaks +trap cleanup SIGINT # lock touch /tmp/.repolck.$repoid @@ -26,18 +35,16 @@ if [ -d /tmp/archpkg.$uid ]; then fi mkdir /tmp/archpkg.$uid; [ $? -gt 0 ] && exit 1 -echo "==> Generating Pacman Database for OFFICIAL..." >&2 +echo "==> Generating Pacman Database for CURRENT..." >&2 cd $TMPDIR CVS_RSH=ssh CVSROOT=:ext:cvs.archlinux.org:/home/cvs-arch cvs -q export -r CURRENT -f arch/build /usr/bin/gensync $TMPDIR/arch/build $TMPDIR/current.db.tar.gz /home/ftp/current [ -f $TMPDIR/current.db.tar.gz ] && mv -f $TMPDIR/current.db.tar.gz /home/ftp/current -cd $TMPDIR/arch/build && /arch/pkgdb 1 +cd $TMPDIR/arch/build && /arch/pkgdb $repoid echo "==> Generating Text Package List..." >&2 /arch/genpkglist current mv packages.txt /home/ftp/current/setup/packages.txt -rm -rf $TMPDIR -# unlock -rm -f /tmp/.repolck.$repoid +cleanup diff --git a/db-extra b/db-extra index 506aea6..b50c7a6 100755 --- a/db-extra +++ b/db-extra @@ -1,10 +1,17 @@ #!/bin/bash -# $Id: db-extra,v 1.3 2003/12/21 03:24:09 judd Exp $ +# $Id: db-extra,v 1.4 2004/01/06 02:50:53 judd Exp $ uid=`id -u` TMPDIR="/tmp/archpkg.$uid" repoid=2 +cleanup() { + rm -rf $TMPDIR + # unlock + rm -f /tmp/.repolck.$repoid + exit 0 +} + # check for locks if [ -f /tmp/.repolck.$repoid ]; then owner=`/bin/ls -l /tmp/.repolck.$repoid | awk '{print $3}'` @@ -16,6 +23,8 @@ if [ -d /tmp/.gensync ]; then exit 1 fi +# catch ^C breaks +trap cleanup SIGINT # lock touch /tmp/.repolck.$repoid @@ -32,11 +41,9 @@ CVS_RSH=ssh CVSROOT=:ext:cvs.archlinux.org:/home/cvs-extra cvs -q export -r CURR /usr/bin/gensync $TMPDIR/extra $TMPDIR/extra.db.tar.gz /home/ftp/extra [ -f $TMPDIR/extra.db.tar.gz ] && mv -f $TMPDIR/extra.db.tar.gz /home/ftp/extra -cd $TMPDIR/extra && /arch/pkgdb 2 +cd $TMPDIR/extra && /arch/pkgdb $repoid echo "==> Scanning for missing packages..." >&2 /arch/genpkglist extra -rm -rf $TMPDIR -# unlock -rm -f /tmp/.repolck.$repoid +cleanup diff --git a/db-unstable b/db-unstable index e090c88..93e8465 100755 --- a/db-unstable +++ b/db-unstable @@ -1,10 +1,17 @@ #!/bin/bash -# $Id: db-unstable,v 1.8 2003/11/25 01:28:26 judd Exp $ +# $Id: db-unstable,v 1.9 2004/01/06 02:50:53 judd Exp $ uid=`id -u` TMPDIR="/tmp/archpkg.$uid" repoid=3 +cleanup() { + rm -rf $TMPDIR + # unlock + rm -f /tmp/.repolck.$repoid + exit 0 +} + # check for locks if [ -f /tmp/.repolck.$repoid ]; then owner=`/bin/ls -l /tmp/.repolck.$repoid | awk '{print $3}'` @@ -16,6 +23,8 @@ if [ -d /tmp/.gensync ]; then exit 1 fi +# catch ^C breaks +trap cleanup SIGINT # lock touch /tmp/.repolck.$repoid @@ -32,12 +41,9 @@ CVS_RSH=ssh CVSROOT=:ext:cvs.archlinux.org:/home/cvs-unstable cvs -q export -r C /usr/bin/gensync $TMPDIR/unstable $TMPDIR/unstable.db.tar.gz /home/ftp/unstable [ -f $TMPDIR/unstable.db.tar.gz ] && mv -f $TMPDIR/unstable.db.tar.gz /home/ftp/unstable -cd $TMPDIR/unstable && /arch/pkgdb 3 +cd $TMPDIR/unstable && /arch/pkgdb $repoid echo "==> Scanning for missing packages..." >&2 /arch/genpkglist unstable -rm -rf $TMPDIR -# unlock -rm -f /tmp/.repolck.$repoid - +cleanup -- cgit v1.2.3-24-g4f1b