Bug 523652 - Build/prep failure when kernel not present in default %{_specdir}
Summary: Build/prep failure when kernel not present in default %{_specdir}
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: kernel
Version: 6.0
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Aristeu Rozanski
QA Contact: Martin Jenner
Depends On:
TreeView+ depends on / blocked
Reported: 2009-09-16 10:56 UTC by Stephen Tweedie
Modified: 2010-04-26 14:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-04-26 14:38:05 UTC

Attachments (Terms of Use)

Description Stephen Tweedie 2009-09-16 10:56:14 UTC
Description of problem:
The kernel spec file always looks for the kernel.spec in the user/system's current %{_specdir} when determining if a Patch: line is present for a file in ApplyPatch().

This causes two problems if the user is trying to build the kernel from a different directory:

* If there is already a kernel build present in the default %{_specdir}, then the ApplyPatch will be checking in the wrong place for the spec file consistency; and

* If there is not a kernel build present in that location, then the build in the non-standard directory will always fail completely on the first ApplyPatch

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

How reproducible:

Steps to Reproduce:
1. Checkout a kernel from CVS
2. Make sure no kernel.spec is present in $HOME/rpmbuild/SPECS/kernel.spec
3. "make prep"
Actual results:
Build fails at first patch with:

+ ApplyPatch linux-2.6-build-nonintconfig.patch
+ local patch=linux-2.6-build-nonintconfig.patch
+ shift
+ '[' '!' -f /tmp/k6/kernel-RHEL-6/kernel/linux-2.6-build-nonintconfig.patch ']'
ERROR: Patch  linux-2.6-build-nonintconfig.patch  not listed as a source patch in specfile
error: Bad exit status from /var/tmp/rpm-tmp.MqmBkw (%prep)

Expected results:

Additional info:
The breaking part of the kernel.spec is here:

  if ! egrep "^Patch[0-9]+: $patch\$" %{_specdir}/${RPM_PACKAGE_NAME%%%%%{?variant}}.spec ; then
    if [ "${patch:0:10}" != "patch-2.6." ] ; then
      echo "ERROR: Patch  $patch  not listed as a source patch in specfile"

where %{_specdir} is not initialised by the kernel CVS Makefile.  This line can never work correctly if we're not building in the standard rpmbuild directory.

The Makefile.common is partly to blame here.  It already passes the correct %{_sourcedir} to the build process:

# RPM with all the overrides in place; you can override this in your
# .cvsdistrc also, to use a default rpm setup
# the rpm build command line
ifndef RPM
RPM := $(shell if test -f /usr/bin/rpmbuild ; then echo rpmbuild ; else echo rpm ; fi)
RPM_WITH_DIRS = $(RPM) --define "_sourcedir $(SOURCEDIR)" \
		--define "_builddir $(BUILDDIR)" \
		--define "_srcrpmdir $(SRCRPMDIR)" \
		--define "_rpmdir $(RPMDIR)"

Adding the line

		--define "_specdir $(SOURCEDIR)" \

to the above fixes the problem for me, but that's not correct for all cases (building from an srpm will install spec and sources to different locations, so we really need a separate $(SPECDIR) here.)  The Fedora F-12 Makefile.common gets it right, with

ifndef SPECDIR
SPECDIR := $(shell pwd)

RPM_DEFINES := --define "_sourcedir $(SOURCEDIR)" \
		--define "_specdir $(SPECDIR)" \
		--define "_builddir $(BUILDDIR)" \
		--define "_srcrpmdir $(SRCRPMDIR)" \
		--define "_rpmdir $(RPMDIR)" \

Comment 2 RHEL Product and Program Management 2009-09-16 11:37:04 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for

Comment 3 Aristeu Rozanski 2010-04-21 17:41:26 UTC
Hm, latest version of Makefile.commonn on ../common has:

## SOURCEDIR is special; it has to match the CVS checkout directory, 
## because the CVS checkout directory contains the patch files. So it basically 
## can't be overridden without breaking things. But we leave it a variable
## for consistency, and in hopes of convincing it to work sometime.
SOURCEDIR := $(shell pwd)
ifndef SPECDIR
SPECDIR := $(shell pwd)                                                                                                                                                                         

ifneq (,$(BRANCHINFO))
DIST_DEFINES := --define "dist $(DIST)" --define "$(DISTVAR) $(DISTVAL)"

RPM_DEFINES ?= --define "_sourcedir $(SOURCEDIR)" \
                --define "_specdir $(SPECDIR)" \
                --define "_builddir $(BUILDDIR)" \
                --define "_srcrpmdir $(SRCRPMDIR)" \
                --define "_rpmdir $(RPMDIR)" \

This is Makefile.common revision 1.211.
Stephen, what version you have there?

Comment 4 Aristeu Rozanski 2010-04-21 17:43:03 UTC
Oh, just noticed the date. Just knew about this bug now. make prep works on the
checkout I just did. Can you confirm if it works for you?

Comment 5 Stephen Tweedie 2010-04-22 10:18:19 UTC
Seems to work fine in current kernel+common, thanks.

Comment 6 Aristeu Rozanski 2010-04-26 14:38:05 UTC
Ok, closing it.

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