summaryrefslogtreecommitdiff
path: root/genpkglist
blob: 7dba4d68a807bdc32a2313c037573c1a9328f465 (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
#!/bin/bash
# $Id: genpkglist,v 1.14 2006/05/05 01:38:33 judd Exp $

#
# genpkglist
#
# Generates a text package database for use with the setup script
# (also used to check for missing packages in the download directory)
#

pkgfile="`pwd`/packages.txt"
ftppath=$1

rm -f $pkgfile
for category in `find * -maxdepth 0 -type d | grep -v CVS`; do
	cd $category
	for pkg in `/bin/ls`; do
		cd $pkg
		if [ -f PKGBUILD ]; then
			. PKGBUILD
			if [ -f $ftppath/$pkgname-$pkgver-$pkgrel.pkg.tar.gz ]; then
				echo "$category/$pkgname-$pkgver-$pkgrel.pkg.tar.gz" >>$pkgfile
			else
				echo "notice: Missing $pkgname-$pkgver-$pkgrel.pkg.tar.gz in ftp site" >&2
			fi
		fi
		cd ..
	done
	cd ..
done

cd $ftppath
unset DUPES DUPEFILES last
for pkg in *.pkg.tar.gz; do
	pkgname=${pkg%-*-*}
	if [ "$last" = "$pkgname" ]; then
		DUPES="$DUPES $pkgname"
		DUPEFILES="$DUPEFILES $pkg"
	fi
	last=$pkgname
done

showdupes() {
	done=
	for i in *.pkg.tar.gz; do
		pkgname=${i%-*-*}
		if [ "$pkgname" = "$1" ]; then
			ls -l $i | awk '{print $6" "$7" "$8" "$9}'
			done=1
		else
			[ "$done" = "1" ] && return
		fi
	done
}

if [ "$DUPES" ]; then
	echo "Possible Dupes for $ftppath (remove old versions)"
	echo "Date             Filename"
	for dupe in $((for d in `echo $DUPES`; do echo $d; done) | sort -u); do
		showdupes $dupe
	done
fi