RPM Hints

RPM Hints

From Consultancy.EdVoncken.NET

Jump to: navigation, search

Contents

List all Non-RedHat supplied software packages on a host

OK, you've installed stuff from Dell, RPMforge etc. but you forgot which packages they were:

 rpm -qa --queryformat "%{VENDOR}|%{BUILDHOST}|%{NAME}\n" |egrep -v "(Red Hat, Inc\.|redhat\.com)"


Create a lookup table for your RPMs

Just for SnG I need a list of all files by package and such that are installed:

 rpm -qa --queryformat '[%{NAME};%{VERSION};%{RELEASE};%{VENDOR};%{FILENAMES}\n]' >rpmfile.db


rpmstat

Get some information about installation sizes from rpm.

 rpm -qa --queryformat "%{SIZE}\n" | awk '{arg += $1; num++ }
         END{
                 printf "Total size:     %0.3f Gb\n", arg / 1073741824;
                 printf "Total packages: %d\n", num;
                 printf "Av. size p/p:   %0.1f Mb\n", ( arg / num )/1048576;
         }'


Update local mirror

Rather ugly (but effective) way of mirroring an RPM site's files. Useful for local mirrors

  #!/bin/bash
  #
  #
  URL=http://archive.cs.uu.nl/mirror/Linux/centos/5.0/updates/i386/RPMS
  
  [[ -f list ]] && rm list
  
  wget -O - $URL | cut -d\" -f 6| grep rpm| while read filename
  do
          if [ -f "$filename" ]
          then
                  echo "already have $filename"
          else
                  echo ${URL}/${filename} >>list
          fi
  done
  wget -i list
  


Check for broken packages in your source

Note: you'll need to have all the required RPM-GPG-KEY's installed.

 find PACKAGEDIR -type f -name '*.rpm' -exec rpm -K "{}" \; | grep NOT