Whamcloud - gitweb
LU-73 lbuild and friends for RHEL6
[fs/lustre-release.git] / build / lbuild-rhel5
index 6e17d49..1ab4b8a 100644 (file)
@@ -1,74 +1,73 @@
 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
 
-DEVEL_KERNEL_TYPE="devel"
+# increment this if you have made a change that should force a new kernel
+# to be built for this release of this distribution (only -- if you want to
+# force a kernel build on all releases of this distribution, update the BUILD_GEN
+# variable in build/lbuild-rhel and if you want to force kernel bulid for all
+# distributions, update the BUILD_GEN variable in build/lbuild)
+BUILD_GEN+=".0"
 
-prepare_and_build_srpm() {
+source ${0%/*}/lbuild-rhel
 
-    pushd $TOPDIR >/dev/null
-    local GCC_VER=""
-    read GCC_VER < <($CC --version)
-    GCC_VER=${GCC_VER##* }
-    if [[ $GCC_VER = 4.3* ]]; then
-        # add the gcc 4.3 kernel build fix patch to it
-       cat <<"EOF" >> $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch
-diff -urp linux-2.6.18.rawops/Makefile linux-2.6.18.races/Makefile
---- linux-2.6.18.rawops/Makefile       2007-02-08 19:00:31.000000000 +0200
-+++ linux-2.6.18.rawops/Makefile       2007-02-14 19:23:49.000000000 +0200
-@@ -506,6 +506,9 @@ KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
- # disable pointer signed / unsigned warnings in gcc 4.0
- CFLAGS += $(call cc-option,-Wno-pointer-sign,)
+SPEC_NAME="kernel-2.6.spec"
 
-+# workaround to avoid gcc 4.3 emitting libgcc calls (see gcc bug #32044)
-+CFLAGS += $(call cc-option,-fno-tree-scev-cprop,)
-+
- # Default kernel image to build when no specific target is given.
- # KBUILD_IMAGE may be overruled on the command line or
- # set in the environment
-EOF
-    fi
-
-    # create the buildid
-    local buildid="_lustre${EXTRA_VERSION##*_lustre}"
+patch_spec() {
+    local buildid="$1"
 
     # edit the SPEC with our changes
-    sed -i -e 's/^\(%define signmodules \).*/\10/' \
-           -e "s/^#% \(define buildid\).*/%\1 ${buildid}/" \
-           -e 's/^\(Name:.*kernel\)/\1-lustre/' \
-           -e '/^# empty final patch file to facilitate testing of kernel patches/i\
+    patch_spec_common "$buildid"
+    sed -i -e '/^# empty final patch file to facilitate testing of kernel patches/i\
 # adds Lustre patches\
 Patch99995: linux-%{kversion}-lustre.patch' \
            -e '/^# conditionally applied test patch for debugging convenience/i\
 # lustre patch\
 %patch99995 -p1\
 ' \
+           -e '/-e $RPM_SOURCE_DIR\/kabi_whitelist_/i\
+    rm -f $RPM_SOURCE_DIR/kabi_whitelist_%{_target_cpu}$Flavour' \
+           -e '/_sourcedir\/kabitool -b \./a\
+    cp $RPM_BUILD_ROOT/kabi_whitelist $RPM_SOURCE_DIR/kabi_whitelist_%{_target_cpu}$Flavour' \
            -e '/^%prep$/,/^# END OF PATCH APPLICATIONS$/s/kernel-%{kversion}/%{name}-%{kversion}/g' \
-           -e '/^Provides: glibc-kernheaders = /a\
+          SPECS/$SPEC_NAME 2>&1 || \
+        fatal 1 "Error while editing SPECS/$SPEC_NAME"
+
+    if $KERNEL_LUSTRE_NAMING; then
+        # these are all of the changes needed because we change the package names
+        # to kernel-lustre-*.  these should all go away when we stop this insanity
+        sed -i -e 's/^\(Name:.*kernel\)/\1-lustre/' \
+               -e '/^Provides: glibc-kernheaders = /a\
 Provides: kernel-headers = %{rpmversion}-%{release}
+Obsoletes: kernel-headers
+' \
+               -e '/^Provides: kernel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
+Provides: kernel = %{rpmversion}-%{release}
 ' \
-           -e '/^Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
+               -e '/^Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
 Provides: kernel-devel = %{rpmversion}-%{release}
+Obsoletes: kernel-devel
 ' \
-           -e '/^Provides: %{name}-debuginfo-common-%{_target_cpu} = %{KVERREL}$/a\
+               -e '/^Provides: %{name}-debuginfo-common-%{_target_cpu} = %{KVERREL}$/a\
 Provides: kernel-debuginfo-common = %{KVERREL}
+Obsoletes: kernel-debuginfo-common
 ' \
-           -e '/^Provides: %{name}-debuginfo-%{_target_cpu} = %{KVERREL}$/a\
+               -e '/^Provides: %{name}-debuginfo-%{_target_cpu} = %{KVERREL}$/a\
 Provides: kernel-debuginfo = %{KVERREL}
+Obsoletes: kernel-debuginfo
 ' \
-          SPECS/kernel-2.6.spec
-
-    # XXX - a building-on-Ubuntu hack
-    if grep -q "Ubuntu" /etc/issue; then
-        sed  -i -e 's/^\(BuildPreReq: .*\)$/#NOU \1/g' \
-               -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
-          SPECS/kernel-2.6.spec
+              SPECS/$SPEC_NAME 2>&1 || \
+            fatal 1 "Error while editing SPECS/$SPEC_NAME"
     fi
 
-    # finally, work around RH bug 491775
-    # XXX - i wonder if we will need to do this enough to formalize a
-    #       patching system.  let's assume not for the time being.
-    patch -s -p0 <<"EOF"
---- SPECS/kernel-2.6.spec.dist 2009-03-23 20:30:55.000000000 -0400
-+++ SPECS/kernel-2.6.spec      2009-03-23 20:37:03.000000000 -0400
+    # finally, work around RH bug 491775, if needed
+    if ! grep -q "cp -a asm-x86_64 \$RPM_BUILD_ROOT/lib/modules/\$KernelVer/build/include" \
+              SPECS/$SPEC_NAME; then
+        # XXX - i wonder if we will need to do this ad-hoc patching enough to
+        #       formalize a patching system.  let's assume not for the time
+        #       being.
+        patch -s -p0 <<"EOF" 2>&1 || \
+            fatal 1 "Error while patching SPECS/$SPEC_NAME"
+--- SPECS/$SPEC_NAME.dist      2009-03-23 20:30:55.000000000 -0400
++++ SPECS/$SPEC_NAME   2009-03-23 20:37:03.000000000 -0400
 @@ -6961,6 +6961,10 @@
      cd include
      cp -a acpi config keys linux math-emu media mtd net pcmcia rdma rxrpc scsi sound video asm asm-generic $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
@@ -81,69 +80,21 @@ Provides: kernel-debuginfo = %{KVERREL}
        cp -a asm-i386 $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
      fi
 EOF
-
-    popd >/dev/null
-
-    # this concept of being able to build a list of targets with a single
-    # lbuild is a fine idea, but in reality I think it's (very) broken.  I
-    # don't even think the lustre.spec can handle being called with "--target
-    # <multiple arches>".  It certainly can't handle the issue where each
-    # arch has it's own kernel location.
-    # but we will do the best we can and put the plumbing in place so that
-    # this could work when the other broken bits are fixed.
-    # in reality, our current use of lbuild only ever has a single arch in
-    # $BUILD_ARCHS
-    local arch
-    local targets=""
-    for arch in $BUILD_ARCHS; do
-        # XXX - ok.  so here's a hack that needs to be fixed properly
-        #       ppc64 was merged to ppc some time ago pre 2.6.18
-        if [ $arch = ppc64 ]; then
-            arch=ppc
-        fi
-        targets="--target $arch $targets"
-        # copy our .config into the RPM build tree
-        (echo "# $(basearch $arch)"; cat $CONFIG_FILE) > \
-            SOURCES/kernel-2.6.18-$arch.config
-
-        # XXX - hackity hack -- until we get (or generate from the base
-        #                       config) configs for xen and debug
-        local f=""
-        for f in SOURCES/kernel-${lnxmaj}-*.config; do
-            grep -q "^CONFIG_SD_IOSTATS=y" $f || \
-                echo "CONFIG_SD_IOSTATS=y" >> $f
-        done
-    done
-
-    # do we need any special rpm build options
-    local rpmbuildopt="-bb"
-    if $DO_SRC; then
-        rpmbuildopt="-ba"
-    fi
-    # stupid Ubuntu's rpm doesn't do debuginfo properly
-    if [ ! -f /usr/lib/rpm/debugedit ]; then
-        rpmbuildopt="$rpmbuildopt --without debuginfo"
     fi
 
-    # XXX - need to figure this kabichk crap out -- it fails the build
-    rpmbuildopt="$rpmbuildopt --without kabichk"
-
-    # now build it
-    if ! $RPMBUILD $rpmbuildopt $targets --with baseonly \
-                   --define "_topdir $TOPDIR" \
-                   $TOPDIR/SPECS/kernel-2.6.spec >&2; then
-        fatal 1 "Failed to build kernel RPM"
-    fi
+    return 0
 
 }
 
-devel_kernel_name() {
-    local lustre=${1:-false}
+unpack_linux_devel_rpm-rhel5() {
+    local callers_rpm="$1"
+
+    unpack_linux_devel_rpm-rhel "$callers_rpm"
 
-    if $lustre; then
-        echo "kernel-lustre-$DEVEL_KERNEL_TYPE"
-    else
-        echo "kernel-$DEVEL_KERNEL_TYPE"
+    if [ ! -f usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}-$TARGET_ARCH/symsets-${lnxmaj}${lnxmin}-${lnxrel}.tar.gz ]; then
+        fatal 1 "cannot build modules: the Kernel's symsets is missing."
     fi
 
+    return 0
+
 }