LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-19-2006, 11:39 PM   #1
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Rep: Reputation: 30
rpmbuild a kernel


Attempting to build me a rpm kernel after I run

rpmbuild --target i386 -ba kernel-2.6.17.13.spec

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}
 
Old 09-20-2006, 01:42 AM   #2
Thoreau
Senior Member
 
Registered: May 2003
Location: /var/log/cabin
Distribution: All
Posts: 1,167

Rep: Reputation: 45
RPM is working correctly. Your spec file is not.
 
Old 09-20-2006, 08:41 AM   #3
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Original Poster
Rep: Reputation: 30
ok thats cool so how would I fix this then?
 
Old 09-20-2006, 02:22 PM   #4
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Original Poster
Rep: Reputation: 30
anyone know ?
 
Old 09-22-2006, 11:46 AM   #5
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Original Poster
Rep: Reputation: 30
bump, still curious
 
Old 09-22-2006, 01:21 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
I'd test by getting the .src.rpm and using rpmbuild --rebuild.
 
Old 09-22-2006, 03:08 PM   #7
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Original Poster
Rep: Reputation: 30
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?
 
Old 09-22-2006, 07:00 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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.
 
Old 09-22-2006, 07:14 PM   #9
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Original Poster
Rep: Reputation: 30
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?
 
Old 09-23-2006, 12:05 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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.
 
Old 09-26-2006, 11:52 AM   #11
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Original Poster
Rep: Reputation: 30
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

output of rpmbuild -ba kernel-2.6.17.13.spec 1>/tmp/std.out 2>stdout1.err http://stlhosting.com/stdout1.err

Last edited by DigiCrime; 09-26-2006 at 11:54 AM.
 
Old 09-27-2006, 03:37 PM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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:
Code:
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
error: Installed (but unpackaged) file(s) found:
   /..tmp_kallsyms1.o.cmd
   /..tmp_kallsyms2.o.cmd
   /..tmp_vmlinux1.cmd
   /..tmp_vmlinux2.cmd
# ad nauseam
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):
Code:
%files
/boot/vmlinuz-%{version}-%{release}
/boot/System.map-%{version}-%{release}
and AFAIK it needs to look something like this:
Code:
%files
%defattr (-, root, root)
%dir /lib/modules
/lib/modules/%{version}-%{release}
/boot/vmlinuz-%{version}-%{release}
/boot/System.map-%{version}-%{release}
/boot/config-%{version}-%{release}
 
Old 09-28-2006, 11:33 AM   #13
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Original Poster
Rep: Reputation: 30
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?
 
Old 09-29-2006, 08:10 AM   #14
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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.
 
Old 09-29-2006, 10:54 AM   #15
DigiCrime
Member
 
Registered: Dec 2002
Location: St. Louis
Distribution: All Flavors
Posts: 195

Original Poster
Rep: Reputation: 30
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need help using rpmbuild. dr_zayus69 Linux - Software 3 04-24-2005 08:49 AM
what should do after rpmbuild? joirnange Linux - Newbie 3 01-15-2005 05:23 AM
summary and description substitutions when doing rpmbuild of Kernel dillybat Programming 0 01-14-2005 12:32 PM
rpmbuild ?? mickeyboa Fedora 1 07-25-2004 10:09 PM
rpmbuild linuxdev Linux - Newbie 1 02-18-2004 03:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration