[RHEL6 PATCH] internal: properly define %{dist} and compute correct pkg_release from Makefile

Paolo Bonzini pbonzini at redhat.com
Fri Sep 18 10:19:24 UTC 2009


This third patch, on top of the two I sent earlier, completes the
changes to the Makefile so that they support brew.  The reason is
that while the previous patch added the targets, there are still
differences between the RHEL5 and RHEL6 spec templates so that the
RHEL6 Makefile did not behave properly.

The changes here are threefold, but difficult to separate further:

- compute the correct value of %{pkg_release} (and hence the name of
the build srpm) from the Makefile.

- I also made the buildid come at the end, after the %{dist}, for
consistency with RHEL5

- finally, I allowed the RHEL build to define its %{dist} instead
of always taking it from the environment.

With this patch in place, I finally was able to start a brew build
with "make rh-brew".
---
 redhat/Makefile             |   21 +++++++++++----------
 redhat/Makefile.common      |    5 +++--
 redhat/create-patches.sh    |    2 ++
 redhat/kernel.spec.template |    7 ++++---
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/redhat/Makefile b/redhat/Makefile
index 91d838f..71770fa 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -11,21 +11,22 @@ BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET)
 #BUILD_TARGET ?= $(BUILD_DEFAULT_TARGET)
 #endif
 
-BUILDID:=$(shell sed -ne 's/^[^\#]*define buildid \(.*\)/\1/p' $(REDHAT)/$(SPECFILE).template)
-RELEASE:=$(shell sed -ne 's/^[^\#]*define release \(.*\)%.*%.*/\1/p' $(REDHAT)/$(SPECFILE).template)
-DIST:=$(shell sed -ne 's/^[^\#]*define dist \(.*\)/\1/p' $(REDHAT)/$(SPECFILE).template)
+RELEASE:=$(BUILD)$(if $(RCREV),.rc$(RCREV),)
 
-ifeq ($(BUILDID),)
+ifeq ($(origin BUILDID),undefined)
 ifneq ($(wildcard $(LOCVERFILE)),)
 BUILDID:=$(shell cat $(LOCVERFILE))
 $(info Using LOCALVERSION buildid "$(BUILDID)")
-else
+else # no localversion
+BUILDID:=$(shell sed -ne 's/^[^\#]*define buildid \(.*\)/\1/p' $(REDHAT)/$(SPECFILE).template)
+ifneq ($(BUILDID),)
+$(info Using SPECFILE buildid "$(BUILDID)")
+else # not in spec
 BUILDID:=.test
 $(info Using default buildid "$(BUILDID)". Specify one in "localversion" file if you want.)
-endif
-else
-$(info Using SPECFILE buildid "$(BUILDID)")
-endif
+endif # not in spec
+endif # no localversion
+endif # not on commandline
 
 rh-configs:
 	cd $(REDHAT)/configs; $(MAKE) VERSION=$(KVERSION) configs
@@ -81,7 +82,7 @@ sources-rh: $(TARBALL) $(RC_PATCH) $(GIT_PATCH)
 	@diff $(TESTPATCH).tmp $(TESTPATCH) > /dev/null || \
 		echo "WARNING: There are uncommitted changes in your tree or the changes are not in sync with the kernel-test.patch.  Either commit the changes or run 'make rh-test-patch'"
 	@rm $(TESTPATCH).tmp
-	@$(REDHAT)/create-patches.sh $(MARKER) $(SOURCES) $(SOURCES)/$(SPECFILE) $(BUILD)
+	@$(REDHAT)/create-patches.sh $(MARKER) $(SOURCES) $(SOURCES)/$(SPECFILE) $(BUILD) $(DIST)
 	@cp $(SOURCES)/$(SPECFILE) $(SOURCES)/../SPECS
 	@cp $(TESTPATCH) $(SOURCES)/linux-kernel-test.patch
 	@cp configs/Makefile $(SOURCES)/Makefile.config
diff --git a/redhat/Makefile.common b/redhat/Makefile.common
index b926bf5..e5ec9c1 100644
--- a/redhat/Makefile.common
+++ b/redhat/Makefile.common
@@ -1,14 +1,15 @@
 RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
                    else echo rpm; fi)
 MACH :=  $(shell uname -m)
-KVERSION:=2.6.30
+KVERSION:=2.6.31
 # marker is git tag
-MARKER:=v2.6.31-rc5-git2
+MARKER:=v2.6.31
 SPECFILE:=kernel.spec
 REDHAT:=$(CURDIR)
 RPM:=$(REDHAT)/rpm
 SRPMS:=$(RPM)/SRPMS
 SOURCES:=$(RPM)/SOURCES
+DIST:=.el6
 BUILD:=1
 #TARFILE:=$(subst _,.,$(MARKER)).tar.bz2
 TARFILE:=linux-$(KVERSION).tar.bz2
diff --git a/redhat/create-patches.sh b/redhat/create-patches.sh
index 2c9cf62..8bef8ad 100755
--- a/redhat/create-patches.sh
+++ b/redhat/create-patches.sh
@@ -4,6 +4,7 @@ MARKER=$1
 SOURCES=$2
 SPECFILE=$3
 BUILD=$4
+DIST=$5
 PATCHF="$SOURCES/Patch.include"
 patchf="$SOURCES/patch.include"
 SERIESF="$SOURCES/series"
@@ -195,6 +196,7 @@ test -n "$SPECFILE" &&
 	/%%CHANGELOG%%/r $clogf.rev
 	/%%CHANGELOG%%/d
 	s/%%BUILD%%/$BUILD/
+	s/%%DIST%%/$DIST/
 	s/%%SUBLEVEL%%/$SUBLEVEL/
 	s/%%RCREV%%/$RCREV/
 	s/%%GITREV%%/$GITREV/
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template
index cbe88e4..bbe1369 100644
--- a/redhat/kernel.spec.template
+++ b/redhat/kernel.spec.template
@@ -15,10 +15,11 @@ Summary: The Linux kernel
 # that the kernel isn't the stock distribution kernel, for example,
 # by setting the define to ".local" or ".bz123456"
 #
-# % define buildid .local
+#% define buildid .local
 
 %define rhel 1
 %if %{rhel}
+%define dist %%DIST%%
 %define distro_build %%BUILD%%
 %define signmodules 1
 %else
@@ -154,7 +155,7 @@ Summary: The Linux kernel
 %if 0%{?stable_rc}
 %define stable_rctag .rc%{stable_rc}
 %endif
-%define pkg_release %{distro_build}%{?stable_rctag}%{?buildid}%{?dist}
+%define pkg_release %{distro_build}%{?stable_rctag}%{?dist}%{?buildid}
 
 %else
 
@@ -168,7 +169,7 @@ Summary: The Linux kernel
 %define rctag .rc0
 %endif
 %endif
-%define pkg_release 0.%{distro_build}%{?rctag}%{?gittag}%{?buildid}%{?dist}
+%define pkg_release 0.%{distro_build}%{?rctag}%{?gittag}%{?dist}%{?buildid}
 
 %endif
 
-- 
1.6.2.5




More information about the Fedora-kernel-list mailing list