Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Shouldn't I have an RPM in /usr/src/redhat/RPMS/i386 ? it builds apparently and no errors but no RPM not doing something right... heres a spec file I borrowed from a friend
Code:
Summary: The 2.6.17.13 kernel.
Name: linux
Version: 2.6.17.13
Release: UP_100megs_1.0
Copyright: GPL
Group: System Environment/Kernel
Source http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.13.tar.gz
BuildRoot: /usr/src/redhat/BUILD/%{name}-%{version}
%description
This is the Linux %{version} kernel compiled to work on most systems.
%prep
%setup
# Check to see if the config file is present and copy it to .config
if [ -f $RPM_BUILD_ROOT/%{version}-%{release} ]; then
cp -f $RPM_BUILD_ROOT/%{version}-%{release} $RPM_BUILD_ROOT/.config
else
echo "No config file found. Exiting"
# rm -rf $RPM_BUILD_ROOT
exit 1;
fi
%build
make dep;make bzImage
%install
mkdir $RPM_BUILD_ROOT/boot
cp $RPM_BUILD_ROOT/arch/i386/boot/bzImage $RPM_BUILD_ROOT/boot/vmlinuz-%{version}-%{release}
cp $RPM_BUILD_ROOT/System.map $RPM_BUILD_ROOT/boot/System.map-%{version}-%{release}
%clean
rm -rf $RPM_BUILD_ROOT
%pre
%post
# If /etc/grub.conf is there, have grubby add the config
if [ -f /etc/grub.conf ]; then
# Backup the grub config
cp -u /etc/grub.conf /etc/grub.conf.rpmsave
# Use grubby to build new config
/sbin/grubby --add-kernel=/boot/vmlinuz-%{version}-%{release} --title="Red Hat Linux (%{version}-%{release})" --copy-default --make-default -c /etc/grub.conf --args="ro root=/dev/`cat /etc/grub.conf |perl -e 'while (my $line = <STDIN>) { if ($line =~ /^#.* root=\/dev\/(.*)$/) { print $1 . "\n"; }}'`" -o /tmp/%{version}-%{release}.grub.conf
# Copy the tmp file to /etc/grub.conf
cp -u /tmp/%{version}-%{release}.grub.conf /etc/grub.conf
ln -sf /boot/System.map-%{version}-%{release} /boot/System.map
fi
# If there is a lilo.conf (and no grub.conf) Add the entry
if [ -f /etc/lilo.conf ]; then
/usr/bin/env perl<<EOF
open(LILO,'/etc/lilo.conf');
while (\$line = <LILO>) {
\$line =~ /.*root=(.*)\$/;
\$hd = \$1;
}
close(LILO);
system('cp -f /etc/lilo.conf /etc/lilo.conf.rpmsave');
system('echo "image=/boot/vmlinuz-%{version}-%{release}
label=%{version}
read-only
root=' . \$hd . '" >> /etc/lilo.conf');
EOF
ln -sf /boot/System.map-%{version}-%{release} /boot/System.map
fi
# Udev foo for CentOS and RHES
if [ ! -d /tmp/udevcheck ]; then
mkdir /tmp/udevcheck
fi
mount --bind / /tmp/udevcheck
if [ ! -c /tmp/udevcheck/dev/console ]; then
mknod -m 660 /tmp/udevcheck/dev/console c 5 1
fi
if [ ! -c /tmp/udevcheck/dev/null ]; then
mknod -m 660 /tmp/udevcheck/dev/null c 1 3
fi
umount /tmp/udevcheck
%preun
%postun
if [ -f /boot/grub/grub.conf ]; then
sed "/title Red Hat Linux (%{version}-%{release})/{N;N;d;}" /boot/grub/grub.conf > /tmp/grub.conf.tmp
mv -f /boot/grub/grub.conf /boot/grub/grub.conf.rpmsave
mv /tmp/grub.conf.tmp /boot/grub/grub.conf
fi
if [ -f /etc/lilo.conf ]; then
sed "/image=\/boot\/vmlinuz-%{version}-%{release}/{N;N;N;d;}" /etc/lilo.conf > /tmp/lilo.conf.tmp
mv -f /etc/lilo.conf /etc/lilo.rpmsave
mv /tmp/lilo.conf.tmp /etc/lilo.conf
fi
%files
/boot/vmlinuz-%{version}-%{release}
/boot/System.map-%{version}-%{release}
Alrighty, I thought I installed it but I checked and dont see it so might be whats it, its building now see what happens. What exactly is the source kernel for? I mean if you were wanting to build a RPM and dont have a source rpm to start with how would you even get around to making one? And does your source kernel need to be the same as the one your building?
What exactly is the source kernel for?
For building a kernel RPM.
I mean if you were wanting to build a RPM and dont have a source rpm to start with how would you even get around to making one?
You take the archive it's distributed as (usually a tarball) and build the package. From those commands you build a spec file. It really is easy to do and I usually do that if I want something that's not rpm-ified yet. For something like a kernel RPM maintainer it requires more work because you have to make sure it builds on all supported architectures and all that.
And does your source kernel need to be the same as the one your building?
Yes. You build from a source. Of course you can have multiple sources installed and build them anytime and any way you like as long as the .spec files are there and pointing to the right sources.
ok still getting the same thing goes thru entire process but no RPM. The tar.gz file has a make rpm switch but I have to edit the script to take out the make modules part because im not building any modules in. It does create the rpm but doesn't install, all you see is a verbose of what appears to be a kernel installing but it doesn't which what prompt me to try it this way. This way isn't workin for me either Is the spec file incorrect?
ok still getting the same thing goes thru entire process but no RPM. The tar.gz file has a make rpm switch but I have to edit the script to take out the make modules part because im not building any modules in. It does create the rpm
First of all you're contradicting yourself here (doesn't build RPM, builds RPM OK) or you're trying to describe the outcome of two different build methods in one go. So choose either the "rpmbuild -b" or the "rpmbuild -t" way and stick with it for troubleshooting purposes. Also by editing buildscripts you're introducing risk of error and making troubleshooting (what should be) a default build process harder. You should not do that unless you know enough of it to not fsck up.
This way isn't workin for me either Is the spec file incorrect?
I don't know. My ESP is way low. Your profile states your distro+release is RH-7.3 and the kernel you're trying to build is 2.6.17.x. Did you previously update all dependencies or is this a build on a later release?
I'd suggest you rerun your RPM-making routine and redirect stdout to a file and stderr to a different file: "rpmbuild -bb kernel.spec 1>/tmp/std.out 2>/tmp/std.err". Post the contents (if any) of /tmp/std.err first but make sure you don't post unnecessary stuff like say configure errors you know are OK.
Ive changed my distro's in my profile, when I joined LQ thats what I was using at the time. This is for a server not a desktop just an FYI. Let me remind again that im not familar with building an RPM I googled around for how to's and articles and the process im using is the same as these articles but no RPM so I came here for advice, obviously im making mistakes so forgive my ignorance. Im building this on a Dual Opteron 246 with CentOS 4
I'll cut the log here. This is part of building the RPM which ends with installing the files and running any scripts. Then RPM kicks in and tries to make an archive out of it:
The error line indicates the .spec file does not have a proper %files listing and so the files are considered "unpackaged". Your .spec file ends with (or you just didn't paste more):
K not that it matters but there are no M built into the kernel its all * or () nothing at all, I didnt intend on building a modulated kernel in which case when building
error: File not found: /usr/src/redhat/BUILD/linux-2.6.17.13/lib/modules
error: File not found: /usr/src/redhat/BUILD/linux-2.6.17.13/lib/modules/2.6.17.13-UP_100megs_1.0
error: File not found: /usr/src/redhat/BUILD/linux-2.6.17.13/boot/config-2.6.17.13-UP_100megs_1.0
File not found: /usr/src/redhat/BUILD/linux-2.6.17.13/lib/modules
File not found: /usr/src/redhat/BUILD/linux-2.6.17.13/lib/modules/2.6.17.13-UP_100megs_1.0
File not found: /usr/src/redhat/BUILD/linux-2.6.17.13/boot/config-2.6.17.13-UP_100megs_1.0
Thanks for your help so far... any other ideas?
Yes. Two ways. I think it's best to stay close to what your distro offers. I still have the idea you're mixing stuff. Hand-editing kernel configs and spec files introduces risks and makes troubleshooting difficult. You should not do that unless you know enough of it to not fsck up. You should try to eliminate any risks by using a more methodical approach. This should make you understand what is necessary:
- Take the latest stock CentOS-4 kernel .src.rpm.
- Install the .src.rpm, build the rpm and see if it installs. (This validates your build process is clean.)
- Use that spec file and ditch the one you've been playing with.
- Backup the kernel config and spec file.
- Make the kernel config process save a config that doesn't build modules (again, no manual editing).
- Inject that config. This is the only time you edit the spec file: (at %configure, cp .config from $RPM_SOURCE_DIR).
- Now retry building and installing.
If you get at this stage with a clean built rpm, you know what's needed. CentOS uses RHEL kernels which means all patches are backported to their kernel version. If you now swap the (I think it uses 2.6.9 series?) kernel source for your 2.6.17.13 one, make sure every patch matches (may take manual patching and re-diffing) or make sure you can do w/o the patch and check every script that "massages" whatever is being built during the build process for changed paths and kernel versions.
Results of the other way MUST NOT be made available publicly because it is simply fooling rpm:
Build your kernel like you want it to be and install it. Make a tarball of what the kernel installed. In your spec file clean out the %build, %install, %clean, %preun and %postun stages. Populate the specfile's %files section running something like "find /installdir -not -type d | while read f; do echo "%attr(600,root,root) $f"; done" or "tar -tzf /your/installedkernel/tarball.tar.gz|xargs -iF echo "%attr(600,root,root) /F"". Check the %post stage for validity of internal or external (Perl?) scripts adding the kernel to GRUB or LILO etc, etc.
Now if you "rpmbuild -bb" the rpm you just extract the files and package it.
Again please DO NOT distribute this publicly as it's just a flawed workaround and not the valid RPM-stylee craftsmanship people depend upon.
I havent been modifying the kernel at all, I have a tarball of it in source downloaded from kernel.org just sitting there only modifications ive made so far is just to the spec file as you had instructed earlier and a config file that i use for building kernels manually i just recompressed it.. ill look into the other kernel source and see finding this is harder then to be expected
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.