Intergrated test scripts with automake
[gnucomo.git] / scripts / ls-rpm
1 #!/bin/sh
2 #
3 #   Turn an 'ls' listing of RPM files into an 'rpm -qa' listing
4 #   Reads a list of filenames, possibly preceeded by a directory and
5 #   strips the directory path from the beginning and the two suffices
6 #   from the end of each filename. For example, the name
7 #   "/mnt/cdrom/RedHat/RPMS/kernel-2.4.20-13.7.i686.rpm" gets turned
8 #   into a simple "kernel-2.4.20-13.7".
9 #
10 #  This is most usefull for maintaining a repository of the most recent
11 #  packages. Using this script, you can keep a list of packages in the
12 #  Gnucomo database. To do this, create a virtual object, for example
13 #  with the name "redhat-7.3" and feed the list of RPM names into gcm_input
14 #  like this:
15 #
16 #   ls /mnt/cdrom/RedHat/RPMS | ls-rpm | sort | uniq | gcm_input -h redhat-7.3
17 #
18 #  After that, enter the updated RPMs with the -i flag for gcm_input.
19 #
20 #  Examples:
21 #  ls /archive/linux/update9.0/*/*.rpm /archive/linux/latest/RH9/*.rpm | ls-rpm \
22 #     | sort | uniq | gcm_input -i -h redhat-9.0
23
24 while read filename
25 do
26    case $filename in
27    *.src.rpm)
28    ;;
29
30    *)
31       filename=`basename $filename .rpm`
32       case $filename in
33       *.athlon)
34          rpm=`basename $filename .athlon`
35       ;; 
36       *.i386)
37          rpm=`basename $filename .i386`
38       ;; 
39       *.i486)
40          rpm=`basename $filename .i486`
41       ;; 
42       *.i586)
43          rpm=`basename $filename .i586`
44       ;; 
45       *.i686)
46          rpm=`basename $filename .i686`
47       ;; 
48       *.noarch)
49          rpm=`basename $filename .noarch`
50       ;; 
51       esac
52       echo $rpm
53    ;;
54    esac
55 done