#!/bin/env rpmbuild -bb # # $Id: uml-custom.spec,v 1.26.2.10 2003/12/07 08:25:02 rogerb Exp $ # # This spec file will build User Mode Linux as an easy to # install rpm for you. As an added convenience, it will # automatically download the sources if you don't already # have them. Note that the kernel source is around 25MB # so if you already have a copy, place that in your RPM # sources directory, to avoid another download. # In addition to the comments in this file, there is further # documentation at http://umlbuilder.sourceforge.net/umlcustom.shtml # You should increase the release number by one for each # successful package you make. This will help avoid # version confusion. %define release 1 # A short name that will become part of the kernel version # to identify it as yours. %define customname custom # Various other versioning information %define name UML # for 2.6.0-test stuff, use an underscore instead of a dash, # otherwise rpm gets upset %define kernelversion 2.4.22 %define umlversion 6 %define version %{kernelversion}.%{customname}.%{umlversion}um %define umlutildate 20030903 # Fixup underscores to dash %define kvtrue `echo "%{kernelversion}" | tr _ -` # Which form of configuring the kernel options and modules you # want. You can also set the environment variable $CONFIG which # will override the setting here. # # xconfig Graphical menus appear # menuconfig Text based menus appear # default Defaults are used (possibly from files provided by # configcopy or configfile) # Kernel 2.6 also has gconfig (Gnome based GUI) and some other # options. Run `make help' in a 2.6 tree to see them. %define config default # If you already have UML installed, you can copy its kernel options # and modules setup. You can also set the environment variable # $CONFIGCOPY which will override the setting here. The existing # config is found by running 'linux --showconfig' %define configcopy no # You can supply the configuration from a file as well. You can # set the environment variable $CONFIGFILE to override this setting %define configfile /dev/null # The URLs to obtain the kernel and UML from %define kernelmajorminor `echo %{kernelversion} | sed 's/\\([^\\.]*\\.[^\\.]*\\).*/\\1/'` %define kernelurlbase http://www.kernel.org/pub/linux/kernel/v%{kernelmajorminor} %define umlurlbase http://osdn.dl.sourceforge.net/user-mode-linux/ # The filenames of the source %define kernelfilename linux-%{kvtrue}.tar.bz2 %define umlfilename uml-patch-%{kvtrue}-%{umlversion}.bz2 %define umlutilfilename uml_utilities_%{umlutildate}.tar.bz2 %define configfilename config-%{kernelversion}-%{customname}-%{umlversion}-%{release} %define extraversion -%{customname}-%{umlversion}um # Boiler plate from here Summary: User Mode Linux Name: %{name} Version: %{version} Release: %{release} Source0: %{configfilename} # We don't list the kernel itself, or UML patches since they # just make the source rpm larger for no benefit License: GPL Group: System BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} Provides: user_mode_linux %description User Mode Linux, home compiled and fresh %prep # If the files aren't in the sources directory, then we actually download them # ourselves using wget cd $RPM_SOURCE_DIR if [ ! -f %{kernelfilename} ] then wget %{kernelurlbase}/%{kernelfilename} fi if [ ! -f %{umlutilfilename} ] then wget %{umlurlbase}/%{umlutilfilename} fi if [ ! -f %{umlfilename} ] then wget %{umlurlbase}/%{umlfilename} fi rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/lib/modules # modules installed here mkdir -p $RPM_BUILD_ROOT/usr/bin # binaries mkdir -p $RPM_BUILD_ROOT/usr/lib/uml # everything else cd $RPM_BUILD_ROOT bzip2 -d < $RPM_SOURCE_DIR/%{kernelfilename} | tar xf - cd linux-%{kvtrue} 2>/dev/null || cd linux bzip2 -d < $RPM_SOURCE_DIR/%{umlfilename} | patch -p1 cd .. bzip2 -d < $RPM_SOURCE_DIR/%{umlutilfilename} | tar xf - # Copy pre-existing config file if we have one. This will ensure correct behaviour # if we are rebuilt from a .src.rpm file cd linux-%{kvtrue} 2>/dev/null || cd linux [ -f $RPM_SOURCE_DIR/%{configfilename} ] && cp $RPM_SOURCE_DIR/%{configfilename} .config %build cd $RPM_BUILD_ROOT cd linux-%{kvtrue} 2>/dev/null || cd linux [ -s "%{configfile}" ] && cp %{configfile} .config [ -s "$CONFIGFILE" ] && cp $CONFIGFILE .config if [ "x$CONFIGCOPY" = "x" ] ; then CONFIGCOPY="%{configcopy}" ; fi if [ "$CONFIGCOPY" = "yes" ] then linux --showconfig > .config fi # Ensure config is uptodate if [ -f .config ] then make oldconfig ARCH=um EXTRAVERSION=%{extraversion} else case %{kernelmajorminor} in 2.6|2.5|2.4) make oldconfig ARCH=um EXTRAVERSION=%{extraversion} ;; esac fi # Do fancy editing if [ "x$CONFIG" = "x" ] ; then CONFIG=%{config} ; fi case $CONFIG in xconfig|config|menuconfig|gconfig|allmodconfig|allyesconfig|allnoconfig) make $CONFIG ARCH=um EXTRAVERSION=%{extraversion} ;; default) true ;; * ) echo "Unrecognised config option \"$CONFIG\"" echo "Should be one of default, xconfig or menuconfig" exit 1 ;; esac rm -f .version make linux ARCH=um EXTRAVERSION=%{extraversion} cd ../tools make DESTDIR=$RPM_BUILD_ROOT %install cd $RPM_BUILD_ROOT cd linux-%{kvtrue} 2>/dev/null || cd linux # only do module stuff if they are configured in if egrep '^CONFIG_MODULES=y' .config >/dev/null then # We fail safe on the modules. They may not be configured, # there may be symbols not exported that should be. We # handle this by ignoring exit codes, and exporting the # symbols if necessary f=instmods.out sf=arch/um/kernel/ksyms.c make modules modules_install ARCH=um INSTALL_MOD_PATH=/var/tmp/UML-buildroot EXTRAVERSION=%{extraversion} 2>$f cat $f # were there missing symbols? if grep 'Unresolved symbols in' $f >/dev/null then syms=`egrep '^depmod: [a-zA-Z0-9_]+$' $f | \ sed 's/^depmod: //' | sort | uniq` for i in $syms do echo "EXPORT_SYMBOL($i);" >> $sf done # make the modules again rm -f .version make linux modules modules_install ARCH=um INSTALL_MOD_PATH=/var/tmp/UML-buildroot EXTRAVERSION=%{extraversion} fi rm $f fi cp linux $RPM_BUILD_ROOT/usr/bin cp .config $RPM_BUILD_ROOT/usr/lib/uml/config cp .config $RPM_SOURCE_DIR/%{configfilename} cd .. # we always create modules tar file. tar doesn't mind a zero length file tar cf usr/lib/uml/modules-%{kernelmajorminor}.tar lib/modules || touch usr/lib/uml/modules-%{kernelmajorminor}.tar cd tools make install DESTDIR=$RPM_BUILD_ROOT # some cleanups so that files doesn't complain cd .. rm -rf lib tools rm -rf linux linux-%{kvtrue} %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) /usr/bin/* /usr/lib/uml # uml_net is setuid root #%attr(4755,root,root) /usr/bin/uml_net %changelog # end of file