summaryrefslogtreecommitdiffstats
path: root/db-arch
blob: d2c93b8a9bf7887ae12a8b9d70c801046c839295 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# $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}'`
	echo "error: db generation is already in progress (started by $owner)"
	exit 1
fi
if [ -d /tmp/.gensync ]; then
	echo "error: someone else is currently running gensync!"
	exit 1
fi

# catch ^C breaks
trap cleanup SIGINT
# lock
touch /tmp/.repolck.$repoid

# RedHat's mktemp is broken...
if [ -d /tmp/archpkg.$uid ]; then
	echo "==> Removing old temp dir..." >&2
	rm -rf /tmp/archpkg.$uid || exit 1
fi
mkdir /tmp/archpkg.$uid; [ $? -gt 0 ] && exit 1

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 $repoid

echo "==> Generating Text Package List..." >&2
/arch/genpkglist current
mv packages.txt /home/ftp/current/setup/packages.txt

cleanup