summaryrefslogtreecommitdiff
path: root/db-inc
blob: 3c7e95484acb2e5fdb5890f3f748ef3fa84987b9 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# $Id: db-inc,v 1.3 2005/06/30 22:30:36 judd Exp $

[ "$UID" = "" ] && UID=`uid`
TMPDIR="/tmp/archpkg.$repoid.$UID"

if [ ! `type -p fakeroot` ]; then
	echo "error: fakeroot is missing"
	exit 1
fi

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

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

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

echo "==> Generating Pacman Database for repository '$reponame'..." >&2
cd $TMPDIR
CVS_RSH=ssh CVSROOT=:ext:cvs.archlinux.org:$cvspath cvs -q export -r CURRENT $cvsmod
if [ $? -gt 0 ]; then
	echo "==> CVS export failed!"
	cleanup
	exit 1
fi

echo "chown -R root.root $TMPDIR/$cvsmod;" \
	"/usr/bin/gensync $TMPDIR/$cvsmod $TMPDIR/$reponame.db.tar.gz $ftppath" \
	| fakeroot

[ -f $TMPDIR/$reponame.db.tar.gz ] && mv -f $TMPDIR/$reponame.db.tar.gz $ftppath

echo "==> Scanning for New/Updated/Deleted packages..." >&2
cd $TMPDIR/$cvsmod
/arch/pkgdb1 $repoid | /arch/pkgdb2 $repoid $ftppath

echo "==> Generating Text Package List..." >&2
/arch/genpkglist $reponame

# hack -- only Current's packages.txt goes in a "setup" subdir
if [ "$reponame" = "current" ]; then
	mv packages.txt $ftppath/setup/packages.txt
else
	mv packages.txt $ftppath/packages.txt
fi

cleanup

# vim: set ts=2 noet ft=sh: