Scripts for collecting data on Gnucomo clients.
[gnucomo.git] / scripts / ls-rpm
diff --git a/scripts/ls-rpm b/scripts/ls-rpm
new file mode 100755 (executable)
index 0000000..139973c
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+#   Turn an 'ls' listing of RPM files into an 'rpm -qa' listing
+#   Reads a list of filenames, possibly preceeded by a directory and
+#   strips the directory path from the beginning and the two suffices
+#   from the end of each filename. For example, the name
+#   "/mnt/cdrom/RedHat/RPMS/kernel-2.4.20-13.7.i686.rpm" gets turned
+#   into a simple "kernel-2.4.20-13.7".
+#
+#  This is most usefull for maintaining a repository of the most recent
+#  packages. Using this script, you can keep a list of packages in the
+#  Gnucomo database. To do this, create a virtual object, for example
+#  with the name "redhat-7.3" and feed the list of RPM names into gcm_input
+#  like this:
+#
+#   ls /mnt/cdrom/RedHat/RPMS | ls-rpm | sort | uniq | gcm_input -h redhat-7.3
+#
+#  After that, enter the updated RPMs with the -i flag for gcm_input.
+#
+#  Examples:
+#  ls /archive/linux/update9.0/*/*.rpm /archive/linux/latest/RH9/*.rpm | ls-rpm \
+#     | sort | uniq | gcm_input -i -h redhat-9.0
+
+while read filename
+do
+   case $filename in
+   *.src.rpm)
+   ;;
+
+   *)
+      filename=`basename $filename .rpm`
+      case $filename in
+      *.athlon)
+         rpm=`basename $filename .athlon`
+      ;; 
+      *.i386)
+         rpm=`basename $filename .i386`
+      ;; 
+      *.i486)
+         rpm=`basename $filename .i486`
+      ;; 
+      *.i586)
+         rpm=`basename $filename .i586`
+      ;; 
+      *.i686)
+         rpm=`basename $filename .i686`
+      ;; 
+      *.noarch)
+         rpm=`basename $filename .noarch`
+      ;; 
+      esac
+      echo $rpm
+   ;;
+   esac
+done