diff mbox

[3/3] kbuild: add generation of kernel-devel

Message ID 20130624143833.10761.94871.stgit@phlsvslse11.ph.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marciniszyn, Mike June 24, 2013, 2:38 p.m. UTC
Change the spec file to generate a kernel-devel module
allowing for compilation of external kernel modules.

Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
---
 scripts/package/mkspec |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)


--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Michal Marek July 4, 2013, 3:15 p.m. UTC | #1
On 24.6.2013 16:38, Mike Marciniszyn wrote:
> Change the spec file to generate a kernel-devel module
> allowing for compilation of external kernel modules.
> 
> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
> ---
>  scripts/package/mkspec |   26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index 514aeb2..65131df 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -59,6 +59,14 @@ echo "header files define structures and constants that are needed for"
>  echo "building most standard programs and are also needed for rebuilding the"
>  echo "glibc package."
>  echo ""
> +echo "%package devel"
> +echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
> +echo "Group: System Environment/Kernel"
> +echo "AutoReqProv: no"
> +echo "%description -n kernel-devel"
> +echo "This package provides kernel headers and makefiles sufficient to build modules"
> +echo "against the $__KERNELRELEASE kernel package."
> +echo ""
>  
>  if ! $PREBUILT; then
>  echo "%prep"
> @@ -109,6 +117,11 @@ echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
>  echo 'mv vmlinux.orig vmlinux'
>  echo "%endif"
>  
> +echo 'rm -rf $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/{build,source}"
> +echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
> +echo "EXCLUDES=\"--exclude-vcs --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude=firmware --exclude .config.old --exclude .missing-syscalls.d\""
> +echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"

For consistency and compatibility with older tar versions, please use
$RCS_TAR_EXCLUDE instead of --exclude-vcs. Also, you only need .config,
scripts/, include/ and the Makefiles to build external modules. But
that's an optimization that can be done in a later patch.

> +echo "%post devel"
> +echo "cd /lib/modules/$KERNELRELEASE"
> +echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
> +echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
> +echo ""
> +echo "%postun devel"
> +echo "cd /lib/modules/$KERNELRELEASE"
> +echo "rm -f build source"

These symlinks should be part of the RPM payload.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marciniszyn, Mike July 5, 2013, 1:04 p.m. UTC | #2
PiBGb3IgY29uc2lzdGVuY3kgYW5kIGNvbXBhdGliaWxpdHkgd2l0aCBvbGRlciB0YXIgdmVyc2lv
bnMsIHBsZWFzZSB1c2UNCj4gJFJDU19UQVJfRVhDTFVERSBpbnN0ZWFkIG9mIC0tZXhjbHVkZS12
Y3MuIEFsc28sIHlvdSBvbmx5IG5lZWQgLmNvbmZpZywNCj4gc2NyaXB0cy8sIGluY2x1ZGUvIGFu
ZCB0aGUgTWFrZWZpbGVzIHRvIGJ1aWxkIGV4dGVybmFsIG1vZHVsZXMuIEJ1dCB0aGF0J3MgYW4N
Cj4gb3B0aW1pemF0aW9uIHRoYXQgY2FuIGJlIGRvbmUgaW4gYSBsYXRlciBwYXRjaC4NCj4gDQoN
CkkgY2FuJ3QgZmluZCBhbnkgcmVmZXJlbmNlIHRvIHRoZSBhYm92ZSBzdHJpbmcgaW4ga2VybmVs
IE1ha2VmaWxlcyBvciB0YXIgaW5mbz8NCg0KRG8geW91IGhhdmUgbW9yZSBkZXRhaWxzPw0KDQo+
ID4gK2VjaG8gIiVwb3N0IGRldmVsIg0KPiA+ICtlY2hvICJjZCAvbGliL21vZHVsZXMvJEtFUk5F
TFJFTEVBU0UiDQo+ID4gK2VjaG8gImxuIC1zZiAvdXNyL3NyYy9rZXJuZWxzLyRLRVJORUxSRUxF
QVNFIGJ1aWxkIg0KPiA+ICtlY2hvICJsbiAtc2YgL3Vzci9zcmMva2VybmVscy8kS0VSTkVMUkVM
RUFTRSBzb3VyY2UiDQo+ID4gK2VjaG8gIiINCj4gPiArZWNobyAiJXBvc3R1biBkZXZlbCINCj4g
PiArZWNobyAiY2QgL2xpYi9tb2R1bGVzLyRLRVJORUxSRUxFQVNFIg0KPiA+ICtlY2hvICJybSAt
ZiBidWlsZCBzb3VyY2UiDQo+IA0KPiBUaGVzZSBzeW1saW5rcyBzaG91bGQgYmUgcGFydCBvZiB0
aGUgUlBNIHBheWxvYWQuDQoNCkkgZ3Vlc3MgdGhlICVwb3N0KiBzZWN0aW9ucyB3b3VsZCB0aGVu
IGJlIG5vdCBuZWVkZWQuLi4NCg0KTWlrZQ0K
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marciniszyn, Mike July 5, 2013, 1:12 p.m. UTC | #3
> I can't find any reference to the above string in kernel Makefiles or tar info?

