From cbef177a79dcea9022fdaa2c292cd2fd4b1cf65d Mon Sep 17 00:00:00 2001 From: brian <brian> Date: Wed, 25 Mar 2009 18:26:33 +0000 Subject: [PATCH] b=18656 i=yangsheng i=wangyb Enable lbuild to build Xen DomU kernel and lustre packages. --- build/lbuild | 28 +++++++- build/lmake | 115 ++++++++++++++++++++------------ build/lustre-kernel-2.4.spec.in | 17 ++--- 3 files changed, 105 insertions(+), 55 deletions(-) diff --git a/build/lbuild b/build/lbuild index 2d008a0255..e662666d37 100755 --- a/build/lbuild +++ b/build/lbuild @@ -35,6 +35,7 @@ SKIPLDISKFSRPM="v1_4_* b1_4" SMPTYPES="smp bigsmp default ''" KERNCONFSMPTYPE= PATCHLESS=false +XEN=false 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. + --xen + Builds a Xen domX kernel. + EOF # list_targets @@ -404,6 +408,11 @@ load_target() . "$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." @@ -463,14 +472,18 @@ load_target() 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 - 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 - 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 @@ -650,6 +663,10 @@ clean_linux() prep_kernel_build() { + local lmakeopts="" + if $XEN; then + lmakeopts="--xen" + fi # 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^@LMAKEOPTS@^$lmakeopts^g" \ < $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 -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 @@ -1686,6 +1704,10 @@ while [ "$1" ] ; do USE_DATESTAMP= shift ;; + --xen) + XEN=true + shift + ;; --) shift CONFIGURE_FLAGS=$@ diff --git a/build/lmake b/build/lmake index c9b22eab19..a0180119ba 100755 --- a/build/lmake +++ b/build/lmake @@ -47,6 +47,7 @@ KERNEL_FILE= SERIES_FILE= CONFIG_FILE= RPMBUILD= +XEN=false canon() { @@ -160,6 +161,9 @@ Options: --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 @@ -228,6 +232,11 @@ load_target() . "$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." @@ -248,8 +257,13 @@ load_target() done fi + local XENPOSTFIX="" + if $XEN; then + XENPOSTFIX="-xen" + fi + 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." @@ -484,17 +498,21 @@ build_kernel() (( $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 @@ -592,37 +610,42 @@ install_kernel() -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 @@ -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="$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" -- "$@") @@ -847,6 +870,10 @@ while [ "$1" ] ; do UNPACK_KERNEL=1 shift ;; + --xen) + XEN=true + shift + ;; --) shift CONFIGURE_FLAGS=$@ diff --git a/build/lustre-kernel-2.4.spec.in b/build/lustre-kernel-2.4.spec.in index 804e65cc52..15b73b60f0 100644 --- a/build/lustre-kernel-2.4.spec.in +++ b/build/lustre-kernel-2.4.spec.in @@ -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 lmakeopts @LMAKEOPTS@ # 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}} - + # 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} \ - --kerneldir $RPM_SOURCE_DIR + --kerneldir $RPM_SOURCE_DIR %{lmakeopts} 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} \ - -j $RPM_BUILD_NCPUS + -j $RPM_BUILD_NCPUS %{lmakeopts} } BuildKernel() @@ -537,7 +538,7 @@ BuildKernel() --extraversion %{kextraver} \ --kerneldir $RPM_SOURCE_DIR \ -j $RPM_BUILD_NCPUS \ - --destdir $RPM_BUILD_ROOT \ + --destdir $RPM_BUILD_ROOT %{lmakeopts} \ -- --enable-tests \ @CONFIGURE_FLAGS@ } @@ -554,7 +555,7 @@ BuildLustre() --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 \ @@ -570,7 +571,7 @@ SaveHeaders() --target @LUSTRE_TARGET@ \ --target-arch %{_target_cpu} \ --extraversion %{kextraver} \ - --destdir $RPM_BUILD_ROOT + --destdir $RPM_BUILD_ROOT %{lmakeopts} } pushd lustre >/dev/null @@ -645,7 +646,7 @@ BuildObj () if grep -q "$oc" Makefile ; then OLDCONFIG="$oc" break - fi + fi 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 - fi + fi done if [ "$CC" ] ; then MAKE_CC="CC=$CC" -- GitLab