Whamcloud - gitweb
b=18656
authorbrian <brian>
Wed, 25 Mar 2009 18:26:33 +0000 (18:26 +0000)
committerbrian <brian>
Wed, 25 Mar 2009 18:26:33 +0000 (18:26 +0000)
i=yangsheng
i=wangyb

Enable lbuild to build Xen DomU kernel and lustre packages.

build/lbuild
build/lmake
build/lustre-kernel-2.4.spec.in

index 2d008a0..e662666 100755 (executable)
@@ -35,6 +35,7 @@ SKIPLDISKFSRPM="v1_4_* b1_4"
 SMPTYPES="smp bigsmp default ''"
 KERNCONFSMPTYPE=
 PATCHLESS=false
 SMPTYPES="smp bigsmp default ''"
 KERNCONFSMPTYPE=
 PATCHLESS=false
+XEN=false
 LINUXOBJ=
 REUSEDKERNELMASK=
 DISTRO=
 LINUXOBJ=
 REUSEDKERNELMASK=
 DISTRO=
@@ -220,6 +221,9 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
     checkouts. This is a workaround for a problem encountered when 
     using lbuild with tinderbox.
 
     checkouts. This is a workaround for a problem encountered when 
     using lbuild with tinderbox.
 
+  --xen
+    Builds a Xen domX kernel.
+
 EOF
 
 #   list_targets
 EOF
 
 #   list_targets
@@ -404,6 +408,11 @@ load_target()
 
     . "$TARGET_FILE"
 
 
     . "$TARGET_FILE"
 
+    # doesn't make any sense to build OFED for xen domX's
+    if $XEN; then
+        OFED_VERSION=""
+    fi
+
     [ "$KERNEL"  ] || fatal 1 "Target $TARGET did not specify a kernel."
     [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
 
     [ "$KERNEL"  ] || fatal 1 "Target $TARGET did not specify a kernel."
     [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
 
@@ -463,14 +472,18 @@ load_target()
         done
     fi
 
         done
     fi
 
+    local XENPOSTFIX=""
+    if $XEN; then
+        XENPOSTFIX="-xen"
+    fi
     if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
     if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
-        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config"
+        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH.config"
     fi
     local smptype
     for smptype in $SMPTYPES; do
         [ "$smptype" = "''" ] && smptype=
         if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config ]; then
     fi
     local smptype
     for smptype in $SMPTYPES; do
         [ "$smptype" = "''" ] && smptype=
         if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config ]; then
-        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config"
+        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH-${smptype}.config"
         KERNCONFSMPTYPE=$smptype
     fi
     done
         KERNCONFSMPTYPE=$smptype
     fi
     done
@@ -650,6 +663,10 @@ clean_linux()
 
 prep_kernel_build()
 {
 
 prep_kernel_build()
 {
+    local lmakeopts=""
+    if $XEN; then
+        lmakeopts="--xen"
+    fi
     # make .spec file
     ENABLE_INIT_SCRIPTS=""
     sed \
     # make .spec file
     ENABLE_INIT_SCRIPTS=""
     sed \
@@ -674,6 +691,7 @@ prep_kernel_build()
         -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
         -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
         -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
         -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
         -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
         -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
+        -e "s^@LMAKEOPTS@^$lmakeopts^g" \
         < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
         > lustre-kernel-2.4.spec
     [ -d SRPMS ] || mkdir SRPMS
         < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
         > lustre-kernel-2.4.spec
     [ -d SRPMS ] || mkdir SRPMS
@@ -1563,7 +1581,7 @@ build_sequence()
 
 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
 
 
 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
 
-options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,src,stage:,tag:,target:,target-archs:,with-linux: -- "$@")
+options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,src,stage:,tag:,target:,target-archs:,with-linux:,xen -- "$@")
 
 if [ $? != 0 ] ; then
     usage 1
 
 if [ $? != 0 ] ; then
     usage 1