> 

> Do you have more details?

> 


Did you mean RCS_FIND_IGNORE?

Mike
Marciniszyn, Mike July 5, 2013, 1:17 p.m. UTC | #4
> > I can't find any reference to the above string in kernel Makefiles or tar info?

> >

> > Do you have more details?

> >

> 

> Did you mean RCS_FIND_IGNORE?

> 


Ok.   RCS_TAR_IGNORE seems to be the correct variable.

Mike
Michal Marek July 5, 2013, 8:29 p.m. UTC | #5
Dne 5.7.2013 15:04, Marciniszyn, Mike napsal(a):
>> For consistency and compatibility with older tar versions, please use
>> $RCS_TAR_EXCLUDE instead of --exclude-vcs. Also, you only need .config,
>> scripts/, include/ and the Makefiles to build external modules. But that's an
>> optimization that can be done in a later patch.
>>
> 
> I can't find any reference to the above string in kernel Makefiles or tar info?
> 
> Do you have more details?

It's $RCS_TAR_IGNORE, sorry.


>>> +echo "%post devel"
>>> +echo "cd /lib/modules/$KERNELRELEASE"
>>> +echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
>>> +echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
>>> +echo ""
>>> +echo "%postun devel"
>>> +echo "cd /lib/modules/$KERNELRELEASE"
>>> +echo "rm -f build source"
>>
>> These symlinks should be part of the RPM payload.
> 
> I guess the %post* sections would then be not needed...

Yes.

Michal

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek July 5, 2013, 8:30 p.m. UTC | #6
Dne 5.7.2013 15:17, Marciniszyn, Mike napsal(a):
>  
>>> I can't find any reference to the above string in kernel Makefiles or tar info?
>>>
>>> Do you have more details?
>>>
>>
>> Did you mean RCS_FIND_IGNORE?
>>
> 
> Ok.   RCS_TAR_IGNORE seems to be the correct variable.

So you found it :). Yes, that's what I meant.

Michal

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marciniszyn, Mike July 8, 2013, 11:55 a.m. UTC | #7
> For consistency and compatibility with older tar versions, please use

> $RCS_TAR_EXCLUDE instead of --exclude-vcs. Also, you only need .config,

> scripts/, include/ and the Makefiles to build external modules. But that's an

> optimization that can be done in a later patch.

> 


In v2 of the patch.

> 

> These symlinks should be part of the RPM payload.

> 


This is also in v2 of the same patch.  The %post and %postun scriptlets are no longer there.

These is one minor oddity in that the symlinks are in the main package because of that packages file selection.   Those symlinks will dangle until the devel package is installed.

It might be possible to adjust the file lists of both, but I was wary of creating a more explicit list in the main package because of a potential maintenance issue as "install" payload changes.

Mike
Michal Marek July 8, 2013, 12:12 p.m. UTC | #8
On 8.7.2013 13:55, Marciniszyn, Mike wrote:
>> For consistency and compatibility with older tar versions, please
>> use $RCS_TAR_EXCLUDE instead of --exclude-vcs. Also, you only need
>> .config, scripts/, include/ and the Makefiles to build external
>> modules. But that's an optimization that can be done in a later
>> patch.
>> 
> 
> In v2 of the patch.
> 
>> 
>> These symlinks should be part of the RPM payload.
>> 
> 
> This is also in v2 of the same patch.  The %post and %postun
> scriptlets are no longer there.
> 
> These is one minor oddity in that the symlinks are in the main
> package because of that packages file selection.   Those symlinks
> will dangle until the devel package is installed.
> 
> It might be possible to adjust the file lists of both, but I was wary
> of creating a more explicit list in the main package because of a
> potential maintenance issue as "install" payload changes.

You can say '%exclude /some/path' to exclude a path that would otherwise
match an earlier pattern. But I do not know since when RPM supports
this. If there is a risk of breaking make rpm on older systems, then
let's leave it as is.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marciniszyn, Mike July 8, 2013, 1:15 p.m. UTC | #9
> You can say '%exclude /some/path' to exclude a path that would otherwise

> match an earlier pattern. But I do not know since when RPM supports this. If

> there is a risk of breaking make rpm on older systems, then let's leave it as is.


This looks to be an RPM 4.0.3 feature.


I agree.

Mike
Doug Ledford July 8, 2013, 1:32 p.m. UTC | #10
On 07/08/13 09:15, Marciniszyn, Mike wrote:
>  
>> You can say '%exclude /some/path' to exclude a path that would otherwise
>> match an earlier pattern. But I do not know since when RPM supports this. If
>> there is a risk of breaking make rpm on older systems, then let's leave it as is.
> 
> This looks to be an RPM 4.0.3 feature.
> 
> 
> I agree.
> 
> Mike
> 

