]> TLD Linux GIT Repositories - tld-ftp-admin.git/blob - wwwbin/obsolete-check.sh
- raw from PLD
[tld-ftp-admin.git] / wwwbin / obsolete-check.sh
1 #!/bin/sh
2 # check for packages on ftp whose .spec does not exist (anymore)
3 # this is extremely heavy on cvs server, so you run it once per month or so
4 # Author: Elan Ruusamäe <glen@pld-linux.org>
5
6 export LC_ALL=C
7 ftpdir=$HOME/ftp
8 wwwdir=$HOME/www
9 CVSROOT=:pserver:cvs@cvs.pld-linux.org:/cvsroot
10 d=$-
11
12 orphaned_pkgs() {
13         set -$d
14         [ -s $t/pkgs.desc ] || /usr/bin/poldek --skip-installed "$@" --cmd "desc *" > $t/pkgs.desc
15         [ -s $t/pkgs.lst ] || sed -n 's/^Source package: \(.*\)-[^-]\+-[^-]\+$/\1/p' $t/pkgs.desc | sort -u > $t/pkgs.lst
16         # {w32codec,acroread,...}-installer pkgs
17         sed -i -e 's,-installer$,,' $t/pkgs.lst
18         for pkg in $(cat $t/pkgs.lst); do
19                 # use awk to match package without any regexp fuzz
20                 awk -vpkg=$pkg.spec -vm=1 '$1 == pkg{m=0} END{exit m}' $t/cvs.lst || echo Obsolete: $pkg
21         done
22 }
23
24 # generate list of .specs on ftp. needs cvsnt client
25 cvs_pkgs() {
26         set -$d
27         [ -s $t/cvs.raw ] || cvs -d $CVSROOT -Q ls -e packages > $t/cvs.raw 2>/dev/null
28         [ -s $t/cvs.dirs ] || awk -F/ '$1 == "D" { print $2 } ' $t/cvs.raw > $t/cvs.dirs
29         [ -s $t/cvs.specs ] || {
30                 while read pkg; do
31                         cvs -d $CVSROOT -Q ls -e packages/$pkg/$pkg.spec 2>/dev/null
32                 done < $t/cvs.dirs > $t/cvs.lst.tmp && mv $t/cvs.lst.tmp $t/cvs.specs
33         }
34         [ -s $t/cvs.lst ] || awk -F/ '$1 == "" { print $2 } ' $t/cvs.specs > $t/cvs.lst
35 }
36
37
38 set -e
39 t=$(mktemp -d)
40 #t=/home/pld/admins/th/tmp/tmp.KOCrX7BtOy
41
42 cvs_pkgs
43 orphaned_pkgs -s $ftpdir/PLD/i686/RPMS/ -s $ftpdir/PLD/noarch/RPMS/ > $t/orphaned.txt && cat $t/orphaned.txt > $wwwdir/main-orphaned4.txt
44
45 chmod 644 $wwwdir/*.txt
46 #rm -rf $t