[RFC PATCH] Add a 'minimal tree install' target

Previous thread: CFS: some bad numbers with Java/database threading by Antoine Martin on Wednesday, September 12, 2007 - 7:10 pm. (32 messages)

Next thread: [PATCH] xen: don't bother trying to set cr4 by Jeremy Fitzhardinge on Wednesday, September 12, 2007 - 7:44 pm. (1 message)
To: LKML <linux-kernel@...>
Cc: <davej@...>, Sam Ravnborg <sam@...>, Eric Sandeen <sandeen@...>
Date: Wednesday, September 12, 2007 - 7:25 pm

This is a somewhat rough first-pass at making a 'minimal tree'
installation target. This installs a partial source-tree which you
can use to build external modules against. It feels pretty unclean
but I'm not aware of a much better way to do some of this.

This patch works for me, even when using O=<buildtree>. It probably
needs further cleanups.

Comments?

-----
Add a 'mintree-install' makefile target.

Red Hat and other distributions typically have some logic in their
kernel package build system to create/install 'minimalist source tree'
which contains enough state to build external modules against but is
much smaller than the entire build-tree.

This introduces similar logic, the guts of this was taken from a
Fedora Core spec file and mutilated to make it work for O=<...>
builds.
-----

diff --git a/Makefile b/Makefile
index 3067f6a..1246939 100644
--- a/Makefile
+++ b/Makefile
@@ -1085,6 +1085,11 @@ package-dir := $(srctree)/scripts/package
$(Q)$(MAKE) $(build)=$(package-dir) $@
rpm: include/config/kernel.release FORCE
$(Q)$(MAKE) $(build)=$(package-dir) $@
+# /usr/src/linux to match what most distro's do
+#export INSTALL_MINTREE_PATH ?= /usr/src/linux
+export INSTALL_MINTREE_PATH ?= /tmp/mt-test/
+mintree-install: include/config/kernel.release FORCE
+ $(Q)$(MAKE) $(build)=$(package-dir) $@

# Brief documentation of the typical targets used
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 7c434e0..0c5f07d 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -86,6 +86,12 @@ tar%pkg: FORCE
clean-dirs += $(objtree)/tar-install/

+# minimal tree installation target
+# ---------------------------------------------------------------------------
+mintree-install: FORCE
+ $(MAKE) KBUILD_SRC=
+ $(CONFIG_SHELL) $(srctree)/scripts/package/mintree-install
+
# Help text displayed when executing 'make help'
# ---------------------------------------------------------------------------
help: FORCE...

To: Chris Wedgwood <cw@...>
Cc: LKML <linux-kernel@...>, <davej@...>, Sam Ravnborg <sam@...>, Eric Sandeen <sandeen@...>
Date: Friday, September 14, 2007 - 12:44 pm

Ever looked at the debian packages and how they do it? They even split
out common files and specific files from the kernel build. Saves some
space if you build multiple flavours of the same kernel version.

MfG
Goswin
-

To: Chris Wedgwood <cw@...>
Cc: LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Thursday, September 13, 2007 - 2:34 pm

Hi Chris.

A few. Please address them and resubmit with full changelog and
proper attribution (if possible) and a signed-of-by.

I would strongly prefer the name "build-pkg".
The prefix -pkg is just to use the magic in top-level Makefile to

I would like to attribute whoever made this somehow.

Here we could do a $(MAKE) KBUILD_SRC= clean
This will leave all files needed for building external modules

Could we pass this as parameters. This makes it explicit.
You do not need to check them since this script is not
^
Why this wildcard??? (objtree/>*<Makefile)
Something less hardcoded are preferred. Maybe like:
Here we use readlink but in next line we use $ARCH.
Too hardcoded.
Here we could use some sed magic to extract a potential ALTARCH from asm-${ARCH}/Kbuild
This part I did not check up on - I assume it is correct.

Sam
-

To: Sam Ravnborg <sam@...>
Cc: LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Thursday, September 13, 2007 - 2:57 pm

yeah, i had something a bit like originally but didn't like the name

so would i, i assume it was davej + others so i cc'd him on this

no, it's so we catch things like

linux/build/Makefile

*and*

right, actually, it can be uncommented but the 'make help' fails; i'm
not sure if we need make help to work since most of the other targets
won't anyhow