rpm 4.0.3 is *ancient*.  An %exclude is perfectly acceptable and
definitely preferable to a broken payload.
Marciniszyn, Mike July 8, 2013, 1:39 p.m. UTC | #11
> 

> rpm 4.0.3 is *ancient*.  An %exclude is perfectly acceptable and definitely

> preferable to a broken payload.

> 


The top of the mkspec shell script has this comment:
#       Output a simple RPM spec file that uses no fancy features requiring
#       RPM v4. This is intended to work with any RPM distro.

Are there old distros that still care about this?

Mike
Michal Marek July 8, 2013, 2:45 p.m. UTC | #12
On 8.7.2013 15:39, Marciniszyn, Mike wrote:
>>
>> rpm 4.0.3 is *ancient*.  An %exclude is perfectly acceptable and definitely
>> preferable to a broken payload.
>>
> 
> The top of the mkspec shell script has this comment:
> #       Output a simple RPM spec file that uses no fancy features requiring
> #       RPM v4. This is intended to work with any RPM distro.
> 
> Are there old distros that still care about this?

If it's that old, I don't think we need to care. At least not for
building the RPM, because the compiler on such old systems is probably
not going to be able to compile the kernel. I wasn't sure if %exclude
wasn't added in the last five years or so.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marciniszyn, Mike July 8, 2013, 3:52 p.m. UTC | #13
> > Are there old distros that still care about this?

> 

> If it's that old, I don't think we need to care. At least not for building the RPM,

> because the compiler on such old systems is probably not going to be able to

> compile the kernel. I wasn't sure if %exclude wasn't added in the last five years

> or so.

> 


Ok.   I will takes Doug's advice and try the %exclude.

Look for a v3 in a bit.  I will adjust the mkspec comment indicated a new min RPM level, 4.0.3.

Mike
Doug Ledford July 8, 2013, 4:20 p.m. UTC | #14
On 7/8/2013 10:45 AM, Michal Marek wrote:
> On 8.7.2013 15:39, Marciniszyn, Mike wrote:
>>>
>>> rpm 4.0.3 is *ancient*.  An %exclude is perfectly acceptable and definitely
>>> preferable to a broken payload.
>>>
>>
>> The top of the mkspec shell script has this comment:
>> #       Output a simple RPM spec file that uses no fancy features requiring
>> #       RPM v4. This is intended to work with any RPM distro.
>>
>> Are there old distros that still care about this?
> 
> If it's that old, I don't think we need to care. At least not for
> building the RPM, because the compiler on such old systems is probably
> not going to be able to compile the kernel. I wasn't sure if %exclude
> wasn't added in the last five years or so.

Quick google search confirms that rpm 4.0.3 was released in December of
2001.  I think it's safe to say we can use %exclude and not worry about
anything so ancient it can't support it.
Marciniszyn, Mike July 8, 2013, 5:17 p.m. UTC | #15
> Quick google search confirms that rpm 4.0.3 was released in December of

> 2001.  I think it's safe to say we can use %exclude and not worry about anything

> so ancient it can't support it.

> 


Version 3 of the fix now uses the exclude.

Mike
diff mbox

Patch

diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 514aeb2..65131df 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -59,6 +59,14 @@  echo "header files define structures and constants that are needed for"
 echo "building most standard programs and are also needed for rebuilding the"
 echo "glibc package."
 echo ""
+echo "%package devel"
+echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
+echo "Group: System Environment/Kernel"
+echo "AutoReqProv: no"
+echo "%description -n kernel-devel"
+echo "This package provides kernel headers and makefiles sufficient to build modules"
+echo "against the $__KERNELRELEASE kernel package."
+echo ""
 
 if ! $PREBUILT; then
 echo "%prep"
@@ -109,6 +117,11 @@  echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
 echo 'mv vmlinux.orig vmlinux'
 echo "%endif"
 
+echo 'rm -rf $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/{build,source}"
+echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
+echo "EXCLUDES=\"--exclude-vcs --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude=firmware --exclude .config.old --exclude .missing-syscalls.d\""
+echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
+
 echo ""
 echo "%clean"
 echo 'rm -rf $RPM_BUILD_ROOT'
@@ -122,6 +135,15 @@  echo "/sbin/installkernel $KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm /boot/
 echo "rm -f /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm"
 echo "fi"
 echo ""
+echo "%post devel"
+echo "cd /lib/modules/$KERNELRELEASE"
+echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
+echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
+echo ""
+echo "%postun devel"
+echo "cd /lib/modules/$KERNELRELEASE"
+echo "rm -f build source"
+echo ""
 echo "%files"
 echo '%defattr (-, root, root)'
 echo "%dir /lib/modules"
@@ -133,3 +155,7 @@  echo "%files headers"
 echo '%defattr (-, root, root)'
 echo "/usr/include"
 echo ""
+echo "%files devel"
+echo '%defattr (-, root, root)'
+echo "/usr/src/kernels/$KERNELRELEASE"
+echo ""