@@ -1686,6 +1704,10 @@ while [ "$1" ] ; do
             USE_DATESTAMP=
             shift
             ;;
             USE_DATESTAMP=
             shift
             ;;
+        --xen)
+            XEN=true
+            shift
+            ;;
         --)
             shift
             CONFIGURE_FLAGS=$@
         --)
             shift
             CONFIGURE_FLAGS=$@
index c9b22ea..a018011 100755 (executable)
@@ -47,6 +47,7 @@ KERNEL_FILE=
 SERIES_FILE=
 CONFIG_FILE=
 RPMBUILD=
 SERIES_FILE=
 CONFIG_FILE=
 RPMBUILD=
+XEN=false
 
 canon()
 {
 
 canon()
 {
@@ -160,6 +161,9 @@ Options:
   --unpack-kernel
     Untars and patches the kernel source.
 
   --unpack-kernel
     Untars and patches the kernel source.
 
+  --xen
+    Builds a Xen domX kernel.
+
   The order that commands (--build-lustre, --unpack-kernel) are
   specified on the command line is ignored; ${0##*/} will always
   execute them in the correct order (unpack, then build, then install
   The order that commands (--build-lustre, --unpack-kernel) are
   specified on the command line is ignored; ${0##*/} will always
   execute them in the correct order (unpack, then build, then install
@@ -228,6 +232,11 @@ load_target()
 
     . "$TARGET_FILE"
 
 
     . "$TARGET_FILE"
 
+    # doesn't make any sense to build OFED for xen domX's
+    if $XEN; then
+        OFED_VERSION=""
+    fi
+
     [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
 # Suse 2.6 has our patches in already
 #    [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series."
     [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
 # Suse 2.6 has our patches in already
 #    [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series."
@@ -248,8 +257,13 @@ load_target()
        done
     fi
 
        done
     fi
 
+    local XENPOSTFIX=""
+    if $XEN; then
+        XENPOSTFIX="-xen"
+    fi
+
     TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS}
     TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS}
-    CONFIG_TARGET="$TARGET-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
+    CONFIG_TARGET="${TARGET}${XENPOSTFIX}-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
     CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config"
     [ -r "$CONFIG_FILE" ] ||
        fatal 1 "Target $TARGET's config file $CONFIG_FILE missing from $TOPDIR/lustre/kernel_patches/configs."
     CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config"
     [ -r "$CONFIG_FILE" ] ||
        fatal 1 "Target $TARGET's config file $CONFIG_FILE missing from $TOPDIR/lustre/kernel_patches/configs."
@@ -484,17 +498,21 @@ build_kernel()
     (( $BUILD_KERNEL )) || return 0
     set_make
     echo "Building kernel in $PWD..."
     (( $BUILD_KERNEL )) || return 0
     set_make
     echo "Building kernel in $PWD..."
-    case "$TARGET_ARCH" in
-       i386 | i586 | i686 | athlon | x86_64)
-           $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
-           ;;
-    ia64 | ppc | ppc64)
-           $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
-           ;;
-       *)
-           $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
-           ;;
-    esac
+    if $XEN; then
+        $MAKE_J "$MAKE_CC" vmlinuz || fatal 1 "Error making vmlinux."
+    else
+        case "$TARGET_ARCH" in
+           i386 | i586 | i686 | athlon | x86_64)
+               $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
+               ;;
+            ia64 | ppc | ppc64)
+               $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
+               ;;
+           *)
+               $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
+               ;;
+        esac
+    fi
     $MAKE_J "$MAKE_CC" modules || fatal 1 "Error building modules."
 
     popd >/dev/null
     $MAKE_J "$MAKE_CC" modules || fatal 1 "Error building modules."
 
     popd >/dev/null
@@ -592,37 +610,42 @@ install_kernel()
        -s modules_install || \
        fatal 1 "Error installing modules."
 
        -s modules_install || \
        fatal 1 "Error installing modules."
 
