EDIT: Use the -bc
switch of rpmbuild
:
-bc Do the "%build" stage from the spec file (after doing the %prep stage).
This generally involves the equivalent of a "make".
... since -bp
will just unpack the "sources" related to the .rpm, but will not "make" them - which involves applying the specific SUSE patches... My attempt to use rpmbuild -bp
is left below for reference - not that it, on its own, doesn't even extract the linux sources. Below is the log of using rpmbuild -bc
, which both unpacks vanilla sources and applies patches to them (which can be seen from the terminal log, which has been left out here; note also that the patched sources will be in "BUILDROOT
"):
> mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
> echo "%_topdir $(pwd)/rpmbuild" > ~/.rpmmacros
> rpm -i ../kernel-source-2.6.31.14-0.8.1.src.rpm
> ls rpmbuild/*
rpmbuild/BUILD:
rpmbuild/RPMS:
rpmbuild/SOURCES:
arch-symbols kernel-source.rpmlintrc patches.kernel.org.tar.bz2
built-in-where kernel-source.spec.in patches.rpmify.tar.bz2
...
> cd rpmbuild/SPECS
> rm -rf ../BUILD/*
> rpmbuild -bc --target=`uname -m` kernel-source.spec 2>&1
> ls ../BUILDROOT/
kernel-source-2.6.31.14-0.8.1.i386
> ls ../BUILD
kernel-source-2.6.31.14
> ls -la ../BUILDROOT/kernel-source-2.6.31.14-0.8.1.i386/usr/src/
total 16
drwxr-xr-x 4 linux users 4096 2011-11-11 20:55 .
drwxr-xr-x 3 linux users 4096 2011-11-11 20:54 ..
lrwxrwxrwx 1 linux users 5 2011-11-11 20:54 linux -> linux
drwxr-xr-x 24 linux users 4096 2011-11-11 20:56 linux-2.6.31.14-0.8.1
drwxr-xr-x 23 linux users 4096 2011-11-11 20:55 linux-2.6.31.14-0.8.1-vanilla
> ls ../BUILDROOT/kernel-source-2.6.31.14-0.8.1.i386/usr/src/linux-2.6.31.14-0.8.1
arch crypto fs Kbuild MAINTAINERS README security virt
block Documentation include kdb Makefile REPORTING-BUGS sound
....
Ok, this turned out to be quite convoluted (given I still don't know the proper way to do this), but the post How to compile custom kernel on Centos/Xen or optimize CS:S server showed the way. Following that post, I did this ( still in the kernel-source-2.6.31.14/
directory as in the OP ):
> mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
> echo "%_topdir $(pwd)/rpmbuild" > ~/.rpmmacros
> rpm -i ../kernel-source-2.6.31.14-0.8.1.src.rpm
> ls rpmbuild/*
rpmbuild/BUILD:
rpmbuild/RPMS:
rpmbuild/SOURCES:
arch-symbols kernel-source.rpmlintrc patches.kernel.org.tar.bz2
built-in-where kernel-source.spec.in patches.rpmify.tar.bz2
...
> cd rpmbuild/SPECS
> rpmbuild -bp --target=`uname -m` kernel-source.spec
Building target platforms: i686
Building for target i686
error: Failed build dependencies:
fdupes is needed by kernel-source-2.6.31.14-0.8.1.src
> sudo zypper install fdupes
> rpmbuild -bp --target=`uname -m` kernel-source.spec
Building target platforms: i686
Building for target i686
Executing(%prep): /bin/bash -e /var/tmp/rpm-tmp.4uWZo1
+ umask 022
+ cd /path/to/kernel-source-2.6.31.14/rpmbuild/BUILD
+ '[' -e /path/to/kernel-source-2.6.31.14/rpmbuild/SOURCES/linux-2.6.31.tar.bz2 ']'
+ echo 'Symbol(s): '
Symbol(s):
+ cd /path/to/kernel-source-2.6.31.14/rpmbuild/BUILD
+ rm -rf kernel-source-2.6.31.14
+ /bin/mkdir -p kernel-source-2.6.31.14
+ cd kernel-source-2.6.31.14
+ /usr/bin/bzip2 -dc /path/to/kernel-source-2.6.31.14/rpmbuild/SOURCES/config.tar.bz2
+ /bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ /usr/bin/bzip2 -dc /path/to/kernel-source-2.6.31.14/rpmbuild/SOURCES/patches.arch.tar.bz2
+ /bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ /usr/bin/bzip2 -dc /path/to/kernel-source-2.6.31.14/rpmbuild/SOURCES/patches.drivers.tar.bz2
+ /bin/tar -xf -
+ STATUS=0
... [snip] ...
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
> ls ../BUILD/kernel-source-2.6.31.14/
config patches.arch patches.kabi patches.rt patches.trace
patches.addon patches.drivers patches.kernel.org patches.staging patches.xen
patches.apparmor patches.fixes patches.rpmify patches.suse
....
# ?? no linux sources?
... and, surprisingly, after all this, I still couldn't see any linux sources? However, I did notice that -e /path/to/kernel-source-2.6.31.14/rpmbuild/SOURCES/linux-2.6.31.tar.bz2
in the script above; and guessing that the linux*.tar.bz2 probably didn't get unpacked (there was nothing after the Symbol(s):
line in the original output for the snippet above); I basically repeated what the rpmbuild
tmp script did:
# done previously
> # cd ./rpmbuild/SPECS/
> # rpmbuild -bp --target=`uname -m` kernel-source.spec 2>&1
> cd ../..
> cd ./rpmbuild/BUILD/kernel-source-2.6.31.14/
> /usr/bin/bzip2 -dc ../../../rpmbuild/SOURCES/linux-2.6.31.tar.bz2 | /bin/tar -xf -
> ls # linux-2.6.31 directory gets created
> ls linux-2.6.31/
arch crypto fs Kbuild Makefile REPORTING-BUGS sound
block Documentation include kernel mm samples tools
...
Well.. finally, those are linux source files I can recognize :)
However, those are still, seemingly, the "vanilla" 'unpatched' sources - I guess there is a command that does all this along with patching, but I'm at loss as to what it is... Anyways, hope this may also help others a bit - cheers!