Hi > I am playing with LTSP-4.0, and need help with building kernels. > > 1) http://www.ltsp.org/lbe-alpha-3.html says: > > The LTSP source package doesn't include the kernel sources yet. > We need to be able to build the initrd and the kernels using the same tools Here is a build_krpm for this situation: run it from the lbe directory
James -------- KERN-VERSION (keep format, but anything goes) ------------------------ 2.4.19-ltsp-3 -------- package.def (from lbe/kernel-src/kernel ------------------------------ # # package.def file for building a package in the the LTSP build environment # # Copyright (c) 2003 by James A. McQuillan (McQuillan Systems, LLC) # # This software is licensed under the Gnu General Public License. # The full text of which can be found at http://www.LTSP.org/license.txt # # perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -ltsp-2/" Makefile PKG1 = linux-2.4.19.tar.bz2 MD5SUM1 = 2bb60b7594a416f2c593923ce446160b SOURCE1 = ftp://ftp.kernel.org/pub/linux/kernel/v2.4/${PKG1}, \ http://www.ltsp.org/tarballs/${PKG1}, \ http://http1.ca.ltsp.org/tarballs/${PKG1}, \ ftp://ftp.sourceforge.net/pub/sourceforge/ltsp/${PKG1} UNPACK1 = bunzip2 < ${TARBALL} | tar xf - BUILDDIR = linux-2.4.19 CONFIGURE = cp ../config-2.4.19-ltsp-2 .config && \ /setextra Makefile POSTPATCH1 = gunzip <../nfs-swap-2.4.19.patch.gz | patch -p1 BUILD = make oldconfig && \ make dep && \ make include/linux/version.h && \ make clean && \ make -j ${CPUS} bzImage && \ make -j ${CPUS} modules INSTALL = make modules_install INSTALL_MOD_PATH=${KERNEL_ROOT} && \ cp arch/i386/boot/bzImage ${KERNEL_ROOT}/bzImage && \ cp System.map ${KERNEL_ROOT} CLEAN = rm -rf ${BUILDDIR} ${SOURCEDIR} -------- setextra from lbe directory ------------------------------------------ # I can't do this from perl's cmd line -- anybody ?? ------------------------------------------------------------------------------- #!/usr/bin/perl -i -w $arg = `cat /KERN-VERSION`; chomp $arg; ($a, $b, $c) = split (/-/, $arg); while (<>) { s/^EXTRAVERSION.*/EXTRAVERSION = -$b-$c/; print; } -------- build_krpm ----------------------------------------------------------- #!/usr/bin/perl -w # $Header: /home/cvs/lbe/build_krpm,v 1.10 2003/06/24 22:44:17 jam Exp $ #------- Setup names paths etc #$num = @ARGV; # for flags whatever $irdsize = 2000; $irdinodes = 180; $rpmpath = "/usr/src/redhat"; $kernver = `cat KERN-VERSION`; chomp $kernver; ($ver, $name, $rel) = split (/-/, $kernver); $pwd = `pwd`; chomp $pwd; $kernsrc = "$pwd/kernel"; # Kernel build src $buildroot = "$pwd/tmp/$name-$ver"; # BUILDROOT actual path $chrbroot = "/tmp/$name-$ver"; # BUILDROOT in chroot env $tftp = "$buildroot/tftpboot/lts"; # actual /tftpboot path $chrtftp = "$chrbroot/tftpboot/lts"; # chroot /tftpboot path $irdimg = "$tftp/initrd-$kernver"; # actual initrd image $chrimg = "$chrtftp/initrd-$kernver.gz"; # chroot initrd image $opt = "$buildroot/opt/ltsp/i386"; # actual /opt path $sysmap = "$kernsrc/System.map"; $moduledir = "/lib/modules/$kernver"; check_root_user (); #------- Create the BUILDROOT directories system "mkdir -p $tftp"; system "mkdir -p $opt"; #------ Create the initrd and copy files and modules there system "dd if=/dev/zero of=$irdimg bs=1k count=$irdsize"; printf "mke2fs -F -q -m 0 -N $irdinodes $irdimg $irdsize\n"; system "mke2fs -F -q -m 0 -N $irdinodes $irdimg $irdsize"; if (!(-d "/mnt/initrd")) { mkdir "/mnt/initrd"; } system "mount -t ext2 -o loop $irdimg /mnt/initrd"; chdir "initrd"; system "find ./ -print | sort | cpio -pmud /mnt/initrd"; chdir "$kernsrc$moduledir"; system "find ./kernel/drivers/net -print | cpio -pmud /mnt/initrd$moduledir"; system "depmod -e -a -F $sysmap -b /mnt/initrd $kernver"; #------- Print some checks printf "[info] Checking size\n"; system "df -v /mnt/initrd"; system "df -i /mnt/initrd"; system "umount /mnt/initrd"; #------- Compress the image chdir $pwd; printf "gzipping initrd\n"; system "gzip -9 $irdimg"; #system "gzip -9 <$irdimg >$irdimg.gz"; #------- Copy files to buildroot system "cp $kernsrc/bzImage $tftp/bzImage-$kernver"; system "cp -a $kernsrc/lib $opt"; #------- Create the pxe files system "cp $kernsrc-src/pxe/pxelinux.0 $tftp"; mkdir "$tftp/pxelinux.cfg"; open (OFIL, ">$tftp/pxelinux.cfg/default") || die "Could not open output \"$tftp/pxelinux.cfg/default\""; print OFIL <<EOS; prompt=0 label linux kernel bzImage-$kernver append init=/linuxrc rw root=/dev/ram0 initrd=initrd-$kernver.gz EOS #------- Tag the kernel for etherboot system "chroot $pwd mknbi-linux --output=$chrtftp/vmlinuz-$kernver " . "--append=\"init=/linuxrc rw\" " . "--rootdir=\"/dev/ram0\" " . "$chrtftp/bzImage-$kernver " . "$chrimg"; system "ls -l $tftp/vmlinuz-$kernver"; #-------- Now do all the rpm-stuff $file = "$rpmpath/SPECS/$name.spec"; if (-e $file) { unlink $file; } #------- Build the spec file open (OFIL, ">$file") || die "Could not open output \"$file\""; print OFIL <<EOT; Summary: Linux Terminal Server Project kernel (ltsp.org) Name: $name Version: $ver Release: $rel Copyright: GPL Group: Networking/Admin Source: $name-$ver.tar.gz BuildRoot: /tmp/$name AutoReqProv: no %description This package is the tagged kernel for etherboot booting of ltsp workstations is also the pxe initrd image together with the untagged kernel. %prep %setup %build mkdir -p /tmp/$name mv tftpboot /tmp/$name mv opt /tmp/$name %install %clean rm -fr /tmp/$name %pre %post %changelog %files EOT chdir "$buildroot"; @files = `find .`; $numf = @files; chomp @files; #------- This check for empty dirs is not needed, but just in case for ($i = 0; $i < $numf; ++$i) { if ((-d $files[$i]) && ($files[$i+1] =~ /$files[$i]/)) { next; } $files[$i] =~ s/^.//; printf OFIL "$files[$i]\n"; } close OFIL; #-------- Build the rpm chdir "$pwd/tmp"; system ("tar czf $rpmpath/SOURCES/$name-$ver.tar.gz $name-$ver"); system ("rpmbuild -ba $rpmpath/SPECS/$name.spec"); system ("mv $rpmpath/RPMS/i386/$name-$ver* /home/downloads"); system ("rm -fr $name-$ver"); #------------------------------------------------------------------------------ sub check_root_user { if( $ENV{LOGNAME} ne "root" ){ die( "\n$0: Sorry! You really need to run as root\n\n" . " If you used 'su' to become the SuperUser, make sure\n" . " you include the hyphen '-' as an argument to su.\n" . " For example:\n\n" . " su -\n\n" . " That will ensure that the proper environment is setup.\n\n" ); } } ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01 _____________________________________________________________________ Ltsp-discuss mailing list. To un-subscribe, or change prefs, goto: https://lists.sourceforge.net/lists/listinfo/ltsp-discuss For additional LTSP help, try #ltsp channel on irc.freenode.net
