1. RPM Shell Notes
Listed here are a few shell scripts to make certain RPM features more accessible. This could probably be done with popt, but I haven't invested the time in learning it.
1.0.1. rpmwhich
I found myself repeated using rpm -qf `which foo` to find the package owning /usr/bin/foo (or other places in my $PATH). So I wrote a little function to make it easier. It is a shell function so put this in your ~/.bashrc:
function rpmwhich {
for f in $*; do
ff=$(which $f 2>/dev/null)
if [ -n "$ff" ]; then
printf "%s: " $ff
rpm -qf $ff
else
printf "'%s' not found!\n" $f
fi
done
}
1.0.2. rpmrm
Remove source and spec files with fewer keystrokes. Shell alias; add to ~/.bashrc:
alias rpmrm='rpmbuild --rmsource --rmspec '
1.0.3. getspec
Extract the .spec file from a source RPM.
function getspec { rpm2cpio $1 | cpio -div '*.spec' }
1.0.4. getsrc
Extract the main source from a source RPM.
function getsrc { rpm2cpio $1 | cpio -div '*.tar.gz' }
1.0.5. getpatches
Extract patches from a source RPM.
function getpatches { rpm2cpio $1 | cpio -div '*.patch' }
1.0.6. rpmdump
Extract the contents of a source or binary RPM.
function rpmdump { rpm2cpio $1 | (mkdir ${1%.rpm} && cd ${1%.rpm} && cpio -div) }
See also:
