3 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
9 # CVSROOT is inherited from the environment
19 TARGET_ARCH=$(uname -m)
21 TARGET_ARCHS_ALL=$TARGET_ARCH
22 [ "$TARGET_ARCH" = "i686" ] && TARGET_ARCHS_ALL="i686 i586 i386"
28 TMPDIR=${TMPDIR:-"/var/tmp"}
34 SKIPLDISKFSRPM="v1_4_* b1_4"
35 SMPTYPES="smp bigsmp default ''"
80 # Readlink is not present on some older distributions: emulate it.
84 if [ -L "$path" ]; then
85 ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
99 [ "$1" ] && echo -e "\n${0##*/}: $1"
111 echo -n "Available targets:"
112 for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do
113 target_file=${target##*/}
114 echo -n " ${target_file%%.target}"
122 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
125 Specifies the CVS Root to use when pulling files from CVS. The
126 environment variable \$CVSROOT is used if this option is not
129 --external-patches=EXTERNAL_PATCHES
130 Directory similar to lustre/lustre/kernel_patches/ that lbuild should
131 look for seres and config files in before looking in the lustre
134 --extraversion=EXTRAVERSION
135 Text to use for the rpm release and kernel extraversion.
137 --kerneldir=KERNELDIR
138 Directory containing Linux source tarballs referenced by target
141 --timestamp=TIMESTAMP
142 Date of building lustre in format YYYYMMDDhhmmss
145 Try to reuse old kernel RPMs from DIR
148 Try to reuse old kernel builds from DIR
151 Path to distro kernel RPM collection
157 Do not build RPMs (compile only mode)
160 Build lustre client only
163 Which distro using. Autodetect by default
165 --kerneltree=KERNELTREE
166 Directory containing dirs with Linux source tarballs referenced by target
167 files. Dir names in format kernel version ('2.6.9', etc.)
170 Directory of Linux kernel sources. When this option is used, only
171 Lustre modules and userspace are built.
174 Path to an existing lustre source tarball to use instead of
178 Do not try to download a kernel from downloads.lustre.org
181 Do not build a .src.rpm, a full kernel patch, or a patched kernel
185 Do ldiskfs RPM. Now true by default
191 Specifies that the files generated do not include timestamps, and
192 that this is an official release.
195 Build a .src.rpm, a full kernel patch, and a patched kernel tarball.
198 Directory used to stage packages for release. RPMs will be placed
199 more or less in DIR/<target>-<arch>, and the tarball will be
203 A CVS branch/tag name to build from when pulling from CVS.
206 The name of the target to build. The available targets are listed
209 --target-archs=TARGET_ARCHS
210 A (space delimited) list of architectures to build. By default,
211 all of the archs supported by the TARGET will be built, in
212 addition to a .src.rpm. This option can limit those, for machines
213 that can only build certain archs or if you only want a certain
214 arch built (for testing, or a one-off kernel).
216 Also note that by using a non-"base" arch (eg, i386) only kernels
217 will be built - there will be no lustre-lite-utils package.
220 Prevents the datestamp flag (-D) from being passed to cvs for
221 checkouts. This is a workaround for a problem encountered when
222 using lbuild with tinderbox.
225 Builds a Xen domX kernel.
236 if [ "$LUSTRE" ] ; then
237 [ -r "$LUSTRE" ] || \
238 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
241 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
243 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
246 if [ -z "$LINUX" ] ; then
247 [ "$KERNELDIR" -o "$KERNELTREE" ] || \
248 usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree."
250 [ -d "$KERNELDIR" -o -d "$KERNELTREE" ] || \
251 usage 1 "$KERNELDIR and $KERNELTREE are not a directory."
255 usage 1 "When building a snapshot, a tag name must be used."
258 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
259 # TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
260 # [ -r "$TARGET_FILE" ] || \
261 # usage 1 "Target '$TARGET' was not found."
266 CANONICAL_TARGET="rhel5"
269 CANONICAL_TARGET="rhel-2.6"
272 CANONICAL_TARGET="sles-2.6"
275 CANONICAL_TARGET="sles10-2.6"
278 CANONICAL_TARGET="hp-pnnl-2.4"
286 CANONICAL_TARGET="$TARGET"
290 local timestampnodig=$(echo $TIMESTAMP | sed -e s/[0-9]*//g)
291 [ "$timestampnodig" = "" ] || TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
292 local timestamplength="${#TIMESTAMP}"
293 if [ $timestamplength -eq 12 ]; then
294 TIMESTAMP="${TIMESTAMP}00"
295 elif [ $timestamplength -ne 14 ]; then
296 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
299 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
300 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
301 RPMBUILD=$(which rpm 2>/dev/null | head -1)
302 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
303 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
307 if [ -n "$CCACHE" ]; then
308 which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc"
309 which "$DISTCC" 2>/dev/null && export DISTCC RPM_BUILD_NCPUS
310 local bindir="/cache/build/bin"
311 [ -d $bindir ] || mkdir -p $bindir
312 [ -d $bindir ] && rm ${bindir}/* > /dev/null 2>&1
313 which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/ccache
314 which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/cc
315 which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/gcc
316 [ -d $bindir ] && export PATH=$bindir:$PATH
319 [ -z "$DISTRO" ] && autodetect_distro
322 #autodetect used Distro
325 if [ -f /etc/SuSE-release ]; then
327 elif [ -f /etc/redhat-release ]; then
328 local distroname=$(head -1 /etc/redhat-release | grep -e "CentOS\|Red")
329 if [ ! "$distroname" = "" ]; then
330 local version=$(echo "$distroname" | sed -e s/[^0-9.]*//g | sed -e s/\\..*// )
332 [ "$version" = "" ] || DISTRO="${distroname}${version}"
335 [ "$DISTRO" = "" ] && DISTRO="sles9" #default distro
340 echo $(echo "$*" | xargs -n 1 | sort -u)
347 if [ "$TARGET" = "rhel-2.6" -o "$TARGET" = "rhel-2.4" ]; then
349 if [ "$TARGET" = "rhel-2.6" ]; then
351 OLDCONFIG=nonint_oldconfig
352 elif [ "$TARGET" = "rhel-2.4" ]; then
357 RPMTOPDIR=$(mktemp -d $KERNELDIR/rpm_XXXXXX)
358 mkdir $RPMTOPDIR/BUILD/
359 rpm -ivh $KERNELDIR/$SRPM --define "_topdir $RPMTOPDIR" || \
360 { rm -rf $RPMTOPDIR; fatal 1 "Error installing kernel SRPM."; }
361 $RPMBUILD -bp --nodeps --target i686 $RPMTOPDIR/SPECS/$SPEC --define "_topdir $RPMTOPDIR"
362 pushd $RPMTOPDIR/BUILD/kernel-${lnxmaj}/linux-${lnxmaj} && {
364 cp configs/kernel-${lnxmaj}-i686-smp.config .config
365 if ! make $OLDCONFIG > /dev/null; then
366 fatal 1 "error trying to make $OLDCONFIG while building a tarball from SRPM."
368 make include/linux/version.h
371 tar cjf $KERNEL_FILE linux-${lnxmaj}
378 download_and_build_tarball() {
382 local srpm=kernel-${lnxmaj}-${lnxrel}.src.rpm
384 echo "Downloading http://downloads.lustre.org/public/kernels/$target/old/$srpm..."
385 if ! wget -nv "http://downloads.lustre.org/public/kernels/$target/old/$srpm" \
386 -O "$KERNELDIR/$srpm" ; then
387 fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org."
389 [ -s "$KERNELDIR/$srpm" ] || {
390 rm -rf $KERNELDIR/$srpm
391 fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org."
394 build_tarball $target $srpm
399 EXTRA_VERSION_save="$EXTRA_VERSION"
400 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
401 TARGET_FILE="$patchesdir/targets/$TARGET.target"
402 [ -r "$TARGET_FILE" ] && break
404 [ -r "$TARGET_FILE" ] || \
405 fatal 1 "Target $TARGET was not found."
407 echo "Loading target config file $TARGET.target..."
411 # doesn't make any sense to build OFED for xen domX's
416 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
417 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
419 #CC was overwriten in TARGET_FILE
420 which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc"
422 if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then
423 KERNELDIR="$KERNELTREE/${lnxmaj}"
424 [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR"
427 if [ "$KERNELDIR" ] ; then
428 KERNEL_FILE="$KERNELDIR/$KERNEL"
429 if [ ! -r "$KERNEL_FILE" ] ; then
430 # see if we have an SRPM we can build a tarball for
431 KERNEL_SRPM=kernel-${lnxmaj}-${lnxrel}.src.rpm
432 if [ -r "$KERNELDIR/$KERNEL_SRPM" ] ; then
433 build_tarball $CANONICAL_TARGET $KERNEL_SRPM
435 if (( $DOWNLOAD )) ; then
436 echo "Downloading http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL..."
437 if ! wget -nv "http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then
438 # see if we can do it with an SRPM from the download site
439 download_and_build_tarball $CANONICAL_TARGET $KERNEL_FILE
441 [ -s "$KERNELDIR/$KERNEL" ] || {
442 rm -rf "$KERNELDIR/$KERNEL"
443 fatal 1 "Target $TARGET's kernel $KERNEL not found in directory $KERNELDIR."
447 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
451 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ] && \
452 [ ! -r "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ] ; then
453 if (( $DOWNLOAD )) ; then
454 local location="http://downloads.lustre.org/public/OFED/"
455 echo "Downloading $location/OFED-${OFED_VERSION}.tgz..."
456 if ! wget -nv "$location/OFED-${OFED_VERSION}.tgz" \
457 -O "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ; then
458 fatal 1 "Could not download OFED-${OFED_VERSION}.tgz from downloads.lustre.org."
461 fatal 1 "OFED-${OFED_VERSION}.tgz not found in kernel directory $KERNELDIR."
466 if [ "$SERIES" ] ; then
467 for series in $SERIES ; do
468 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
469 [ -r "$patchesdir/series/$series" ] && continue 2
471 fatal 1 "Target $TARGET's series $SERIES could not be found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n\t$TOPDIR/lustre/lustre/kernel_patches/series."
479 if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
480 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH.config"
483 for smptype in $SMPTYPES; do
484 [ "$smptype" = "''" ] && smptype=
485 if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config ]; then
486 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH-${smptype}.config"
487 KERNCONFSMPTYPE=$smptype
491 local lnxrelnew=${lnxrel//-/_}
493 if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then
494 fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
497 if [ "$EXTRA_VERSION_save" ] ; then
498 EXTRA_VERSION="$EXTRA_VERSION_save"
499 elif ! $RELEASE; then
500 # if there is no patch series, then this is not a lustre specific
501 # kernel. don't make it look like one
502 if [ -n "$SERIES" ]; then
503 #remove the @VERSION@ (lustre version)
504 # EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
505 # EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
506 ! ( $PATCHLESS ) && EXTRA_VERSION="${EXTRA_VERSION}.${TIMESTAMP}"
509 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
511 [ -z $REUSEDKERNELMASK ] && \
512 # create mask for kernel RPM/builddir which could be reused
514 REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.*${TARGET_ARCH}
516 REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TARGET_ARCH}
518 REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TIMESTAMP}.${TARGET_ARCH}
520 # kernel-lustre-smp-2.6.9-55.0.2.EL_lustre.1.6.1.i686.rpm
522 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
525 for arch in $(uniqify "$ALL_ARCHS") ; do
526 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep -w "$arch" >/dev/null 2>/dev/null ; then
527 BUILD_ARCHS="$BUILD_ARCHS $arch"
530 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
531 echo "Building for: $BUILD_ARCHS"
538 fatal 1 "tarflags(): File name argument missing."
550 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
557 echo "Untarring ${1##*/}..."
558 tar $(tarflags "$1") "$1"
563 untar "$KERNELTREE/../OFED-${OFED_VERSION}.tgz"
564 [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED
566 ls -ld OFED OFED-[0-9].[0-9]*
567 ls -l OFED OFED-[0-9].[0-9]*
572 DIRNAME="lustre-$TAG-$TIMESTAMP"
573 if [ "$LUSTRE" ] ; then
575 [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
577 if [ "$USE_DATESTAMP" ]; then
578 DATESTAMP="-D '$DATE'"
583 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
584 fatal 1 "There was an error checking out toplevel Lustre from CVS."
585 pushd "$DIRNAME" > /dev/null
586 ./lustrecvs "$TAG" || \
587 fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."
588 echo "Creating lustre tarball..."
589 sh autogen.sh || fatal 1 "There was an error running autogen.sh."
590 ./configure --disable-{modules,utils,liblustre,tests,doc} || \
591 fatal 1 "There was an error running ./configure to create makefiles."
592 make dist || fatal 1 "There was an error running 'make dist'."
594 fname=$(basename $DIRNAME/lustre-*.tar.gz)
595 cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."
597 ln -sf "$DIRNAME" lustre
604 [ -d linux ] || ln -sf linux* linux
609 [ "$SERIES" ] || return 0
610 FULL_PATCH="$PWD/lustre-kernel-${TARGET}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}.patch"
611 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
612 pushd linux >/dev/null
613 for series in $SERIES ; do
614 echo -n "Applying series $series:"
615 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
616 [ -r "$patchesdir/series/$series" ] || continue
617 SERIES_FILE="$patchesdir/series/$series"
618 for patch in $(<"$SERIES_FILE") ; do
620 PATCH_FILE="$patchesdir/patches/$patch"
621 [ -r "$PATCH_FILE" ] || \
622 fatal 1 "Patch $patch does not exist in Lustre tree."
623 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
624 fatal 1 "Error adding patch $patch to full patch."
625 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
632 echo "Full patch has been saved in ${FULL_PATCH##*/}."
633 echo "Replacing .config files..."
634 [ -d linux/configs ] || mkdir linux/configs || \
635 fatal 1 "Error creating configs directory."
636 rm -f linux/configs/*
638 for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
639 [ "$patchesdir" ] && \
640 cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
642 [ "$copysuccess" = "1" ] || \
643 fatal 1 "Error copying in kernel configs."
648 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
649 echo "Creating patched linux tarball $TARBALL..."
650 tar zcf "$TARBALL" "$(readlink linux)" \
651 --exclude "CVS" --exclude ".cvsignore" || \
652 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
653 fatal 1 "Error creating patched Linux tarball."
658 [ -d linux ] || return 0
659 echo "Cleaning linux..."
660 [ -L linux ] && rm -rf $(readlink linux)
666 local lmakeopts="\"\""
671 ENABLE_INIT_SCRIPTS=""
673 -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
674 -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
675 -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
676 -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
677 -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
678 -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
679 -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
680 -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
681 -e "s^@KERNEL_EXTRA_VERSION_DELIMITER@^$EXTRA_VERSION_DELIMITER^g" \
682 -e "s^@KERNEL_TARGET_DELIMITER@^$TARGET_DELIMITER^g" \
683 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
684 -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
685 -e "s^@KERNEL_VERSION@^$VERSION^g" \
686 -e "s^@LINUX26@^$LINUX26^g" \
687 -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
688 -e "s^@LUSTRE_TARGET@^$TARGET^g" \
689 -e "s^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \
690 -e "s^@RHBUILD@^$RHBUILD^g" \
691 -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
692 -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
693 -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
694 -e "s^@LMAKEOPTS@^$lmakeopts^g" \
695 < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
696 > lustre-kernel-2.4.spec
697 [ -d SRPMS ] || mkdir SRPMS
698 [ -d RPMS ] || mkdir RPMS
699 [ -d BUILD ] || mkdir BUILD
700 [ -d SOURCES ] || mkdir SOURCES
701 for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
702 suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} \
703 sles8-{pre,post,postun,update_{INITRD_MODULES,rcfile_setting}}.sh ; do
704 cp $TOPDIR/lustre/build/$script SOURCES
706 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
707 if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
708 tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
710 touch SOURCES/external-patches.tar.gz
716 [ -d lustre ] || return 0
717 echo "Cleaning Lustre..."
718 [ -L lustre ] && rm -rf $(readlink lustre)
724 echo "Building kernel + Lustre RPMs for: $BUILD_ARCHS..."
726 for arch in $BUILD_ARCHS ; do
727 targets="--target $arch $targets"
730 local rpmbuildopt='-bb'
733 # echo NORPM mode. Only compiling.
734 # echo "XXX: need to fix lmake - add options to do rpmbuild -bc instead of -bb"
737 $RPMBUILD $targets $rpmbuildopt lustre-kernel-2.4.spec \
738 --define "_tmppath $TMPDIR" \
739 --define "_topdir $TOPDIR" || \
740 fatal 1 "Error building rpms for $BUILD_ARCHS."
742 if (( $DO_SRC )) ; then
743 $RPMBUILD -bs lustre-kernel-2.4.spec \
744 --define "_tmppath $TMPDIR" \
745 --define "_topdir $TOPDIR" || \
746 fatal 1 "Error building .src.rpm."
749 ( $(skeep_ldiskfs_rpm $TAG) ) && return
751 pushd $TOPDIR/BUILD/lustre*/ldiskfs || return 255
753 if [ "$?" != "0" ] ; then
757 cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
761 local ldiskfs_spec=lustre-ldiskfs.spec
762 [ -f "$ldiskfs_spec" ] && sed \
763 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
765 > ../lustre-ldiskfs.spec
767 $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
768 --define "_tmppath /var/tmp" \
769 --define "_topdir $TOPDIR"
770 if [ "$?" != "0" ] ; then
775 if (( $DO_SRC )) ; then
776 $RPMBUILD -bs ../lustre-ldiskfs.spec \
777 --define "_tmppath /var/tmp" \
778 --define "_topdir $TOPDIR"
779 if [ "$?" != "0" ] ; then
789 [ -d SRPMS ] || mkdir SRPMS
790 [ -d RPMS ] || mkdir RPMS
791 [ -d BUILD ] || mkdir BUILD
792 [ -d SOURCES ] || mkdir SOURCES
796 pushd lustre >/dev/null
798 echo "Building Lustre RPMs for: $BUILD_ARCHS..."
800 for arch in $BUILD_ARCHS ; do
801 targets="--target $arch $targets"
804 local confoptions="--with-linux=${LINUX}"
806 confoptions="--with-linux=${LINUX} --disable-server"
808 if [ ! "$LINUXOBJ" = "" ]; then
809 confoptions="$confoptions --with-linux-obj=${LINUXOBJ}"
812 ./configure $confoptions ${CONFIGURE_FLAGS}
813 if [ "$?" != "0" ] ; then
814 local saved_config="../config.log.$(date +%s)"
815 cp config.log $saved_config
816 chmod a+r $saved_config
817 echo "Saved config.log is at $saved_config"
824 # hack. Somebody move build/lustre.spec to lustre.spec for b1_6
826 [ -f lustre.spec ] && lustre_spec=lustre.spec
827 [ -f build/lustre.spec ] && lustre_spec=build/lustre.spec
829 [ -f "$lustre_spec" ] && sed \
830 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
834 local rpmbuildopt='-bb'
837 echo NORPM mode. Only compiling.
840 $RPMBUILD $targets $rpmbuildopt ../lustre.spec \
841 --define "_tmppath $TMPDIR" \
842 --define "_topdir $TOPDIR" || \
843 fatal 1 "Error building rpms for $BUILD_ARCHS."
846 ( $(skeep_ldiskfs_rpm $TAG) ) && return
848 pushd lustre/ldiskfs || return 255
850 if [ "$?" != "0" ] ; then
854 cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
858 local ldiskfs_spec=lustre-ldiskfs.spec
859 [ -f "$ldiskfs_spec" ] && sed \
860 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
862 > ../lustre-ldiskfs.spec
864 $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
865 --define "_tmppath /var/tmp" \
866 --define "_topdir $TOPDIR"
867 if [ "$?" != "0" ] ; then
872 if (( $DO_SRC )) ; then
873 $RPMBUILD -bs ../lustre-ldiskfs.spec \
874 --define "_tmppath /var/tmp" \
875 --define "_topdir $TOPDIR"
876 if [ "$?" != "0" ] ; then
886 [ "$STAGEDIR" ] || return 0
888 for arch in $BUILD_ARCHS ; do
889 rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
890 echo "${0##*/}: Copying RPMs into ${rpmdir}"
892 cp -v RPMS/${arch}/*.rpm "${rpmdir}"
893 if [ -d RPMS/noarch ] ; then
894 cp -v RPMS/noarch/*.rpm "${rpmdir}"
898 cp -v "$LUSTRE" "$STAGEDIR"
901 #check if we need to build separate ldiskfs RPM
906 if ! $LDISKFSRPM; then
908 elif $PATCHLESS; then
911 for skiptag in $SKIPLDISKFSRPM; do
912 [[ $tag == $skiptag ]] && skip=true && break
918 #get date of last changed target/config/series/patches
919 get_last_source_date()
921 local filelist="${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} \
923 local TOPDIRnew=$(echo ${TOPDIR} | sed -e s/\\//\\\\\\//g)
924 filelist="$filelist $( \
925 cat ${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} | \
926 sed -e s/^/${TOPDIRnew}\\/lustre\\/lustre\\/kernel_patches\\/patches\\// 2>&1)"
927 local sourcelastdate=$( find ${filelist} -name CVS -prune -o \
928 -type f -printf "%T@\n" 2>&1 | sort | tail -1 )
929 is_integer $sourcelastdate && echo $sourcelastdate
932 #check if variable is integer
936 [ "$invariable" = "" ] && return 255
937 local invariableint=$( echo $invariable | sed -e s/[^0-9]//g )
938 [ "$invariable" = "$invariableint" ] || return 255
941 #generate LUSTRE_EXTRA_VERSION from EXTRA_VERSION
945 [ "$KERNCONFSMPTYPE" = "" ] || smptype=$KERNCONFSMPTYPE
946 [ "$RPMSMPTYPE" = "" ] || smptype=$RPMSMPTYPE
948 LUSTRE_EXTRA_VERSION="${lnxmaj}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}${TARGET_DELIMITER}${smptype}"
949 LUSTRE_EXTRA_VERSION=${LUSTRE_EXTRA_VERSION//-/_}
952 #store RPMs and/or BUILD dir for future reuse
956 if [ ! "$REUSEBUILD" = "" ] && [ -d "/$REUSEBUILD/" ] ; then
957 [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || mkdir "${REUSEBUILD}/${TIMESTAMP}"
958 [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || return 255
963 local lnxrelnew=${lnxrel//-/_}
964 local EXTRA_VERSIONnew=${EXTRA_VERSION//-/_}
965 local KERNELRPMnew=$(basename "$KERNELRPM")
966 if [ ! "$rpmonly" = "rpmonly" ]; then
968 if [ ! "$KERNELCOMPILEDIR" = "" ]; then
969 builddir="$KERNELCOMPILEDIR"
971 builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}"
972 [ "$KERNELCOMPILEDIR" = "" ] || builddir="$KERNELCOMPILEDIR"
973 [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}.${lnxrel}"
974 [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}-${lnxrel}"
975 if [ ! -d "$builddir" ]; then
976 pushd "BUILD/lustre-kernel-${lnxmaj}/lustre/" || return 255
977 local basebuilddir=$(ls -d linux-${lnxmaj}* | head -1)
978 [ "$basebuilddir" = "" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/${basebuilddir}"
982 [ -d "$builddir" ] || return 255
983 local dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}"
984 ( $PATCHLESS ) && dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-$KERNELRPMnew" && \
985 dstdir="${dstdir%.rpm}"
986 [ -d "$dstdir" ] && rm -rf "$dstdir"
987 mv "${builddir}" "$dstdir" || return 255
988 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
989 # move the OFED kernel-ib-devel tree as well
990 mv "${builddir%/*}/kernel-ib-devel/usr/src/ofa_kernel" "${dstdir%/*}" || return 255
994 local kernelrpmname="kernel-lustre-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
995 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSNnew}.${TARGET_ARCH}.rpm"
996 ( $PATCHLESS ) && [ -f "$KERNELRPM" ] && kernelrpmname="$KERNELRPMnew"
997 if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
998 echo "RPM already exist in store directory tree"
1000 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
1002 #store kernel source rpm
1003 kernelrpmname="kernel-lustre-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
1004 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
1005 ( $PATCHLESS ) && [ -f "$KERNELSOURCERPM" ] && kernelrpmname=$(basename "$KERNELSOURCERPM")
1006 if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
1007 echo "RPM already exist in store directory tree"
1009 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
1011 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1012 # store kernel-ib RPMs
1014 for rpmname in "kernel-ib" "kernel-ib-devel"; do
1015 rpmname="${rpmname}-${OFED_VERSION}"
1017 rpmname="${rpmname}-${LINUXRELEASE//-/_}"
1019 rpmname="${rpmname}-${lnxmaj}${EXTRA_VERSION_DELIMITER//-/_}${EXTRA_VERSIONnew}${TARGET_DELIMITER//-/_}${KERNCONFSMPTYPE}"
1021 rpmname="${rpmname}.${TARGET_ARCH}.rpm"
1022 if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${rpmname}" ]; then
1023 echo "RPM already exist in store directory tree"
1025 [ -f "RPMS/${TARGET_ARCH}/${rpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${rpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
1033 local infact_arch=${TARGET_ARCH}
1035 [ "$infact_arch" == "i586" ] && infact_arch="i686"
1036 for smp_type in $SMP_ARCHS; do
1037 [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break
1039 for smp_type in $BIGSMP_ARCHS; do
1040 [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break
1044 # This function takes a linux source pool and digs out the linux release
1046 find_linux_release() {
1049 local LINUXRELEASEHEADER=$SRCDIR/include/linux/version.h
1050 if [ -s $SRCDIR/include/linux/utsrelease.h ]; then
1051 LINUXRELEASEHEADER=$SRCDIR/include/linux/utsrelease.h
1054 sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER
1058 #unpack kernel(/source/devel) RPM
1062 local delimiter=${2:-"-"}
1063 local pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
1064 local kernelbinaryrpm=
1065 [ -d $pathtorpms ] || return 255
1067 local wanted_kernel="${lnxmaj}${delimiter}${lnxrel}"
1068 for arch in $TARGET_ARCHS_ALL; do
1069 for rpm in ${pathtorpms}/${arch}/*.rpm; do
1070 local provides=$(rpm -q --provides -p $rpm)
1071 if (echo $provides | grep -q "kernel${prefix} = $wanted_kernel"); then
1075 [ -f "$KERNELRPM" ] && TARGET_ARCH="$arch" && BUILD_ARCHS="$arch" && break
1081 [ -f "$KERNELRPM" ] || return 255
1082 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
1083 pushd $TOPDIR/reused || return 255
1085 rpm2cpio < "$KERNELRPM" | cpio -idc > /dev/null 2>&1
1086 if [ ${PIPESTATUS[0]} -eq 0 ]; then
1087 # RHEL-style and SLES-style rpms
1088 local paths="kernels/${lnxmaj}${delimiter}${lnxrel}-${TARGET_ARCH} linux-${lnxmaj}${delimiter}${lnxrel}"
1090 for path in $paths; do
1093 if [ -d "$src/$path/" ]; then
1094 LINUX="$(pwd)/$src/$path"
1096 # SLES has a separate -obj tree
1097 if [ -d "$src/${path}-obj" ]; then
1098 src="$src/${path}-obj"
1099 local objects="$TARGET_ARCH/$RPMSMPTYPE"
1101 # Novell, are you *TRYING* to make life hard for me?
1102 if [ -d "$src/powerpc" ]; then
1103 objects="powerpc/$TARGET_ARCH"
1104 elif [ $TARGET_ARCH == 'i686' ]; then
1105 objects="i386/$RPMSMPTYPE"
1108 LINUXOBJ="$(pwd)/$src/$objects"
1111 if [ -z "$LINUX" ]; then
1114 # dig out the release version
1115 LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
1116 if [ -z "$LINUXRELEASE" ]; then
1117 echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
1128 #look for kernel source RPM
1129 find_linux_source_rpm()
1135 [ ! "$TARGET_ARCH" = "" ] && arch=$TARGET_ARCH && findarch=false
1137 if ! $findarch; then
1138 pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
1139 [ -d $pathtorpms ] || return 255
1142 rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
1145 rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
1148 rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
1151 [ -f "${pathtorpms}/${rpmfile}" ] || return 255
1152 KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
1154 for arch in $TARGET_ARCHS_ALL; do
1155 pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
1156 [ -d $pathtorpms ] || continue
1159 rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
1162 rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
1165 rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
1168 [ -f "${pathtorpms}/${rpmfile}" ] || continue
1169 KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
1174 [ -f "${KERNELSOURCERPM}" ] || return 255
1177 #unpack and make symlinks for reusing kernel RPM
1181 local pathtokernelibrpm=$2
1182 [ "$pathtorpm" = "" ] && return 255
1183 [ -f "$pathtorpm" ] || return 255
1184 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
1185 pushd $TOPDIR/reused || return 255
1187 rpm2cpio < $pathtorpm | cpio -idc
1188 [ ${PIPESTATUS[0]} -eq 0 ] || return 255
1190 if [ -n "$pathtokernelibrpm" ] && [ -f "$pathtokernelibrpm" ]; then
1191 rpm2cpio < $pathtokernelibrpm | cpio -idc
1192 [ ${PIPESTATUS[0]} -eq 0 -o ${PIPESTATUS[1]} -eq 0 ] || return 255
1193 CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
1197 if pushd usr/src/linux-*-obj/${TARGET_ARCH}; then
1198 local smptypes="$SMPTYPES"
1199 [ "$RPMSMPTYPE" = "" ] || smptypes=$RPMSMPTYPE
1200 ( ! $PATCHLESS ) && [ ! "$KERNCONFSMPTYPE" = "" ] && smptypes="$KERNCONFSMPTYPE"
1202 for cursmptype in $smptypes; do
1203 [ "$cursmptype" = "''" ] && continue
1204 [ -d $cursmptype ] && smptype=$cursmptype
1205 [ -d $smptype ] && break
1209 if [ "${smptype}" = "" ]; then
1211 return 255 # cannot detect smp type
1213 if pushd usr/src/linux-*-obj/${TARGET_ARCH}/$smptype/include2; then
1214 local base=$(readlink asm)
1215 if [ ! -d "/${base}/" ]; then
1217 base=$(basename "$base")
1218 if pushd ../../../../linux-*/include; then
1221 [ -d "$lsrc/${base}" ] && ln -s $lsrc/${base} asm
1225 read a b < <(echo $(pwd)/usr/src/linux-*)
1226 if [[ $a == $(pwd)/* && $b = $(pwd)/* ]]; then
1227 cp -f $a/include/linux/config.h $b/${TARGET_ARCH}/$smptype/include/linux/
1228 cp $b/${TARGET_ARCH}/$smptype/.config $a/
1229 [ -f "$b/${TARGET_ARCH}/$smptype/.config" ] && KERNELRPMCONFIG="$b/${TARGET_ARCH}/$smptype/.config"
1230 cp $b/${TARGET_ARCH}/$smptype/.kernelrelease $a/
1231 [ -f "$b/${TARGET_ARCH}/$smptype/.kernelrelease" ] && KERNELRPMRELEASE="$b/${TARGET_ARCH}/$smptype/.kernelrelease"
1233 LINUXOBJ=$b/${TARGET_ARCH}/$smptype
1234 # local fname=$(basename $kernel_rpm)
1235 # KERNELRPMSDIR=${kernel_rpm%$fname}
1239 [ "$LINUX" = "" ] && return 255
1240 [ -d "$LINUX" ] || return 255
1243 #build linux kernel rpm
1246 pushd $LINUX || return 255
1247 make binrpm-pkg || ( popd ; return 255 )
1249 [ -f ".version" ] && addlnxrel="-$(cat .version)"
1252 for arch in $TARGET_ARCHS_ALL; do
1253 [ -f "/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
1254 KERNELRPM="/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
1256 [ -f "/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
1257 KERNELRPM="/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
1260 [ "$KERNELRPM" = "" ] || return
1268 local nocopykernel=$2
1269 pushd $LINUX || fatal 1 "Kernel source not found"
1270 [ "$nofullmake" = "nofullmake" ] || make mrproper
1271 [ "$nofullmake" = "nofullmake" ] || rm -f rpm-release
1272 # [ "$nocopykernel" = "copyrpmkernel" ] || rm -f localversion-*
1273 [ "$nocopykernel" = "copykernel" ] && [ -f "$CONFIG_FILE" ] && cp $CONFIG_FILE .config
1274 if [ "$nocopykernel" = "copyrpmkernel" ]; then
1275 [ -f "$KERNELRPMCONFIG" ] && cp $KERNELRPMCONFIG .config
1276 if [ -f "$KERNELRPMRELEASE" ]; then
1277 cp $KERNELRPMRELEASE .
1279 sed -e "s/^EXTRAVERSION\s\+=\s\+.*$/EXTRAVERSION = -${lnxrel}/" < Makefile > Makefile.new
1280 [ -f "Makefile.new" ] && mv Makefile.new Makefile
1283 [ -f ".config" ] || ( popd ; echo "Cannot find .config file"; return 255 )
1284 make oldconfig || ( popd ; return 255 )
1285 make include/linux/version.h
1286 if [ ! "$nofullmake" = "nofullmake" ]; then
1287 make || ( popd ; return 255 )
1295 # build kernel-ib{,-devel}
1296 # some I/B drivers are architecture dependent and kernel-ib's configure
1297 # does not figure it out for us ~sigh~
1298 local configure_options=""
1299 case "$TARGET_ARCH" in
1301 configure_options="--with-ipath_inf-mod"
1304 configure_options="--with-ipath_inf-mod --with-ehca-mod"
1308 # ofed 1.3 had a bug in the rpm spec
1309 if [ "$OFED_VERSION" = "1.3" ]; then
1312 $RPMBUILD --rebuild --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
1313 --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
1314 --define "KVERSION ${LINUXRELEASE}" \
1315 --define "$K_SRC ${LINUXOBJ:-${LINUX}}" \
1316 --define "LIB_MOD_DIR /lib/modules/${LINUXRELEASE}/updates" \
1317 --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --without-srp-target-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" ${TOPDIR}/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
1319 if [ ${PIPESTATUS[0]} != 0 ]; then
1320 fatal 1 "Error building kernel-ib"
1323 pushd "$TOPDIR" >/dev/null
1324 rm -rf kernel-ib-devel
1325 mkdir kernel-ib-devel
1327 local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${LINUXRELEASE//-/_}.*.rpm)
1328 rpm2cpio -itv < $rpm | cpio -id
1329 CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
1333 #build patchless lustre
1334 patchless_build_sequence()
1336 if [ -f $LINUX/Makefile ]; then
1337 # Get the correct kernel release - I'm unsure how this can ever
1338 # work otherwise, unless you're using the exact same kernel version
1339 # Lustre is shipped with.
1341 local LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
1342 if [ -z "$LINUXRELEASE" ]; then
1343 echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
1347 lnxmaj=$(echo $LINUXRELEASE | cut -f1 -d-)
1348 EXTRA_VERSION=$(echo $LINUXRELEASE | cut -f2 -d-)_lustre.$LUSTRE_VERSION
1350 build_lustre && buildsuccess=true
1352 #try to build from kernel-devel RPM (RHEL)
1355 local rpmfound=false
1356 local buildsuccess=false
1357 local storeforreuse=false
1358 if [ "$KERNELRPMSBASE" = "" ] || [ ! -d "$KERNELRPMSBASE" ]; then
1361 [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
1363 local delimiter=${EXTRA_VERSION_DELIMITER:-"-"}
1364 # default to source type -source and special case below
1372 unpack_linux_rpm $type $delimiter && rpmfound=true
1374 [ -d SRPMS ] || mkdir SRPMS
1375 [ -d RPMS ] || mkdir RPMS
1376 [ -d BUILD ] || mkdir BUILD
1377 [ -d SOURCES ] || mkdir SOURCES
1379 # first build kernel-ib
1380 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1381 $rpmfound && build_kernel_ib
1383 ( $rpmfound ) && build_lustre && buildsuccess=true && find_linux_source_rpm
1386 if $buildsuccess; then
1387 [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELRPM" ] && \
1388 cp "$KERNELRPM" RPMS/${TARGET_ARCH}/
1389 [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELSOURCERPM" ] && \
1390 cp "$KERNELSOURCERPM" RPMS/${TARGET_ARCH}/
1391 KERNELCOMPILEDIR="$LINUX"
1392 if $storeforreuse; then
1393 store_for_reuse || echo "Cannot store for future reuse"
1397 elif ! $rpmfound; then
1398 echo "COULD NOT FIND VENDOR -devel or -source RPM for $DISTRO/$TARGET_ARCH: $lnxmaj-$lnxrel in $KERNELRPMSBASE"
1401 echo "Patchless build failed."
1406 #check timestamp value. should bi 14-digits string
1410 local timestampnodig=$(echo $invalue | sed -e s/[0-9]*//g)
1411 [ "$timestampnodig" = "" ] || return 255
1412 local timestamplength="${#invalue}"
1413 [ $timestamplength -eq 14 ] || return 255
1416 # get list of suitable directories with potential reused staff
1417 get_reuse_dir_list()
1420 local reusedkernelmasknew=$2
1421 local buildtimestamp=
1423 local sourcelastdate=$(get_last_source_date)
1424 for buildtimestamp in $(ls "$REUSEBUILD/" 2>&1); do
1425 [ -d "$REUSEBUILD/$buildtimestamp" ] || continue
1426 check_timestamp "$buildtimestamp" || continue
1427 local buildtimestampstr=$(echo $buildtimestamp | \
1428 sed -e "s^\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)^\1-\2-\3 \4:\5:\6 GMT^g")
1429 local buildtimestampepoch=$(date --date="$buildtimestampstr" +%s )
1430 #check for suitable date
1431 if ! $PATCHLESS; then
1432 [ $buildtimestampepoch -ge $sourcelastdate ] || continue
1434 #check for suitable version
1435 if [ "$rpmonly" = "rpmonly" ]; then
1436 local reusedkernelprefix="kernel-lustre-"
1437 ( $PATCHLESS ) && reusedkernelprefix=
1438 local rpmmask="${reusedkernelprefix}${REUSEDKERNELMASK}"
1439 [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
1440 [ -f $REUSEBUILD/$buildtimestamp/${rpmmask}.rpm ] && \
1441 dirsforreuse="$dirsforreuse $REUSEBUILD/$buildtimestamp"
1443 local rpmmask="$REUSEDKERNELMASK"
1444 [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
1445 pushd $REUSEBUILD/$buildtimestamp/linux-${rpmmask} > /dev/null 2>&1 || continue
1447 dirsforreuse="$dirsforreuse $curdir"
1451 echo "$dirsforreuse"
1454 #try to reuse old RPM
1455 build_sequence_rpm_reuse()
1458 [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
1460 if ! [ "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse RPM
1461 local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
1462 REUSEDKERNELMASKnew="kernel-lustre-source-${REUSEDKERNELMASKnew}"
1463 local dirsforreuse="$(get_reuse_dir_list rpmonly $REUSEDKERNELMASKnew)"
1464 local buildsuccess=false
1466 for curdir in $(echo $dirsforreuse); do
1467 [ -d "$curdir" ] || continue
1468 local reusedkernelprefix="kernel-lustre-"
1469 local reusedkernelrpm=
1470 [ -f ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
1471 reusedkernelrpm=$(ls ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
1472 [ -f "$reusedkernelrpm" ] || continue
1474 local reusedkernelsourcerpm=
1475 [ -f ${curdir}/${REUSEDKERNELMASKnew}.rpm ] && \
1476 reusedkernelsourcerpm=$(ls ${curdir}/${REUSEDKERNELMASKnew}.rpm | head -1 )
1477 [ -f "$reusedkernelsourcerpm" ] || continue
1479 # don't need to check for kernel-ib RPM reuse here because sles9 is not supported
1480 # by OFED >= 1.3.0 and this function appears to only be used for sles9
1482 [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
1483 reuse_kernel_rpm "$reusedkernelsourcerpm" "" && build_linux nofullmake copyrpmkernel && build_lustre && buildsuccess=true
1484 ( $buildsuccess ) || continue
1485 if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
1486 [ -f "$reusedkernelrpm" ] && \
1487 cp -f "$reusedkernelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1489 [ -f "$reusedkernelsourcerpm" ] && \
1490 cp -f "$reusedkernelsourcerpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
1491 touch RPMS/${TARGET_ARCH}/kernel_was_reused
1499 #try to reuse old BUILD dir
1500 build_sequence_reuse()
1503 [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
1505 if [ ! "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse old kernel build directory
1506 local dirsforreuse="$(get_reuse_dir_list)"
1507 local buildsuccess=false
1509 local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
1510 for curdir in $(echo $dirsforreuse); do
1511 local reusedkernelrpm=
1512 local reusedkernelsourcerpm=
1513 local reusedkernelibrpm=
1514 [ -d "$curdir" ] || continue
1515 [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" -a
1516 ! -d "${curdir%/*}/ofa_kernel" ] && continue
1517 local reusedkernelprefix="kernel-lustre-"
1518 ( $PATCHLESS ) && reusedkernelprefix=
1519 [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
1520 reusedkernelrpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
1521 reusedkernelprefix="kernel-lustre-source-"
1522 [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm ] && \
1523 reusedkernelsourcerpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm | head -1 )
1524 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1526 reusedkernelprefix="kernel-ib-"
1527 [ -f ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm ] && \
1528 reusedkernelibrpm=$(ls ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 )
1529 reusedkernelibdevelrpm=$(ls ${curdir}/../${reusedkernelprefix}devel-${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 )
1531 if ! ( $NORPM ) && ! [ -f "$reusedkernelrpm" ]; then #kernel rpm not found. Build all
1534 if ! ( $NORPM ) && ! [ -f "$reusedkernelsourcerpm" ]; then #kernel source rpm not found. Build all
1537 if [ -n "$OFED_VERSION" ]; then
1538 if [ "$OFED_VERSION" != "inkernel" ]; then
1539 if ! ( $NORPM ) && [ ! -f "$reusedkernelibrpm" -o ! -f "$reusedkernelibdevelrpm"]; then #kernel-ib{,-devel} rpm not found. Build all
1542 CONFIGURE_FLAGS="--with-o2ib=${curdir%/*}/ofa_kernel ${CONFIGURE_FLAGS}"
1544 CONFIGURE_FLAGS="--with-o2ib=yes ${CONFIGURE_FLAGS}"
1548 build_lustre || continue
1551 if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
1552 [ -f "$reusedkernelrpm" ] && \
1553 cp -f "$reusedkernelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
1554 touch RPMS/${TARGET_ARCH}/kernel_was_reused
1555 [ -f "$reusedkernelsourcerpm" ] && \
1556 cp -f "$reusedkernelsourcerpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1557 [ -f "$reusedkernelibrpm" ] && \
1558 cp -f "$reusedkernelibrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1559 cp -f "$reusedkernelibdevelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1570 if (( $DO_SRC )) ; then
1576 prep_kernel_build || return 255
1577 clean_lustre || return 255
1579 build_kernel || return 255
1582 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
1584 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 -- "$@")
1586 if [ $? != 0 ] ; then
1590 eval set -- "$options"
1628 --linux | --with-linux)
1703 --disable-datestamp)
1714 CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests"
1718 usage 1 "Unrecognized option: $1"
1728 EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
1730 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1736 patchless_build_sequence && build_success=true
1737 elif [ -z "$LINUX" ] ; then
1738 [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
1739 if ! $build_success; then
1740 build_sequence_reuse && build_success=true
1741 if ! $build_success; then
1742 build_sequence && build_success=true
1743 if $build_success; then
1744 store_for_reuse || echo "Cannot store for future reuse"
1749 build_lustre && build_success=true
1751 ( $build_success ) || fatal 1 "Cannot build lustre"