Bug 653170 - kmodtool %preun scriptlet fails when uninstalling kmod packages
Summary: kmodtool %preun scriptlet fails when uninstalling kmod packages
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: redhat-rpm-config
Version: 6.0
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Jon Masters
QA Contact: Milos Malik
Depends On:
TreeView+ depends on / blocked
Reported: 2010-11-14 21:25 UTC by Phil Perry
Modified: 2011-02-04 12:52 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2011-02-04 12:52:42 UTC
Target Upstream Version:

Attachments (Terms of Use)

Description Phil Perry 2010-11-14 21:25:02 UTC
Description of problem:
Uninstalling kmod packages built with kmodtool fails due to the %preun scriptlet

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Build a kmod package with kmodtool
2. Install kmod package from step 1
3. Attempt to uninstall kmod package
Actual results:
# rpm -e kmod-hellop
error: ^%{kmod_version}$: regcomp failed: Invalid content of \{\}
error: %preun(kmod-hellop-0.5-1.el6.elrepo.x86_64) scriptlet failed, exit status

Expected results:
The package uninstalls cleanly

Additional info:
The error is due to the %preun scriptlet in kmodtool:

cat <<EOF
%preun         -n kmod-${kmod_name}${dashvariant}
rpm -ql kmod-${kmod_name}${dashvariant}-%{kmod_version}-%{kmod_release}.$(arch) | grep '\.ko$' > /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules

The following code fixes the issue:

cat <<EOF
%preun         -n kmod-${kmod_name}${dashvariant}
rpm -ql kmod-${kmod_name}${dashvariant}-%{version}-%{release}.$(arch) | grep '\.ko$' > /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules

Comment 2 Jon Masters 2010-11-16 17:08:01 UTC
Are you using the %kernel_module_package RPM macro to build your package?

Comment 3 Phil Perry 2010-11-16 22:43:29 UTC
No, I'm just building with rpmbuild as we do on RHEL5:

rpmbuild -ba --target=`uname -m` foo.spec

Looking in the %kernel_module_package RPM macro, I see %{kmod_version} and %{kmod_release} are defined there so that is probably my mistake. Thanks for the heads up.

Comment 4 Jon Masters 2010-11-18 07:27:47 UTC
No problem. I see you pinged me on IRC earlier. I apologize that I missed you. I have been operating on various timezones over the past few days (not physically, just long hours). Please do ping me again Thu or Fri afternoon.

Comment 5 Phil Perry 2010-11-18 19:13:46 UTC
No worries Jon - just wanted to run this past you before filing a bug if you were around.

As I didn't explain very well above, we are still calling kmodtool's rpmtemplate in our SPEC file for RHEL6 builds, much like we did for RHEL5, hence why %{kmod_version} and %{kmod_release} throw up errors when the %preun scriptlet is run.

%{expand:%(%{kmodtool} rpmtemplate %{kmod_name} %{kversion} %{kvariants} 2>/dev/null)}

I hope to get some time this weekend to take a closer look at the %kernel_module_package macro.

Comment 8 Jon Masters 2011-02-04 12:52:42 UTC
I meant to say before, I don't consider this a bug. As I mentioned, those two macros: %kmod_version and %kmod_release are defined as a result of using %kernel_module_package.

We have since spoken by email about RHEL6, and the process of using these macros. So, I'm going to close this bug now and then we can discuss the best way for you to use the RHEL6 macros. If you don't want to switch to %kernel_module_package (yet), then you can of course just define those two macros yourself for now (and for "legacy" RHEL6 packages that already might exist).


Note You need to log in before you can comment on or make changes to this bug.