summaryrefslogtreecommitdiff
path: root/wwwbin/obsolete-check.sh
blob: 52a9f81e19bfc618f993f3dbf6773c65838e0905 (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
#!/bin/sh
# check for packages on ftp whose .spec does not exist (anymore)
# this is extremely heavy on cvs server, so you run it once per month or so
# Author: Elan Ruusamäe <glen@pld-linux.org>

export LC_ALL=C
ftpdir=$HOME/ftp
wwwdir=$HOME/www
CVSROOT=:pserver:cvs@cvs.pld-linux.org:/cvsroot
d=$-

orphaned_pkgs() {
	set -$d
	[ -s $t/pkgs.desc ] || /usr/bin/poldek --skip-installed "$@" --cmd "desc *" > $t/pkgs.desc
	[ -s $t/pkgs.lst ] || sed -n 's/^Source package: \(.*\)-[^-]\+-[^-]\+$/\1/p' $t/pkgs.desc | sort -u > $t/pkgs.lst
	# {w32codec,acroread,...}-installer pkgs
	sed -i -e 's,-installer$,,' $t/pkgs.lst
	for pkg in $(cat $t/pkgs.lst); do
		# use awk to match package without any regexp fuzz
		awk -vpkg=$pkg.spec -vm=1 '$1 == pkg{m=0} END{exit m}' $t/cvs.lst || echo Obsolete: $pkg
	done
}

# generate list of .specs on ftp. needs cvsnt client
cvs_pkgs() {
	set -$d
	[ -s $t/cvs.raw ] || cvs -d $CVSROOT -Q ls -e packages > $t/cvs.raw 2>/dev/null
	[ -s $t/cvs.dirs ] || awk -F/ '$1 == "D" { print $2 } ' $t/cvs.raw > $t/cvs.dirs
	[ -s $t/cvs.specs ] || {
		while read pkg; do
			cvs -d $CVSROOT -Q ls -e packages/$pkg/$pkg.spec 2>/dev/null
		done < $t/cvs.dirs > $t/cvs.lst.tmp && mv $t/cvs.lst.tmp $t/cvs.specs
	}
	[ -s $t/cvs.lst ] || awk -F/ '$1 == "" { print $2 } ' $t/cvs.specs > $t/cvs.lst
}


set -e
t=$(mktemp -d)
#t=/home/pld/admins/th/tmp/tmp.KOCrX7BtOy

cvs_pkgs
orphaned_pkgs -s $ftpdir/PLD/i686/RPMS/ -s $ftpdir/PLD/noarch/RPMS/ > $t/orphaned.txt && cat $t/orphaned.txt > $wwwdir/main-orphaned4.txt

chmod 644 $wwwdir/*.txt
#rm -rf $t