-    case "$TARGET_ARCH" in
-       i386 | i586 | i686 | athlon)
-           cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-           cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-           ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-           ;;
-       x86_64)
-           cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-           cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-           ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-           ;;
-        ppc | ppc64)
-           cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-           ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" 
-           ;;
-       ia64)
-           gzip -cfv vmlinux > vmlinuz
-           mkdir -p "$DESTDIR/boot/efi/redhat"
-           install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-           install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
-           ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
-           ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-           ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-           ;;
-       *)
-           cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-           cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
-           ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-
-           ;;
-    esac
+    if $XEN; then
+       cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+       cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
+       ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+    else
+        case "$TARGET_ARCH" in
+           i386 | i586 | i686 | athlon)
+               cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+               cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+               ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ;;
+           x86_64)
+               cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+               cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+               ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ;;
+            ppc | ppc64)
+               cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" 
+               ;;
+           ia64)
+               gzip -cfv vmlinux > vmlinuz
+               mkdir -p "$DESTDIR/boot/efi/redhat"
+               install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+               install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
+               ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
+               ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+               ;;
+           *)
+               cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+               cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
+               ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+               ;;
+       esac
+    fi
     if [ -e init/kerntypes.o ] ; then
        cp init/kerntypes.o "$DESTDIR/boot/Kerntypes-${FULL_VERSION}"
     fi
     if [ -e init/kerntypes.o ] ; then
        cp init/kerntypes.o "$DESTDIR/boot/Kerntypes-${FULL_VERSION}"
     fi
@@ -764,7 +787,7 @@ save_all_headers()
 
 longopts="build,build-lustre,build-kernel,depend-kernel,destdir:,extraversion:"
 longopts="$longopts,help,install,install-lustre,install-kernel,kerneldir:"
 
 longopts="build,build-lustre,build-kernel,depend-kernel,destdir:,extraversion:"
 longopts="$longopts,help,install,install-lustre,install-kernel,kerneldir:"
-longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel"
+longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel,xen"
 
 options=$(getopt -o hj: -l "$longopts" -- "$@")
 
 
 options=$(getopt -o hj: -l "$longopts" -- "$@")
 
@@ -847,6 +870,10 @@ while [ "$1" ] ; do
            UNPACK_KERNEL=1
            shift
            ;;
            UNPACK_KERNEL=1
            shift
            ;;
+        --xen)
+            XEN=true
+            shift
+            ;;
        --)
            shift
            CONFIGURE_FLAGS=$@
        --)
            shift
            CONFIGURE_FLAGS=$@
index 804e65c..15b73b6 100644 (file)
@@ -25,6 +25,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define rhbuild @RHBUILD@
 %define susebuild @SUSEBUILD@
 %define linux26 @LINUX26@
 %define rhbuild @RHBUILD@
 %define susebuild @SUSEBUILD@
 %define linux26 @LINUX26@
+%define lmakeopts @LMAKEOPTS@
 
 # disable build root strip policy
 %define __spec_install_post /usr/lib/rpm/brp-compress || :
 
 # disable build root strip policy
 %define __spec_install_post /usr/lib/rpm/brp-compress || :
@@ -42,7 +43,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define dashtargetboard %{?targetboard:-%{targetboard}}
 %define withtargetboard 0
 %{?targetboard: %{expand: %%define withtargetboard 1}}
 %define dashtargetboard %{?targetboard:-%{targetboard}}
 %define withtargetboard 0
 %{?targetboard: %{expand: %%define withtargetboard 1}}
-       
+
 # Override generic defaults with per-arch defaults (which can
 # themselves be overridden with --with/--without).  These must
 # ONLY be "0", never "1"
 # Override generic defaults with per-arch defaults (which can
 # themselves be overridden with --with/--without).  These must
 # ONLY be "0", never "1"
