making a kernel rpm

Discussion in 'OT Technology' started by DigiCrime, Sep 29, 2006.

  1. DigiCrime

    DigiCrime If Only!

    Joined:
    Oct 25, 2001
    Messages:
    32,996
    Likes Received:
    100
    Location:
    St. Louis
    having a hard time figuring this out, asking around but havent found anything out yet, everyones confused as to why im not building in modules. im trying to build a kernel rpm but the rpm doesn't show up after running

    rpmbuild -ba kernel-2.6.17.13.spec

    instead I find in /usr/src/redhat/BUILD/linux-2.6.17.13/ a compiled kernel ready to be installed actually but no rpm. I have a tarball in /usr/src/redhat/SOURCE that Ive uncompressed and placed a config file I use for building with and re-compressed it.. what am i doing wrong?

    spec file
    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} 
     
    
     

Share This Page