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 ${PATCHLESS:+--define "lustre_name lustre-client"} \
842 --define "_tmppath $TMPDIR" \
843 --define "_topdir $TOPDIR" || \
844 fatal 1 "Error building rpms for $BUILD_ARCHS."
847 ( $(skeep_ldiskfs_rpm $TAG) ) && return
849 pushd lustre/ldiskfs || return 255
851 if [ "$?" != "0" ] ; then
855 cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
859 local ldiskfs_spec=lustre-ldiskfs.spec
860 [ -f "$ldiskfs_spec" ] && sed \
861 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
863 > ../lustre-ldiskfs.spec
865 $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
866 --define "_tmppath /var/tmp" \
867 --define "_topdir $TOPDIR"
868 if [ "$?" != "0" ] ; then
873 if (( $DO_SRC )) ; then
874 $RPMBUILD -bs ../lustre-ldiskfs.spec \
875 --define "_tmppath /var/tmp" \
876 --define "_topdir $TOPDIR"
877 if [ "$?" != "0" ] ; then
887 [ "$STAGEDIR" ] || return 0
889 for arch in $BUILD_ARCHS ; do
890 rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
891 echo "${0##*/}: Copying RPMs into ${rpmdir}"
893 cp -v RPMS/${arch}/*.rpm "${rpmdir}"
894 if [ -d RPMS/noarch ] ; then
895 cp -v RPMS/noarch/*.rpm "${rpmdir}"
899 cp -v "$LUSTRE" "$STAGEDIR"
902 #check if we need to build separate ldiskfs RPM
907 if ! $LDISKFSRPM; then
909 elif $PATCHLESS; then
912 for skiptag in $SKIPLDISKFSRPM; do
913 [[ $tag == $skiptag ]] && skip=true && break
919 #get date of last changed target/config/series/patches
920 get_last_source_date()
922 local filelist="${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} \
924 local TOPDIRnew=$(echo ${TOPDIR} | sed -e s/\\//\\\\\\//g)
925 filelist="$filelist $( \
926 cat ${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} | \
927 sed -e s/^/${TOPDIRnew}\\/lustre\\/lustre\\/kernel_patches\\/patches\\// 2>&1)"
928 local sourcelastdate=$( find ${filelist} -name CVS -prune -o \
929 -type f -printf "%T@\n" 2>&1 | sort | tail -1 )
930 is_integer $sourcelastdate && echo $sourcelastdate
933 #check if variable is integer
937 [ "$invariable" = "" ] && return 255
938 local invariableint=$( echo $invariable | sed -e s/[^0-9]//g )
939 [ "$invariable" = "$invariableint" ] || return 255
942 #generate LUSTRE_EXTRA_VERSION from EXTRA_VERSION
946 [ "$KERNCONFSMPTYPE" = "" ] || smptype=$KERNCONFSMPTYPE
947 [ "$RPMSMPTYPE" = "" ] || smptype=$RPMSMPTYPE
949 LUSTRE_EXTRA_VERSION="${lnxmaj}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}${TARGET_DELIMITER}${smptype}"
950 LUSTRE_EXTRA_VERSION=${LUSTRE_EXTRA_VERSION//-/_}
953 #store RPMs and/or BUILD dir for future reuse
957 if [ ! "$REUSEBUILD" = "" ] && [ -d "/$REUSEBUILD/" ] ; then
958 [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || mkdir "${REUSEBUILD}/${TIMESTAMP}"
959 [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || return 255
964 local lnxrelnew=${lnxrel//-/_}
965 local EXTRA_VERSIONnew=${EXTRA_VERSION//-/_}
966 local KERNELRPMnew=$(basename "$KERNELRPM")
967 if [ ! "$rpmonly" = "rpmonly" ]; then
969 if [ ! "$KERNELCOMPILEDIR" = "" ]; then
970 builddir="$KERNELCOMPILEDIR"
972 builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}"
973 [ "$KERNELCOMPILEDIR" = "" ] || builddir="$KERNELCOMPILEDIR"
974 [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}.${lnxrel}"
975 [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}-${lnxrel}"
976 if [ ! -d "$builddir" ]; then
977 pushd "BUILD/lustre-kernel-${lnxmaj}/lustre/" || return 255
978 local basebuilddir=$(ls -d linux-${lnxmaj}* | head -1)
979 [ "$basebuilddir" = "" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/${basebuilddir}"
983 [ -d "$builddir" ] || return 255
984 local dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}"
985 ( $PATCHLESS ) && dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-$KERNELRPMnew" && \
986 dstdir="${dstdir%.rpm}"
987 [ -d "$dstdir" ] && rm -rf "$dstdir"
988 mv "${builddir}" "$dstdir" || return 255
989 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
990 # move the OFED kernel-ib-devel tree as well
991 mv "${builddir%/*}/kernel-ib-devel/usr/src/ofa_kernel" "${dstdir%/*}" || return 255
995 local kernelrpmname="kernel-lustre-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
996 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSNnew}.${TARGET_ARCH}.rpm"
997 ( $PATCHLESS ) && [ -f "$KERNELRPM" ] && kernelrpmname="$KERNELRPMnew"
998 if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
999 echo "RPM already exist in store directory tree"
1001 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
1003 #store kernel source rpm
1004 kernelrpmname="kernel-lustre-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
1005 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
1006 ( $PATCHLESS ) && [ -f "$KERNELSOURCERPM" ] && kernelrpmname=$(basename "$KERNELSOURCERPM")
1007 if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
1008 echo "RPM already exist in store directory tree"
1010 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
1012 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1013 # store kernel-ib RPMs
1015 for rpmname in "kernel-ib" "kernel-ib-devel"; do
1016 rpmname="${rpmname}-${OFED_VERSION}"
1018 rpmname="${rpmname}-${LINUXRELEASE//-/_}"
1020 rpmname="${rpmname}-${lnxmaj}${EXTRA_VERSION_DELIMITER//-/_}${EXTRA_VERSIONnew}${TARGET_DELIMITER//-/_}${KERNCONFSMPTYPE}"
1022 rpmname="${rpmname}.${TARGET_ARCH}.rpm"
1023 if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${rpmname}" ]; then
1024 echo "RPM already exist in store directory tree"
1026 [ -f "RPMS/${TARGET_ARCH}/${rpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${rpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
1034 local infact_arch=${TARGET_ARCH}
1036 [ "$infact_arch" == "i586" ] && infact_arch="i686"
1037 for smp_type in $SMP_ARCHS; do
1038 [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break
1040 for smp_type in $BIGSMP_ARCHS; do
1041 [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break
1045 # This function takes a linux source pool and digs out the linux release
1047 find_linux_release() {
1050 local LINUXRELEASEHEADER=$SRCDIR/include/linux/version.h
1051 if [ -s $SRCDIR/include/linux/utsrelease.h ]; then
1052 LINUXRELEASEHEADER=$SRCDIR/include/linux/utsrelease.h
1055 sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER
1059 #unpack kernel(/source/devel) RPM
1063 local delimiter=${2:-"-"}
1064 local pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
1065 local kernelbinaryrpm=
1066 [ -d $pathtorpms ] || return 255
1068 local wanted_kernel="${lnxmaj}${delimiter}${lnxrel}"
1069 for arch in $TARGET_ARCHS_ALL; do
1070 for rpm in ${pathtorpms}/${arch}/*.rpm; do
1071 local provides=$(rpm -q --provides -p $rpm)
1072 if (echo $provides | grep -q "kernel${prefix} = $wanted_kernel"); then
1076 [ -f "$KERNELRPM" ] && TARGET_ARCH="$arch" && BUILD_ARCHS="$arch" && break
1082 [ -f "$KERNELRPM" ] || return 255
1083 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
1084 pushd $TOPDIR/reused || return 255
1086 rpm2cpio < "$KERNELRPM" | cpio -idc > /dev/null 2>&1
1087 if [ ${PIPESTATUS[0]} -eq 0 ]; then
1088 # RHEL-style and SLES-style rpms
1089 local paths="kernels/${lnxmaj}${delimiter}${lnxrel}-${TARGET_ARCH} linux-${lnxmaj}${delimiter}${lnxrel}"
1091 for path in $paths; do
1094 if [ -d "$src/$path/" ]; then
1095 LINUX="$(pwd)/$src/$path"
1097 # SLES has a separate -obj tree
1098 if [ -d "$src/${path}-obj" ]; then
1099 src="$src/${path}-obj"
1100 local objects="$TARGET_ARCH/$RPMSMPTYPE"
1102 # Novell, are you *TRYING* to make life hard for me?
1103 if [ -d "$src/powerpc" ]; then
1104 objects="powerpc/$TARGET_ARCH"
1105 elif [ $TARGET_ARCH == 'i686' ]; then
1106 objects="i386/$RPMSMPTYPE"
1109 LINUXOBJ="$(pwd)/$src/$objects"
1112 if [ -z "$LINUX" ]; then
1115 # dig out the release version
1116 LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
1117 if [ -z "$LINUXRELEASE" ]; then
1118 echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
1129 #look for kernel source RPM
1130 find_linux_source_rpm()
1136 [ ! "$TARGET_ARCH" = "" ] && arch=$TARGET_ARCH && findarch=false
1138 if ! $findarch; then
1139 pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
1140 [ -d $pathtorpms ] || return 255
1143 rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
1146 rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
1149 rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
1152 [ -f "${pathtorpms}/${rpmfile}" ] || return 255
1153 KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
1155 for arch in $TARGET_ARCHS_ALL; do
1156 pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
1157 [ -d $pathtorpms ] || continue
1160 rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
1163 rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
1166 rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
1169 [ -f "${pathtorpms}/${rpmfile}" ] || continue
1170 KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
1175 [ -f "${KERNELSOURCERPM}" ] || return 255
1178 #unpack and make symlinks for reusing kernel RPM
1182 local pathtokernelibrpm=$2
1183 [ "$pathtorpm" = "" ] && return 255
1184 [ -f "$pathtorpm" ] || return 255
1185 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
1186 pushd $TOPDIR/reused || return 255
1188 rpm2cpio < $pathtorpm | cpio -idc
1189 [ ${PIPESTATUS[0]} -eq 0 ] || return 255
1191 if [ -n "$pathtokernelibrpm" ] && [ -f "$pathtokernelibrpm" ]; then
1192 rpm2cpio < $pathtokernelibrpm | cpio -idc
1193 [ ${PIPESTATUS[0]} -eq 0 -o ${PIPESTATUS[1]} -eq 0 ] || return 255
1194 CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
1198 if pushd usr/src/linux-*-obj/${TARGET_ARCH}; then
1199 local smptypes="$SMPTYPES"
1200 [ "$RPMSMPTYPE" = "" ] || smptypes=$RPMSMPTYPE
1201 ( ! $PATCHLESS ) && [ ! "$KERNCONFSMPTYPE" = "" ] && smptypes="$KERNCONFSMPTYPE"
1203 for cursmptype in $smptypes; do
1204 [ "$cursmptype" = "''" ] && continue
1205 [ -d $cursmptype ] && smptype=$cursmptype
1206 [ -d $smptype ] && break
1210 if [ "${smptype}" = "" ]; then
1212 return 255 # cannot detect smp type
1214 if pushd usr/src/linux-*-obj/${TARGET_ARCH}/$smptype/include2; then
1215 local base=$(readlink asm)
1216 if [ ! -d "/${base}/" ]; then
1218 base=$(basename "$base")
1219 if pushd ../../../../linux-*/include; then
1222 [ -d "$lsrc/${base}" ] && ln -s $lsrc/${base} asm
1226 read a b < <(echo $(pwd)/usr/src/linux-*)
1227 if [[ $a == $(pwd)/* && $b = $(pwd)/* ]]; then
1228 cp -f $a/include/linux/config.h $b/${TARGET_ARCH}/$smptype/include/linux/
1229 cp $b/${TARGET_ARCH}/$smptype/.config $a/
1230 [ -f "$b/${TARGET_ARCH}/$smptype/.config" ] && KERNELRPMCONFIG="$b/${TARGET_ARCH}/$smptype/.config"
1231 cp $b/${TARGET_ARCH}/$smptype/.kernelrelease $a/
1232 [ -f "$b/${TARGET_ARCH}/$smptype/.kernelrelease" ] && KERNELRPMRELEASE="$b/${TARGET_ARCH}/$smptype/.kernelrelease"
1234 LINUXOBJ=$b/${TARGET_ARCH}/$smptype
1235 # local fname=$(basename $kernel_rpm)
1236 # KERNELRPMSDIR=${kernel_rpm%$fname}
1240 [ "$LINUX" = "" ] && return 255
1241 [ -d "$LINUX" ] || return 255
1244 #build linux kernel rpm
1247 pushd $LINUX || return 255
1248 make binrpm-pkg || ( popd ; return 255 )
1250 [ -f ".version" ] && addlnxrel="-$(cat .version)"
1253 for arch in $TARGET_ARCHS_ALL; do
1254 [ -f "/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
1255 KERNELRPM="/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
1257 [ -f "/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
1258 KERNELRPM="/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
1261 [ "$KERNELRPM" = "" ] || return
1269 local nocopykernel=$2
1270 pushd $LINUX || fatal 1 "Kernel source not found"
1271 [ "$nofullmake" = "nofullmake" ] || make mrproper
1272 [ "$nofullmake" = "nofullmake" ] || rm -f rpm-release
1273 # [ "$nocopykernel" = "copyrpmkernel" ] || rm -f localversion-*
1274 [ "$nocopykernel" = "copykernel" ] && [ -f "$CONFIG_FILE" ] && cp $CONFIG_FILE .config
1275 if [ "$nocopykernel" = "copyrpmkernel" ]; then
1276 [ -f "$KERNELRPMCONFIG" ] && cp $KERNELRPMCONFIG .config
1277 if [ -f "$KERNELRPMRELEASE" ]; then
1278 cp $KERNELRPMRELEASE .
1280 sed -e "s/^EXTRAVERSION\s\+=\s\+.*$/EXTRAVERSION = -${lnxrel}/" < Makefile > Makefile.new
1281 [ -f "Makefile.new" ] && mv Makefile.new Makefile
1284 [ -f ".config" ] || ( popd ; echo "Cannot find .config file"; return 255 )
1285 make oldconfig || ( popd ; return 255 )
1286 make include/linux/version.h
1287 if [ ! "$nofullmake" = "nofullmake" ]; then
1288 make || ( popd ; return 255 )
1296 # build kernel-ib{,-devel}
1297 # some I/B drivers are architecture dependent and kernel-ib's configure
1298 # does not figure it out for us ~sigh~
1299 local configure_options=""
1300 case "$TARGET_ARCH" in
1302 configure_options="--with-ipath_inf-mod"
1305 configure_options="--with-ipath_inf-mod --with-ehca-mod"
1309 # ofed 1.3 had a bug in the rpm spec
1310 if [ "$OFED_VERSION" = "1.3" ]; then
1313 $RPMBUILD --rebuild --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
1314 --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
1315 --define "KVERSION ${LINUXRELEASE}" \
1316 --define "$K_SRC ${LINUXOBJ:-${LINUX}}" \
1317 --define "LIB_MOD_DIR /lib/modules/${LINUXRELEASE}/updates" \
1318 --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
1320 if [ ${PIPESTATUS[0]} != 0 ]; then
1321 fatal 1 "Error building kernel-ib"
1324 pushd "$TOPDIR" >/dev/null
1325 rm -rf kernel-ib-devel
1326 mkdir kernel-ib-devel
1328 local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${LINUXRELEASE//-/_}.*.rpm)
1329 rpm2cpio -itv < $rpm | cpio -id
1330 CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
1334 #build patchless lustre
1335 patchless_build_sequence()
1337 if [ -f $LINUX/Makefile ]; then
1338 # Get the correct kernel release - I'm unsure how this can ever
1339 # work otherwise, unless you're using the exact same kernel version
1340 # Lustre is shipped with.
1342 local LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
1343 if [ -z "$LINUXRELEASE" ]; then
1344 echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
1348 lnxmaj=$(echo $LINUXRELEASE | cut -f1 -d-)
1349 EXTRA_VERSION=$(echo $LINUXRELEASE | cut -f2 -d-)_lustre.$LUSTRE_VERSION
1351 build_lustre && buildsuccess=true
1353 #try to build from kernel-devel RPM (RHEL)
1356 local rpmfound=false
1357 local buildsuccess=false
1358 local storeforreuse=false
1359 if [ "$KERNELRPMSBASE" = "" ] || [ ! -d "$KERNELRPMSBASE" ]; then
1362 [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
1364 local delimiter=${EXTRA_VERSION_DELIMITER:-"-"}
1365 # default to source type -source and special case below
1373 unpack_linux_rpm $type $delimiter && rpmfound=true
1375 [ -d SRPMS ] || mkdir SRPMS
1376 [ -d RPMS ] || mkdir RPMS
1377 [ -d BUILD ] || mkdir BUILD
1378 [ -d SOURCES ] || mkdir SOURCES
1380 # first build kernel-ib
1381 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1382 $rpmfound && build_kernel_ib
1384 ( $rpmfound ) && build_lustre && buildsuccess=true && find_linux_source_rpm
1387 if $buildsuccess; then
1388 [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELRPM" ] && \
1389 cp "$KERNELRPM" RPMS/${TARGET_ARCH}/
1390 [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELSOURCERPM" ] && \
1391 cp "$KERNELSOURCERPM" RPMS/${TARGET_ARCH}/
1392 KERNELCOMPILEDIR="$LINUX"
1393 if $storeforreuse; then
1394 store_for_reuse || echo "Cannot store for future reuse"
1398 elif ! $rpmfound; then
1399 echo "COULD NOT FIND VENDOR -devel or -source RPM for $DISTRO/$TARGET_ARCH: $lnxmaj-$lnxrel in $KERNELRPMSBASE"
1402 echo "Patchless build failed."
1407 #check timestamp value. should bi 14-digits string
1411 local timestampnodig=$(echo $invalue | sed -e s/[0-9]*//g)
1412 [ "$timestampnodig" = "" ] || return 255
1413 local timestamplength="${#invalue}"
1414 [ $timestamplength -eq 14 ] || return 255
1417 # get list of suitable directories with potential reused staff
1418 get_reuse_dir_list()
1421 local reusedkernelmasknew=$2
1422 local buildtimestamp=
1424 local sourcelastdate=$(get_last_source_date)
1425 for buildtimestamp in $(ls "$REUSEBUILD/" 2>&1); do
1426 [ -d "$REUSEBUILD/$buildtimestamp" ] || continue
1427 check_timestamp "$buildtimestamp" || continue
1428 local buildtimestampstr=$(echo $buildtimestamp | \
1429 sed -e "s^\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)^\1-\2-\3 \4:\5:\6 GMT^g")
1430 local buildtimestampepoch=$(date --date="$buildtimestampstr" +%s )
1431 #check for suitable date
1432 if ! $PATCHLESS; then
1433 [ $buildtimestampepoch -ge $sourcelastdate ] || continue
1435 #check for suitable version
1436 if [ "$rpmonly" = "rpmonly" ]; then
1437 local reusedkernelprefix="kernel-lustre-"
1438 ( $PATCHLESS ) && reusedkernelprefix=
1439 local rpmmask="${reusedkernelprefix}${REUSEDKERNELMASK}"
1440 [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
1441 [ -f $REUSEBUILD/$buildtimestamp/${rpmmask}.rpm ] && \
1442 dirsforreuse="$dirsforreuse $REUSEBUILD/$buildtimestamp"
1444 local rpmmask="$REUSEDKERNELMASK"
1445 [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
1446 pushd $REUSEBUILD/$buildtimestamp/linux-${rpmmask} > /dev/null 2>&1 || continue
1448 dirsforreuse="$dirsforreuse $curdir"
1452 echo "$dirsforreuse"
1455 #try to reuse old RPM
1456 build_sequence_rpm_reuse()
1459 [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
1461 if ! [ "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse RPM
1462 local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
1463 REUSEDKERNELMASKnew="kernel-lustre-source-${REUSEDKERNELMASKnew}"
1464 local dirsforreuse="$(get_reuse_dir_list rpmonly $REUSEDKERNELMASKnew)"
1465 local buildsuccess=false
1467 for curdir in $(echo $dirsforreuse); do
1468 [ -d "$curdir" ] || continue
1469 local reusedkernelprefix="kernel-lustre-"
1470 local reusedkernelrpm=
1471 [ -f ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
1472 reusedkernelrpm=$(ls ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
1473 [ -f "$reusedkernelrpm" ] || continue
1475 local reusedkernelsourcerpm=
1476 [ -f ${curdir}/${REUSEDKERNELMASKnew}.rpm ] && \
1477 reusedkernelsourcerpm=$(ls ${curdir}/${REUSEDKERNELMASKnew}.rpm | head -1 )
1478 [ -f "$reusedkernelsourcerpm" ] || continue
1480 # don't need to check for kernel-ib RPM reuse here because sles9 is not supported
1481 # by OFED >= 1.3.0 and this function appears to only be used for sles9
1483 [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
1484 reuse_kernel_rpm "$reusedkernelsourcerpm" "" && build_linux nofullmake copyrpmkernel && build_lustre && buildsuccess=true
1485 ( $buildsuccess ) || continue
1486 if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
1487 [ -f "$reusedkernelrpm" ] && \
1488 cp -f "$reusedkernelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1490 [ -f "$reusedkernelsourcerpm" ] && \
1491 cp -f "$reusedkernelsourcerpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
1492 touch RPMS/${TARGET_ARCH}/kernel_was_reused
1500 #try to reuse old BUILD dir
1501 build_sequence_reuse()
1504 [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
1506 if [ ! "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse old kernel build directory
1507 local dirsforreuse="$(get_reuse_dir_list)"
1508 local buildsuccess=false
1510 local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
1511 for curdir in $(echo $dirsforreuse); do
1512 local reusedkernelrpm=
1513 local reusedkernelsourcerpm=
1514 local reusedkernelibrpm=
1515 [ -d "$curdir" ] || continue
1516 [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" -a
1517 ! -d "${curdir%/*}/ofa_kernel" ] && continue
1518 local reusedkernelprefix="kernel-lustre-"
1519 ( $PATCHLESS ) && reusedkernelprefix=
1520 [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
1521 reusedkernelrpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
1522 reusedkernelprefix="kernel-lustre-source-"
1523 [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm ] && \
1524 reusedkernelsourcerpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm | head -1 )
1525 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1527 reusedkernelprefix="kernel-ib-"
1528 [ -f ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm ] && \
1529 reusedkernelibrpm=$(ls ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 )
1530 reusedkernelibdevelrpm=$(ls ${curdir}/../${reusedkernelprefix}devel-${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 )
1532 if ! ( $NORPM ) && ! [ -f "$reusedkernelrpm" ]; then #kernel rpm not found. Build all
1535 if ! ( $NORPM ) && ! [ -f "$reusedkernelsourcerpm" ]; then #kernel source rpm not found. Build all
1538 if [ -n "$OFED_VERSION" ]; then
1539 if [ "$OFED_VERSION" != "inkernel" ]; then
1540 if ! ( $NORPM ) && [ ! -f "$reusedkernelibrpm" -o ! -f "$reusedkernelibdevelrpm"]; then #kernel-ib{,-devel} rpm not found. Build all
1543 CONFIGURE_FLAGS="--with-o2ib=${curdir%/*}/ofa_kernel ${CONFIGURE_FLAGS}"
1545 CONFIGURE_FLAGS="--with-o2ib=yes ${CONFIGURE_FLAGS}"
1549 build_lustre || continue
1552 if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
1553 [ -f "$reusedkernelrpm" ] && \
1554 cp -f "$reusedkernelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
1555 touch RPMS/${TARGET_ARCH}/kernel_was_reused
1556 [ -f "$reusedkernelsourcerpm" ] && \
1557 cp -f "$reusedkernelsourcerpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1558 [ -f "$reusedkernelibrpm" ] && \
1559 cp -f "$reusedkernelibrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1560 cp -f "$reusedkernelibdevelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1571 if (( $DO_SRC )) ; then
1577 prep_kernel_build || return 255
1578 clean_lustre || return 255
1580 build_kernel || return 255
1583 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
1585 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 -- "$@")
1587 if [ $? != 0 ] ; then
1591 eval set -- "$options"
1629 --linux | --with-linux)
1704 --disable-datestamp)
1715 CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests"
1719 usage 1 "Unrecognized option: $1"
1729 EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
1731 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1737 patchless_build_sequence && build_success=true
1738 elif [ -z "$LINUX" ] ; then
1739 [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
1740 if ! $build_success; then
1741 build_sequence_reuse && build_success=true
1742 if ! $build_success; then
1743 build_sequence && build_success=true
1744 if $build_success; then
1745 store_for_reuse || echo "Cannot store for future reuse"
1750 build_lustre && build_success=true
1752 ( $build_success ) || fatal 1 "Cannot build lustre"