ok (though i'm not a big fan of ls | grep as a rule, it tends to be

i tried to preserve as much logic as possible from the original
script, at least initially

what about something like?

sed -n "s/^ALTARCH[[:space:]]:=[[:space:]]\(.*$\)\+/\1/p"

it all seems to work
-

To: Chris Wedgwood <cw@...>
Cc: Sam Ravnborg <sam@...>, LKML <linux-kernel@...>, Eric Sandeen <sandeen@...>
Date: Thursday, September 13, 2007 - 7:27 pm

On Thu, Sep 13, 2007 at 11:57:53AM -0700, Chris Wedgwood wrote:

> > I would like to attribute whoever made this somehow.
>
> so would i, i assume it was davej + others so i cc'd him on this
> hoping for feedback

90%+ of that part of the fedora specfile was Arjan's doings,
myself, dwmw2 and Jarod Wilson have poked at it since then,
but in mostly minor ways.

FWIW, I'd love to see this become a generic upstream target that
I could just use in the Fedora specfile.
The question I have is whether other distros do anything differently
that might be worth taking into consideration?

Dave

--
http://www.codemonkey.org.uk
-

To: Chris Wedgwood <cw@...>, Oleg Verych <olecom@...>
Cc: LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Thursday, September 13, 2007 - 3:19 pm

Hi Chris.

Obviously - I missed the find when I looked.
Thanks for the explanation. And no comments needed in the script -

find . -maxdepth 1 -! -name 'asm*'

Oleg (added to mail) - you are quite confident in sed et al.
Let us know if there is a simpler way.

(We want to pick i386 from include/asm-x86_64/Kbuild
and similar for the architectures that uses ARCHDEF).

Sam
-

To: Sam Ravnborg <sam@...>
Cc: Chris Wedgwood <cw@...>, LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Thursday, September 13, 2007 - 4:17 pm

Hallo.

On Thu, Sep 13, 2007 at 09:19:38PM +0200, Sam Ravnborg wrote:

That particular one-line `ALTARCH := i386' of course can be matched
simpler, because there's only *one* (as written above) whitespace and no
make's assignment variations, like (?=,=). I wonder, if there can be more
options, than i386 and more occurrences of `ALTARCH' actually :) Also,
make can have lead whitespace on line start, as well as near assignment
sign, if that matters.

So, to match *one* line with *one* `ALTARCH' followed by `i386'

sed -n '/ALTARCH/{/i386/{p ; q}}'

is fine by me. If there are dis-assignments, so to speak, or comments
with i386 this will not work obviously. But it's fast and must work
with variety of make syntax. Check is "for non empty output".

Also, please take a look on man isspace(). It matches much more
characters, than necessary for ordinary syntax whitespace. Using
[:blank:] (i.e. tab and space, with no options) is OK. Last thing: i'm not
sure, what that `+' is. I stick to BRE in sed, as it should be, so just
don't know what it does.

Hope that helps.
____
-

To: Oleg Verych <olecom@...>
Cc: Sam Ravnborg <sam@...>, LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Thursday, September 13, 2007 - 4:05 pm

The \+ was misplaced :-) I typed that very quickly and didn't think to
hard.
-

To: Chris Wedgwood <cw@...>
Cc: Sam Ravnborg <sam@...>, LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Friday, September 14, 2007 - 6:04 am

printf "C=i386\n ALTARCH = i386
ALTARCH= i386
ALTARCH :=i386
A=i386
ALTARCH := i386
ALTARCH?=i386
" | sed -n '
/^[[:blank:]]*ALTARCH[^?]*=/{
/[[:blank:]:]*=[[:blank:]]*i386[[:blank:]]*$/{
s_.*_i386_;=;p;
}
}'

Maybe this one then, to much as much valid assigments as possible :)
____
-

To: Sam Ravnborg <sam@...>
Cc: Chris Wedgwood <cw@...>, LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Thursday, September 13, 2007 - 2:37 pm

what about "devel-pkg" instead? that would match fedora's
"kernel-devel" naming convention.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
-

To: Robert P. J. Day <rpjday@...>
Cc: Chris Wedgwood <cw@...>, LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Thursday, September 13, 2007 - 3:26 pm

Does
make devel-pkg
in the kernel make you think:
"This is a minimum package to build an external module".

I guess not.

I suggested "build-pkg" from the rationale that this is a package
used when building something.
Any better suggestions within the context of the kernel are galdly
received.

Sam
-

To: Sam Ravnborg <sam@...>
Cc: Robert P. J. Day <rpjday@...>, Chris Wedgwood <cw@...>, LKML <linux-kernel@...>, <davej@...>, Eric Sandeen <sandeen@...>
Date: Friday, September 14, 2007 - 5:59 am

=46rom an rpm-based distribution background, it does, actually.
You typically have to install a "xyzzy-devel" package before
you can compile something related to "xyzzy", so it is quite
natural to look for a "kernel-devel" package providing
whatever is necessary to build kernel modules; and
"cd kernel ; make devel-pkg" reads almost literally like
"make kernel-devel.rpm".

--=20
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Unge=F6ffnet mindestens haltbar bis: (siehe R=FCckseite)

Previous thread: CFS: some bad numbers with Java/database threading by Antoine Martin on Wednesday, September 12, 2007 - 7:10 pm. (32 messages)

Next thread: [PATCH] xen: don't bother trying to set cr4 by Jeremy Fitzhardinge on Wednesday, September 12, 2007 - 7:44 pm. (1 message)