Homepage of Lars E. Pettersson

RPM-related tips and tricks

Creating your own rpms, or rebuilding src.rpms

First, you should not do this as an ordinary user. Set up an rpm environment in your home directory instead. It is easy, only two steps.

First step. Create a file ~/.rpmmacros that contains

%packager               Lars E. Pettersson <user@domain.invalid>
 
%_topdir                %(echo $HOME)/redhat

Second step. Create the directories to be used

mkdir -p ~/redhat/{BUILD,RPMS/{i386,i586,i686,x86_64,i686,noarch},SOURCES,SPECS,SRPMS}

You can now rebuild packages with the command rpmbuild --rebuild --clean package-1-1.src.rpm The built binary package, or packages, may be found in the directories below the ~/rpm/RPMS/ directory.

rpm-related problems

In case of trouble with rpm or yum, try to remove the rpm database lock files, /var/lib/rpm/__db.00*, and rebuild the database.

rm /var/lib/rpm/__db.00*
rpm --rebuilddb

rpm

rpm is a package management command used by a number of different Linux distributions. The following tips and tricks should work at any of these.

Find old packages
To get a date sorted list of all installed packages, do
 rpm -qa --qf "%{INSTALLTIME} %{INSTALLTIME:date} %{NAME} %{VERSION} %{RELEASE}\n" | sort -r
How to get one file from an RPM
To list the contents, do
rpm2cpio sendmail.src.rpm | cpio -t

To extract a file, do (if a path is listed by cpio -t then you must include that path with the filename, do not forget the begining dot)

rpm2cpio sendmail.src.rpm | cpio -ivd FILE_FROM_LIST
See the RPM changelog
Almost all RPM:s have a changelog, that can be accessed with
rpm -q RPM_FILE --changelog
List all known gpg keys in the rpm database
rpm -q gpg-pubkey --qf '%{name}-%{version}-%{release} --> %{summary}\n'
See the status of the rpm data base
/usr/lib/rpm/rpmdb_stat -ch /var/lib/rpm

yum

yum is a utility that can check for, and automatically download, and install, updated rpm packages. More information about yum can be found at http://linux.duke.edu/projects/yum/

Find packages not listed in any of the enabled repositories
yum list extras
Do a localinstall without beeing prompted for a GPG-key
sudo yum shell
> config gpgcheck 0
> localinstall download/bla_bla_1.1-1.i386.rpm
> run
> quit