Whamcloud - gitweb
b=20744 hacks for Novell bug 639581
[fs/lustre-release.git] / build / lbuild-rhel5
index 6e17d49..11d9545 100644 (file)
@@ -1,6 +1,13 @@
 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
 
+# increment this if you have made a change that should force a new kernel
+# to build built
+#BUILD_GEN=1
+#BUILD_GEN=2   # bz19952: remove -lustre tag from kernel RPM names
+BUILD_GEN=3    # bz19975 enable the building of src.rpms by default
+
 DEVEL_KERNEL_TYPE="devel"
+RPM_HELPERS_DIR="/usr/lib/rpm/redhat"
 
 prepare_and_build_srpm() {
 
@@ -33,7 +40,10 @@ EOF
     # 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 '/-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 '/^# empty final patch file to facilitate testing of kernel patches/i\
 # adds Lustre patches\
 Patch99995: linux-%{kversion}-lustre.patch' \
@@ -42,31 +52,56 @@ Patch99995: linux-%{kversion}-lustre.patch' \
 %patch99995 -p1\
 ' \
            -e '/^%prep$/,/^# END OF PATCH APPLICATIONS$/s/kernel-%{kversion}/%{name}-%{kversion}/g' \
-           -e '/^Provides: glibc-kernheaders = /a\
+           -e '/find $RPM_BUILD_ROOT\/lib\/modules\/$KernelVer/a\
+    cp -a fs/ext3/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext3 \
+    cp -a fs/ext4/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext4' \
+          SPECS/kernel-2.6.spec 2>&1 || \
+        fatal 1 "Error while editing SPECS/kernel-2.6.spec"
+
+    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
+              SPECS/kernel-2.6.sp 2>&1 || \
+            fatal 1 "Error while editing SPECS/kernel-2.6.spec"ec
+    fi
 
     # 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
+               -e 's/sha512hmac/md5sum/g' \
+            SPECS/kernel-2.6.spec 2>&1 || \
+                fatal 1 "Error while editing SPECS/kernel-2.6.spec"
     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"
+    # 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/kernel-2.6.spec; 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/kernel-2.6.spec"
 --- 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
 @@ -6961,6 +6961,10 @@
@@ -81,6 +116,7 @@ Provides: kernel-debuginfo = %{KVERREL}
        cp -a asm-i386 $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
      fi
 EOF
+    fi
 
     popd >/dev/null
 
@@ -131,10 +167,12 @@ EOF
     # 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"
+                   $TOPDIR/SPECS/kernel-2.6.spec 2>&1; then
+        return 1
     fi
 
+    return 0
+
 }
 
 devel_kernel_name() {
@@ -147,3 +185,55 @@ devel_kernel_name() {
     fi
 
 }
+
+rpm_BUILD_kernel_dirname() {
+    local rpmsmptype="$1"
+    local lnxmaj="$2"
+    local lnxmin="$3"
+    local arch="$4"
+
+    local lustre=""
+    if $KERNEL_LUSTRE_NAMING; then
+        $lustre="-lustre"
+    fi
+    echo kernel${lustre}${lnxmaj}${lnxmin}/linux-${lnxmaj}.$arch
+}
+
+find_linux_devel_paths() {
+    local path="$1"
+    local ARCH=$TARGET_ARCH
+
+    # If DEVEL_PATH_ARCH is set, use it. Added for fc11 as it needs i586 string for i686.
+    if [ $DEVEL_PATH_ARCH ];then
+        ARCH=$DEVEL_PATH_ARCH
+    fi
+
+    LINUX=$path/usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}${DEVEL_PATH_ARCH_DELIMETER:-"-"}${ARCH}
+    # RHEL doesn't have the -obj tree
+    LINUXOBJ=""
+    # XXX - i don't think we need this any more
+    #LINUXRELEASE=$(find_linux_release "$LINUX")
+    #if [ -z "$LINUXRELEASE" ]; then
+    #    echo "Failed to find linux release in $LINUX"
+    #    return 255
+    #fi
+
+    return 0
+}
+
+unpack_linux_devel_rpm-rhel5() {
+    local callers_rpm="$1"
+
+    # now just sanity check that everything needed to build properly versioned
+    # modules is in place
+    if [ ! -f usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}-$TARGET_ARCH/Module.symvers ]; then
+        fatal 1 "cannot build kernel modules: the Kernel's Module.symvers is missing."
+    fi
+
+    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
+
+}