I'm using OpenSuse 11.2 from a LiveUSB USB flash/stick, which arguably has not much place on it. I need to get the Linux sources for this version of OpenSuse, as they are needed to build a driver for an application I'm using. I have plenty of disk space on an attached hard-drive, so I'd like to "install" the sources there (note that on 11.2, zypper --download-only
will by default download to /var/cache/zypp/packages, which crashes my LiveUSB setup).
So, I do the following:
> cd /media/myhdrive/
> wget http://download.opensuse.org/update/11.2/rpm/src/kernel-source-2.6.31.14-0.8.1.src.rpm
> mkdir kernel-source-2.6.31.14
> cd kernel-source-2.6.31.14/
> rpm2cpio ../kernel-source-2.6.31.14-0.8.1.src.rpm | cpio -idmv --no-absolute-filenames
> ls
arch-symbols kernel-source.rpmlintrc patches.kabi.tar.bz2
built-in-where kernel-source.spec patches.kernel.org.tar.bz2
check-for-config-changes kernel-source.spec.in patches.rpmify.tar.bz2
check-supported-list kernel-spec-macros patches.rt.tar.bz2
compute-PATCHVERSION.sh kernel-syms.spec.in patches.staging.tar.bz2
....
… and there is a bunch of *.tar.gz
files (patches) – and not anything resembling C source files. I'm guessing there is a script/command I should apply now to unpack the source tree, but I have no idea what it – I've seen rpmbuild -bb ...
here, but I guess that will build yet another .rpm
– while I want the actual sources unpacked (and that at a location I specify – not in /usr/src
or anywhere on root filesystem).
Any ideas what I should do now?
Many thanks in advance for any answers,
Cheers!
EDIT: via Building a custom kernel – FedoraProject, trying rpmbuild -bp
, but it fails:
# man rpmbuild:
# -bp Executes the "%prep" stage from the spec file. Normally this involves
unpacking the sources and applying any patches.
> mkdir src
> rpmbuild --buildroot=$(pwd)/src/ -bp --target=$(uname -m) kernel-source.spec
Building target platforms: i686
Building for target i686
error: Unable to open /usr/src/packages/SOURCES/kernel-spec-macros: No such file or directory
Best Answer
EDIT: Use the
-bc
switch ofrpmbuild
:... 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 userpmbuild -bp
is left below for reference - not that it, on its own, doesn't even extract the linux sources. Below is the log of usingrpmbuild -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
"):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 ):... 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 theSymbol(s):
line in the original output for the snippet above); I basically repeated what therpmbuild
tmp script did: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!