Spinning kernel-vanilla packages via standard spec

Roland McGrath roland at redhat.com
Fri Mar 30 22:11:39 UTC 2007


> It is. And I was under the impression that's what Dave was thinking too, 
> but I'll let him speak for himself.

Well, do we want it in the package set?  I figured we were talking about
"informal" builds that might be put up for ftp, but not be an integrated
part of the Fedora world.  If one rpmbuild from the spec kicks out -vanilla
packages along with other variants, and we turn that on only for rawhide,
still it winds up "in the system", people install it as "normal" and wind
up with upgrade issues and all that.  Eventually we have clueless Fedora
users saying "you use -PAE? well -vanilla is the Fedora kernel I like best!"
and reporting in bugs "why this fix isn't in -vanilla too?"

It's easy to tweak my changes to put "vanilla" into %name instead of
%release.  I went with "kernel" and a long, funky %release because that's
the tradition I've experienced for one-off and test builds people
distribute.  From my own experience juggling a dozen installations on two
or three test boxes with many hack kernels installed each in an utterly
disorganized fashion, it seems more likely to get resolved usefully when
doing upgrades and such than an rpm named "kernel-foobar".  That is, yum
and rpm will get in your face all the time in the way that people are used
to for juggling kernel rpms.  (Also, I always shudder in superstitious fear
that yum or who knows what will assume things about the kernel rpm being
the way it always has been.)

With whatever name, separate vanilla builds could easily be made usable as
their own little yum repository.

What is more work, and I think is more dubious, is having it be the same
srpm that produces both fedora and vanilla builds.  What will -bp do, make
two source trees patched differently?

> > That requires
> > basically duplicating all the innards of the spec file.  I don't think that
> > should be attempted without a complete cleanup of the spec file to become
> > sane.
> 
> More specifically, what I had in mind was to add just one more variant, 
> so you'd have kernel, kernel-xen, kernel-kdump, kernel-PAE, etc., plus 
> now a kernel-vanilla, which would be analogous to kernel minus patches 
> -- i.e., don't bother with kernel-vanilla-xen, kernel-vanilla-kudmp, etc.