@@ -384,7 +385,7 @@ sh -x ./build/lmake \
        --unpack-kernel \
        --target @LUSTRE_TARGET@ \
        --target-arch %{_target_cpu} \
        --unpack-kernel \
        --target @LUSTRE_TARGET@ \
        --target-arch %{_target_cpu} \
-       --kerneldir $RPM_SOURCE_DIR
+       --kerneldir $RPM_SOURCE_DIR %{lmakeopts}
 popd >/dev/null
 
 # handle both SuSE and Red Hat's new-kernel-pkg bits
 popd >/dev/null
 
 # handle both SuSE and Red Hat's new-kernel-pkg bits
@@ -521,7 +522,7 @@ DependKernel()
        --target-arch %{_target_cpu} \
        ${target_config} \
        --extraversion %{kextraver} \
        --target-arch %{_target_cpu} \
        ${target_config} \
        --extraversion %{kextraver} \
-       -j $RPM_BUILD_NCPUS
+       -j $RPM_BUILD_NCPUS %{lmakeopts}
 }
 
 BuildKernel()
 }
 
 BuildKernel()
@@ -537,7 +538,7 @@ BuildKernel()
        --extraversion %{kextraver} \
        --kerneldir $RPM_SOURCE_DIR \
        -j $RPM_BUILD_NCPUS \
        --extraversion %{kextraver} \
        --kerneldir $RPM_SOURCE_DIR \
        -j $RPM_BUILD_NCPUS \
-       --destdir $RPM_BUILD_ROOT \
+       --destdir $RPM_BUILD_ROOT %{lmakeopts} \
        -- --enable-tests \
        @CONFIGURE_FLAGS@
 }
        -- --enable-tests \
        @CONFIGURE_FLAGS@
 }
@@ -554,7 +555,7 @@ BuildLustre()
        --extraversion %{kextraver} \
        --kerneldir $RPM_SOURCE_DIR \
        -j $RPM_BUILD_NCPUS \
        --extraversion %{kextraver} \
        --kerneldir $RPM_SOURCE_DIR \
        -j $RPM_BUILD_NCPUS \
-       --destdir $RPM_BUILD_ROOT \
+       --destdir $RPM_BUILD_ROOT %{lmakeopts} \
        -- --enable-utils \
        --disable-doc --disable-tests \
        --disable-modules --disable-liblustre \
        -- --enable-utils \
        --disable-doc --disable-tests \
        --disable-modules --disable-liblustre \
@@ -570,7 +571,7 @@ SaveHeaders()
        --target @LUSTRE_TARGET@ \
        --target-arch %{_target_cpu} \
        --extraversion %{kextraver} \
        --target @LUSTRE_TARGET@ \
        --target-arch %{_target_cpu} \
        --extraversion %{kextraver} \
-       --destdir $RPM_BUILD_ROOT
+       --destdir $RPM_BUILD_ROOT %{lmakeopts}
 }
 
 pushd lustre >/dev/null
 }
 
 pushd lustre >/dev/null
@@ -645,7 +646,7 @@ BuildObj ()
            if grep -q "$oc" Makefile ; then
                OLDCONFIG="$oc"
                break
            if grep -q "$oc" Makefile ; then
                OLDCONFIG="$oc"
                break
-           fi
+           fi
         done
        MAKE="make -s O=$o -C ${c}"
        if [ "$CC" ] ; then
         done
        MAKE="make -s O=$o -C ${c}"
        if [ "$CC" ] ; then
@@ -732,7 +733,7 @@ if [ "%{buildbase}" -ne 0 ] ; then
            if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
                OLDCONFIG="$oc"
                break
            if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
                OLDCONFIG="$oc"
                break
-           fi
+           fi
         done
        if [ "$CC" ] ; then
            MAKE_CC="CC=$CC"
         done
        if [ "$CC" ] ; then
            MAKE_CC="CC=$CC"