correct smp related /boot symlinks
[linux-2.6.git] / scripts / kernel-2.6-planetlab.spec
index 90f509a..fff0acd 100644 (file)
@@ -23,7 +23,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define rpmversion 2.6.%{sublevel}
 %define rhbsys  %([ -r /etc/beehive-root -o -n "%{?__beehive_build}" ] && echo || echo .`whoami`)
 
-%define release 1.1398_FC4.0.planetlab%{?date:.%{date}}
+%define release 1.1398_FC4.5%{?pldistro:.%{pldistro}}%{?date:.%{date}}
 
 %define signmodules 0
 %define make_target bzImage
@@ -62,7 +62,9 @@ Summary: The Linux kernel (the core of the Linux operating system)
 #
 # The ld.so.conf.d file we install uses syntax older ldconfig's don't grok.
 #
-%define xen_conflicts glibc < 2.3.5-1
+
+# MEF commented out
+# %define xen_conflicts glibc < 2.3.5-1
 
 #
 # Packages that need to be installed before the kernel is, because the %post
@@ -189,7 +191,10 @@ Prereq: %{kernel_prereq}
 Conflicts: %{kernel_dot_org_conflicts}
 Conflicts: %{package_conflicts}
 Conflicts: %{nptl_conflicts}
-Conflicts: %{xen_conflicts}
+
+# MEF commented out 
+# Conflicts: %{xen_conflicts}
+
 # We can't let RPM do the dependencies automatic because it'll then pick up
 # a correct but undesirable perl dependency from the module headers which
 # isn't required for the kernel proper to function
@@ -321,17 +326,38 @@ BuildKernel() {
 
     # and now to start the build process
 
-    make -s ARCH=$Arch mrproper
-    cp configs/$Config .config
-
-    echo USING ARCH=$Arch
+    CC=gcc
+    gccversion=$(gcc -v 2>&1 | grep "gcc version" | awk '{print $3'} | awk -F . '{print $1}')
+    if [ "$gccversion" == "4" ] ; then
+       echo "Currently not compiling kernel with gcc 4.x"
+       echo "Trying to find a recent gcc 3.x based compiler"
+       CC=
+       gcc3=$(which gcc32 2>/dev/null || /bin/true)
+       [ "$gcc3" != "" ] && CC=gcc32
+       echo "gcc3 = $gcc3; CC=${CC}"
+       gcc3=$(which gcc33 2>/dev/null || /bin/true)
+       [ "$gcc3" != "" ] && CC=gcc33
+       echo "gcc3 = $gcc3; CC=${CC}"
+       gcc3=$(which gcc34 2>/dev/null || /bin/true)
+       [ "$gcc3" != "" ] && CC=gcc34
+       echo "gcc3 = $gcc3; CC=${CC}"
+       if [ -z "$CC" ]; then
+           echo "Could not find a gcc 3.x based compiler!"
+           echo "Aborting kernel compilation!"
+           exit -1
+       fi
+    fi
+    HOSTCC=${CC}
 
-    make -s ARCH=$Arch nonint_oldconfig > /dev/null
-    make -s ARCH=$Arch include/linux/version.h 
+    make -s CC=${CC} HOSTCC=${HOSTCC} ARCH=$Arch mrproper
+    cp configs/$Config .config
+    echo "USING ARCH=$Arch CC=${CC} HOSTCC=${HOSTCC}"
 
-    make -s ARCH=$Arch %{?_smp_mflags} $Target
-    make -s ARCH=$Arch %{?_smp_mflags} modules || exit 1
-    make ARCH=$Arch buildcheck
+    make -s CC=${CC} HOSTCC=${HOSTCC} ARCH=$Arch nonint_oldconfig > /dev/null
+    make -s CC=${CC} HOSTCC=${HOSTCC} ARCH=$Arch include/linux/version.h 
+    make -s CC=${CC} HOSTCC=${HOSTCC} ARCH=$Arch %{?_smp_mflags} $Target
+    make -s CC=${CC} HOSTCC=${HOSTCC} ARCH=$Arch %{?_smp_mflags} modules || exit 1
+    make CC=${CC} HOSTCC=${HOSTCC} ARCH=$Arch buildcheck
     
     # Start installing the results
 
@@ -365,8 +391,11 @@ BuildKernel() {
     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
     (cd $RPM_BUILD_ROOT/lib/modules/$KernelVer ; ln -s build source)
     # first copy everything
-    cp --parents `find  -type f -name Makefile -o -name "Kconfig*"` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build 
+    cp --parents `find  -type f -name "Makefile*" -o -name "Kconfig*"` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build 
     cp Module.symvers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
+    if [ "$1" = "uml" ] ; then
+      cp --parents -a `find arch/um -name include` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
+    fi
     # then drop all but the needed Makefiles/Kconfig files
     rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Documentation
     rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts
@@ -388,6 +417,11 @@ BuildKernel() {
 %if %{buildxen}
     cp -a asm-xen $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
 %endif
+    if [ "$1" = "uml" ] ; then
+      cd asm   
+      cp -a `readlink arch` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
+      cd ..
+    fi
     cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
     # Make sure the Makefile and version.h have a matching timestamp so that
     # external modules can be built
@@ -505,7 +539,9 @@ if echo $rootdev |grep -q /dev/mapper 2>/dev/null ; then
 fi
 
 [ ! -x /usr/sbin/module_upgrade ] || /usr/sbin/module_upgrade
-[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install %{KVERREL}
+#[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install %{KVERREL}
+# Older modutils do not support --package option
+[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}
 
 # remove fake handle
 if [ -n "$fake_root_lvm" ]; then
@@ -532,8 +568,37 @@ popd > /dev/null
 fi
 
 %post smp
+# trick mkinitrd in case the current environment does not have device mapper
+rootdev=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' /etc/fstab)
+if echo $rootdev |grep -q /dev/mapper 2>/dev/null ; then
+    if [ ! -f $rootdev ]; then
+       fake_root_lvm=1
+       mkdir -p $(dirname $rootdev)
+       touch $rootdev
+    fi
+fi
+
 [ ! -x /usr/sbin/module_upgrade ] || /usr/sbin/module_upgrade
-[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --package kernel-smp --mkinitrd --depmod --install %{KVERREL}smp
+#[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --package kernel-smp --mkinitrd --depmod --install %{KVERREL}smp
+# Older modutils do not support --package option
+[ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}smp
+
+# remove fake handle
+if [ -n "$fake_root_lvm" ]; then
+    rm -f $rootdev
+fi
+
+# make some useful links
+pushd /boot > /dev/null ; {
+       ln -sf config-%{KVERREL}smp configsmp
+       ln -sf initrd-%{KVERREL}smp.img initrd-bootsmp
+       ln -sf vmlinuz-%{KVERREL}smp kernel-bootsmp
+}
+popd > /dev/null
+
+# ask for a reboot
+mkdir -p /etc/planetlab
+touch /etc/planetlab/update-reboot
 
 %post smp-devel
 if [ -x /usr/sbin/hardlink ] ; then