That's no fun!  Seriously, I think we need the full suite of variants
(modulo xen until that's uptsream, etc.) for it really to be useful.
Plenty of people are using -PAE and the point is to compare the foo you're
using to foo-vanilla on a one-to-one basis, i.e. different source, same
.config settings.  And you want -debuginfo for all of those too.

> Not to say that a spec file sanitization/sane-itization wouldn't be good 
> to do as well (which I'm also perfectly willing to take on -- a few 
> steps in this direction were taken earlier today).

I despise how much duplication there is in there.  The debuginfo stuff I
originally did with rpm macros got hand-expanded because older rpmbuild
couldn't cope with it.  Maybe nowadays there is nothing with an rpmbuild
older than FC-5 we are trying to work with, so we could use more macros for
new stuff.  (I think brew got fixed to use the buildroot's rpmbuild, so
anything that's fine for the target systems sharing the kernel spec source
should be fine.)  rpm macros are a hairy mess, but cleaning things up with
clean new macros is a better bet than anything else, IMHO.

> Cool, I'll read your patch more carefully now. :)

Here's the current version of it.  You still need the nonintconfig patch
variant I posted last time to go with this.  I also attached below the
shell script used by the GIT-using hacks that are in this version.
http://porkchop.devel.redhat.com/brewroot/scratch/roland/task_703101/ shows
what "make git/roland/scratch-build" does (the build magic works for "make
git/roland-fedora/..." too, but the fedora patches don't apply to current
upstream so it didn't build).  This (the non-fedora flavor) is similar to
the vanilla build, but automagically prepends:

%changelog
* Thu Mar 29 2007 Roland McGrath <roland at redhat.com>
- Experimental build from git sources (no Fedora patches)
- git tag:    v2.6.21-rc5             6fb04ccf5c5e054c4107090bed6e866489f1089f
- git branch: upstream                28defbea64622f69d65a6079bf800cedb9915a5f
- git branch: roland                  0ca00c859e7ac4d9d053abd06376233cb4f3bf84

and includes:

Patch1: patch-2.6.21-rc5.bz2
Patch2: linux-2.6.21-rc5-upstream.patch
Patch3: linux-2.6.21-rc5-roland.patch


Thanks,
Roland


Index: Makefile
===================================================================
RCS file: /cvs/dist/rpms/kernel/devel/Makefile,v
retrieving revision 1.45
diff -u -B -p -r1.45 Makefile
--- Makefile	19 Mar 2007 21:32:30 -0000	1.45
+++ Makefile	30 Mar 2007 21:45:57 -0000
@@ -68,3 +68,119 @@ reconfig:
 
 # since i386 isn't a target...
 compile compile-short: DIST_DEFINES += --target $(shell uname -m)
+
+#
+# Hacks for building vanilla (unpatched) kernel rpms.
+# Use "make vanilla-TARGET" like "make TARGET" (make vanilla-scratch-build).
+#
+vanilla-%: $(SPECFILE:.spec=-vanilla.spec)
+	@$(MAKE) $* SPECFILE=$<
+
+$(SPECFILE:.spec=-vanilla.spec): $(SPECFILE)
+	@rm -f $@
+	(echo %define nopatches 1; cat $<) > $@
+
+scratch-build: test-srpm
+	$(BUILD_CLIENT) $(BUILD_FLAGS) --scratch $(COLLECTION) \
+			$(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
+
+# Dismal kludge for building via brew from cvs after "make vanilla-tag".
+ifdef BEEHIVE_SRPM_BUILD
+export CHECKOUT_TAG ?= $(shell sed s/^.// CVS/Tag)
+tag-pattern = $(TAG_NAME)-$(TAG_VERSION)-0_%_$(TAG_RELEASE)
+ifeq (,$(filter-out $(tag-pattern),$(CHECKOUT_TAG)))
+variant := $(patsubst $(tag-pattern),%,$(CHECKOUT_TAG))
+srpm: SPECFILE := $(wildcard $(SPECFILE:.spec=-$(variant).spec) \
+			     $(SPECFILE:.spec=-t.$(variant).spec))
+srpm beehive-sprm: RELEASE := 0.$(variant).$(RELEASE)
+endif
+endif
+
+
+#
+# Hacks for building kernel rpms from upstream code plus local GIT branches.
+# Use "make git/BRANCH/TARGET" like "make TARGET".
+# Use "make git/BRANCH-fedora/TARGET" to include Fedora patches on top.
+#
+ifndef GIT_SPEC
+git/%:
+	@$(MAKE) GIT_SPEC=$(subst /,-,$(*D)) git-$(*F)
+else
+git-%: $(SPECFILE:.spec=-t.$(GIT_SPEC).spec)
+	@$(MAKE) GIT_SPEC= $* SPECFILE=$<
+endif
+
+#
+# Your git-branches.mk file can define GIT_DIR, e.g.:
+#	GIT_DIR = ${HOME}/kernel/.git
+# Make sure GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL are also set
+# or your rpm changelogs will look like crap.
+#
+# For each branch it can define a variable branch-BRANCH or tag-BRANCH
+# giving the parent of BRANCH to diff against in a separate patch.  If
+# the parent is unknown, it will use $(branch-upstream) defaulting to
+# "upstream".
+#
+# Defining tag-BRANCH means the tag corresponds to an upstream patch in
+# the sources file, so that is used instead of generating a patch with
+# git.  If there is no tag-upstream defined, it will figure out a vNNN
+# tag or vNNN-gitN pseudo-tag from the last patch in the sources file.
+# For example:
+#	tag-some-hacks = v2.6.21-rc5
+#	branch-more-hacks = first-hacks
+# Leads to patches:
+#	git diff v2.6.21-rc5..more-hacks > linux-2.6.21-rc5-some-hacks.patch
+#	git diff some-hacks..more-hacks > linux-2.6.21-rc5-more-hacks.patch
+# Whereas having no git-branches.mk at all but doing
+# "make GIT_DIR=... git/mybranch/test-srpm" does:
+#	id=`cat patch-2.6.21-rc5-git4.id` # auto-fetched via upstream file
+#	git diff $id..upstream > linux-2.6.21-rc5-git4-upstream.patch
+#	git diff upstream..mybranch > linux-2.6.21-rc5-git4-mybranch.patch
+# If the upstream patch (or any branch patch) is empty it's left out.
+#
+git-branches.mk:;
+-include git-branches.mk
+
+branch-upstream ?= upstream
+
+ifdef GIT_DIR
+export GIT_DIR
+export GIT_AUTHOR_NAME
+export GIT_AUTHOR_EMAIL
+gen-patches ?= gen-patches
+
+ifndef havespec
+$(SPECFILE:.spec=-t.%-fedora.spec): $(SPECFILE) $(gen-patches) FORCE
+	./$(gen-patches) --fedora < $< > $@ $(gen-patches-args)
+$(SPECFILE:.spec=-t.%.spec): $(SPECFILE) $(gen-patches) FORCE
+	./$(gen-patches) < $< > $@ $(gen-patches-args)
+.PRECIOUS: $(SPECFILE:.spec=-t.%.spec) $(SPECFILE:.spec=-t.%-fedora.spec)
+endif
+
+spec-%: $(SPECFILE:.spec=-t.%.spec) ;
+$(SPECFILE):;
+FORCE:;
+
+gen-patches-args = ${srcdir} v$(VERSION) $(call heads,$*)
+define heads
+$(if $(tag-$1),$(filter-out v$(VERSION),$(tag-$1)),\
+     $(call heads,$(firstword $(branch-$1) $(branch-upstream)))) $1
+endef
+
+files-%-fedora:
+	@echo $(SPECFILE:.spec=-t.$*-fedora.spec)
+	@$(call list-patches,$*)
+files-%:
+	@echo $(SPECFILE:.spec=-t.$*.spec)
+	@$(call list-patches,$*)
+define list-patches
+$(if $(tag-$1),version=$(patsubst v%,%,$(tag-$1)),\
+     $(call list-patches,$(firstword $(branch-$1) $(branch-upstream)))); \
+echo linux-$${version}-$1.patch
+endef
+
+ifndef tag-$(branch-upstream)
+tag-$(branch-upstream) := $(shell \
+	sed -n 's/^.*  *//;s/\.bz2$$//;s/patch-/v/p' sources)
+endif
+endif
Index: kernel-2.6.spec
===================================================================
RCS file: /cvs/dist/rpms/kernel/devel/kernel-2.6.spec,v
retrieving revision 1.3025
diff -u -B -p -r1.3025 kernel-2.6.spec
--- kernel-2.6.spec	29 Mar 2007 00:00:55 -0000	1.3025
+++ kernel-2.6.spec	30 Mar 2007 21:45:57 -0000
@@ -32,7 +32,8 @@ Summary: The Linux kernel (the core of t
 %define sublevel 20
 %define kversion 2.6.%{sublevel}
 %define rpmversion 2.6.%{sublevel}
-%define release %(R="$Revision: 1.3025 $"; RR="${R##: }"; echo ${RR%%?})%{?dist}
+%define specrelease %(R="$Revision: 1.3025 $"; RR="${R##: }"; echo ${RR%%?})%{?dist}
+%define release %{specrelease}
 
 %define make_target bzImage
 %define kernel_image x86
@@ -45,6 +46,28 @@ Summary: The Linux kernel (the core of t
 %define KVERREL %{PACKAGE_VERSION}-%{PACKAGE_RELEASE}
 %define hdrarch %_target_cpu
 
+%if 0%{!?nopatches:1}
+%define nopatches 0
+%endif
+
+%if %{nopatches}
+%define includexen 0
+%else
+%define relsuffix .fedora
+%endif
+
+%define using_upstream_branch 0
+%if 0%{?upstream_branch:1}
+%define using_upstream_branch 1
+%define release 0.%{upstream_branch}%{?relsuffix}.%{specrelease}
+%define buildxen 0
+%define buildxenPAE 0
+%else
+%if %{nopatches}
+%define release 0.vanilla.%{specrelease}
+%endif
+%endif
+
 # groups of related archs
 #OLPC stuff
 %if 0%{?olpc}
@@ -169,6 +192,15 @@ Summary: The Linux kernel (the core of t
 %define xen_image vmlinux.gz
 %endif
 
+%if %{nopatches}
+%define signmodules 0
+# Ignore unknown options in our config-* files.
+# Some options go with patches we're not applying.
+%define oldconfig_target loose_nonint_oldconfig
+%else
+%define oldconfig_target nonint_oldconfig
+%endif
+
 # To temporarily exclude an architecture from being built, add it to
 # %nobuildarches. Do _NOT_ use the ExclusiveArch: line, because if we
 # don't build kernel-headers then the new build system will no longer let
@@ -304,7 +336,15 @@ Source82: config-olpc-generic
 #
 # Patches 0 through 100 are meant for core subsystem upgrades
 #
+
+%if %{using_upstream_branch}
+### BRANCH PATCH ###
+%else
+# Here should be only the patches up to the upstream canonical Linus tree.
 Patch1: patch-2.6.21-rc5.bz2
+%endif
+
+%if !%{nopatches}
 Patch3: git-geode.patch
 
 # Patches 10 through 99 are for things that are going upstream really soon.
@@ -360,7 +400,9 @@ Patch341: linux-2.6-mpc52xx-fec.patch
 # Patches 800 through 899 are reserved for bugfixes to the core system
 # and patches related to how RPMs are build
 #
-Patch800: linux-2.6-build-nonintconfig.patch
+%endif
+Patch800: linux-2.6.17-nonintconfig.patch
+%if !%{nopatches}
 
 # Exec-shield.
 Patch810: linux-2.6-execshield.patch
@@ -495,6 +537,7 @@ Patch20001: xen-11668-hvm_disable_fix.pa
 Patch20002: xen-dom0-reboot.patch
 
 # END OF PATCH DEFINITIONS
+%endif
 
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root-%{_target_cpu}
 
@@ -867,9 +910,16 @@ cp -rl vanilla linux-%{kversion}.%{_targ
 
 cd linux-%{kversion}.%{_target_cpu}
 
+%if %{using_upstream_branch}
+### BRANCH APPLY ###
+%else
+
 # Update to latest upstream.
 %patch1 -p1
 
+%endif
+%if !%{nopatches}
+
 # Patches 10 through 100 are meant for core subsystem upgrades
 
 # Roland's utrace ptrace replacement.
@@ -945,13 +995,14 @@ cd linux-%{kversion}.%{_target_cpu}
 # Patches 800 through 899 are reserved for bugfixes to the core system
 # and patches related to how RPMs are build
 #
-
+%endif
 
 # This patch adds a "make nonint_oldconfig" which is non-interactive and
 # also gives a list of missing options at the end. Useful for automated
 # builds (as used in the buildsystem).
 %patch800 -p1
 
+%if !%{nopatches}
 # Exec shield
 %patch810 -p1
 
@@ -1171,6 +1222,7 @@ mv drivers/xen/blktap/blktap.c drivers/x
 %patch10001 -p1
 
 # END OF PATCH APPLICATIONS
+%endif
 
 cp %{SOURCE10} Documentation/
 
@@ -1201,7 +1253,7 @@ for i in *.config
 do
   mv $i .config
   Arch=`head -1 .config | cut -b 3-`
-  make ARCH=$Arch nonint_oldconfig > /dev/null
+  make ARCH=$Arch %{oldconfig_target} > /dev/null
   echo "# $Arch" > configs/$i
   cat .config >> configs/$i
 done
@@ -1295,7 +1347,7 @@ BuildKernel() {
        KernelImage=arch/$Arch/boot/bzImage
     fi
 
-    make -s ARCH=$Arch nonint_oldconfig > /dev/null
+    make -s ARCH=$Arch %{oldconfig_target} > /dev/null
     make -s ARCH=$Arch %{?_smp_mflags} $MakeTarget %{?sparse_mflags}
     make -s ARCH=$Arch %{?_smp_mflags} modules %{?sparse_mflags} || exit 1
 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gen-patches
URL: <http://listman.redhat.com/archives/fedora-kernel-list/attachments/20070330/3a27a47b/attachment.ksh>


More information about the Fedora-kernel-list mailing list