The usual IT babble
Posts tagged RPM
RPM: Query a specific rpm-file for information
Oct 28th
Since I end up googling it each time I need this, it’s about time I write it down … If you want to query a specific RPM for information (Requires/Information/…) you’ll need to use the –package/-p option.
-p <file> — Query a Specific RPM Package File
Up to now, every means of specifying a package to an RPM query focused on packages that had already been installed. While it’s certainly very useful to be able to dredge up information about packages that are already on your system, what about packages that haven’t yet been installed? The -p option can do that for you.
So, if I wanted to show the Requires of my vmware-tools-kmp:
rpm -qR -p vmware-tools-kmp-default-3.5.0_184236_2.6.16.60_0.21-0.5.i586.rpm
KMP: Define a new subpkg template
Oct 24th
There might be reasons, you’d wish you could make the kernel module package do other things. Two already pop into my head: 1) The mpp-Image upgrades for the ibm-rdac kernel module packages and 2) the “adjustments” which need to be done post install for the VMware kernel module package in /etc/vmware-tools/locations.
What you basically do is this:
- Add the new subpkg template to your sources list
- Call the %suse_kernel_module_package macro with the option -s and then add your source number
For me this looks like this:
...
Source4: vmxnet.tar
Source5: preamble
Source6: subpkg
...
%suse_kernel_module_package -p %{S:5} -s %{S:6} umAfter that, you just need to copy over /usr/lib/rpm/rpm-suse-kernel-module-subpackage to /usr/src/packages/SOURCES/subpkg and make your adjustments to that copy.
For example the diff between those two could look like this:
--- /usr/lib/rpm/rpm-suse-kernel-module-subpackage +++ /usr/src/packages/SOURCES/subpkg @@ -20,8 +20,8 @@ ' $spec ) Provides: %{-n*} = %(echo %{-v*}-%3 | tr - _) -Requires: kernel-%1 -AutoReqProv: on +Requires: kernel-%1 = %( echo %2 | sed "s,-%1,," ) +AutoReqProv: off %{-p:%{expand:%(cd %_sourcedir; cat %{-p*})}} %description -n %{-n*}-%1 %( @@ -77,6 +77,21 @@ done fi fi +if [ -f /etc/vmware-tools/locations ] ; then + for kmodule in ${modules[@]}; do + echo "file $kmodule $( stat -c %Y $kmodule )" \ + >> /etc/vmware-tools/locations + echo "file $( echo $kmodule | \ + sed -e "s,.ko,.o," -e "s,updates,misc," )" \ + >> /etc/vmware-tools/locations + echo "answer $( echo ${kmodule##*/} | sed -e "s,.ko,," | \ + tr '[:lower:]' '[:upper:]' )_CONFED yes" \ + >> /etc/vmware-tools/locations + done + + [ -f /etc/vmware-tools/not_configured ] && \ + rm -f /etc/vmware-tools/not_configured +fi %{-i:%{expand:%(cd %_sourcedir; cat %{-i*})}} %preun -n %{-n*}-%1 version=%(echo %{-v*}-%3 | tr - _) @@ -116,8 +131,29 @@ done fi fi +if [ -f /etc/vmware-tools/locations ] ; then + for kmodule in ${modules[@]}; do + MOD="$( echo ${kmodule##*/} | sed -e "s,.ko,," | \ + tr '[:lower:]' '[:upper:]' )_CONFED yes" + [ -n "$( grep "$MOD" /etc/vmware-tools/locations )" ] && \ + sed -i "/$MOD/d" /etc/vmware-tools/locations + + [ -n "$( grep "file $kmodule" /etc/vmware-tools/locations )" ] && \ + sed -i "/file ${kmodule//\//\\/}.*/d" /etc/vmware-tools/locations + + MOD="$( echo $kmodule | sed -e "s,.ko,.o," -e "s,updates,misc," )" + [ -n "$( grep "file $MOD" /etc/vmware-tools/locations )" ] && \ + sed -i "/file $( echo $MOD | sed -e "s,/,\\\/,g" )/d" \ + /etc/vmware-tools/locations + done + + [ ! -f /etc/vmware-tools/not_configured ] && \ + touch /etc/vmware-tools/not_configured +fi %{-u:%{expand:%(cd %_sourcedir; cat %{-u*})}} %files -n %{-n*}-%1 %{-f:%{expand:%(cd %_sourcedir; cat %{-f*})}} %{!-f:%defattr (-,root,root)} %{!-f:/lib/modules/%2} + +# vim: set syntax=on ft=sh :
This is my final version of the subpkg template and I hopefully demonstrated how powerful a customized subpkg template can be!