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 ''"
79 # Readlink is not present on some older distributions: emulate it.
83 if [ -L "$path" ]; then
84 ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
98 [ "$1" ] && echo -e "\n${0##*/}: $1"
110 echo -n "Available targets:"
111 for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do
112 target_file=${target##*/}
113 echo -n " ${target_file%%.target}"
121 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
124 Specifies the CVS Root to use when pulling files from CVS. The
125 environment variable \$CVSROOT is used if this option is not
128 --external-patches=EXTERNAL_PATCHES
129 Directory similar to lustre/lustre/kernel_patches/ that lbuild should
130 look for seres and config files in before looking in the lustre
133 --extraversion=EXTRAVERSION
134 Text to use for the rpm release and kernel extraversion.
136 --kerneldir=KERNELDIR
137 Directory containing Linux source tarballs referenced by target
140 --timestamp=TIMESTAMP
141 Date of building lustre in format YYYYMMDDhhmmss
144 Try to reuse old kernel RPMs from DIR
147 Try to reuse old kernel builds from DIR
150 Path to distro kernel RPM collection
156 Do not build RPMs (compile only mode)
159 Build lustre client only
162 Which distro using. Autodetect by default
164 --kerneltree=KERNELTREE
165 Directory containing dirs with Linux source tarballs referenced by target
166 files. Dir names in format kernel version ('2.6.9', etc.)
169 Directory of Linux kernel sources. When this option is used, only
170 Lustre modules and userspace are built.
173 Path to an existing lustre source tarball to use instead of
177 Do not try to download a kernel from ftp.lustre.org
180 Do not build a .src.rpm, a full kernel patch, or a patched kernel
184 Do ldiskfs RPM. Now true by default
190 Specifies that the files generated do not include timestamps, and
191 that this is an official release.
194 Build a .src.rpm, a full kernel patch, and a patched kernel tarball.
197 Directory used to stage packages for release. RPMs will be placed
198 more or less in DIR/<target>-<arch>, and the tarball will be
202 A CVS branch/tag name to build from when pulling from CVS.
205 The name of the target to build. The available targets are listed
208 --target-archs=TARGET_ARCHS
209 A (space delimited) list of architectures to build. By default,
210 all of the archs supported by the TARGET will be built, in
211 addition to a .src.rpm. This option can limit those, for machines
212 that can only build certain archs or if you only want a certain
213 arch built (for testing, or a one-off kernel).
215 Also note that by using a non-"base" arch (eg, i386) only kernels
216 will be built - there will be no lustre-lite-utils package.
219 Prevents the datestamp flag (-D) from being passed to cvs for
220 checkouts. This is a workaround for a problem encountered when
221 using lbuild with tinderbox.
232 if [ "$LUSTRE" ] ; then
233 [ -r "$LUSTRE" ] || \
234 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
237 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
239 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
242 if [ -z "$LINUX" ] ; then
243 [ "$KERNELDIR" -o "$KERNELTREE" ] || \
244 usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree."
246 [ -d "$KERNELDIR" -o -d "$KERNELTREE" ] || \
247 usage 1 "$KERNELDIR and $KERNELTREE are not a directory."
251 usage 1 "When building a snapshot, a tag name must be used."
254 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
255 # TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
256 # [ -r "$TARGET_FILE" ] || \
257 # usage 1 "Target '$TARGET' was not found."
262 CANONICAL_TARGET="rhel5"
265 CANONICAL_TARGET="rhel-2.6"
268 CANONICAL_TARGET="sles-2.6"
271 CANONICAL_TARGET="sles10-2.6"
274 CANONICAL_TARGET="hp-pnnl-2.4"
282 CANONICAL_TARGET="$TARGET"
286 local timestampnodig=$(echo $TIMESTAMP | sed -e s/[0-9]*//g)
287 [ "$timestampnodig" = "" ] || TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
288 local timestamplength="${#TIMESTAMP}"
289 if [ $timestamplength -eq 12 ]; then
290 TIMESTAMP="${TIMESTAMP}00"
291 elif [ $timestamplength -ne 14 ]; then
292 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
295 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
296 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
297 RPMBUILD=$(which rpm 2>/dev/null | head -1)
298 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
299 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
303 if [ -n "$CCACHE" ]; then
304 which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc"
305 which "$DISTCC" 2>/dev/null && export DISTCC RPM_BUILD_NCPUS
306 local bindir="/cache/build/bin"
307 [ -d $bindir ] || mkdir -p $bindir
308 [ -d $bindir ] && rm ${bindir}/* > /dev/null 2>&1
309 which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/ccache
310 which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/cc
311 which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/gcc
312 [ -d $bindir ] && export PATH=$bindir:$PATH
315 [ -z "$DISTRO" ] && autodetect_distro
318 #autodetect used Distro
321 if [ -f /etc/SuSE-release ]; then
323 elif [ -f /etc/redhat-release ]; then
324 local distroname=$(head -1 /etc/redhat-release | grep -e "CentOS\|Red")
325 if [ ! "$distroname" = "" ]; then
326 local version=$(echo "$distroname" | sed -e s/[^0-9.]*//g | sed -e s/\\..*// )
328 [ "$version" = "" ] || DISTRO="${distroname}${version}"
331 [ "$DISTRO" = "" ] && DISTRO="sles9" #default distro
336 echo $(echo "$*" | xargs -n 1 | sort -u)
343 if [ "$TARGET" = "rhel-2.6" -o "$TARGET" = "rhel-2.4" ]; then
345 if [ "$TARGET" = "rhel-2.6" ]; then
347 OLDCONFIG=nonint_oldconfig
348 elif [ "$TARGET" = "rhel-2.4" ]; then
353 RPMTOPDIR=$(mktemp -d $KERNELDIR/rpm_XXXXXX)
354 mkdir $RPMTOPDIR/BUILD/
355 rpm -ivh $KERNELDIR/$SRPM --define "_topdir $RPMTOPDIR" || \
356 { rm -rf $RPMTOPDIR; fatal 1 "Error installing kernel SRPM."; }
357 $RPMBUILD -bp --nodeps --target i686 $RPMTOPDIR/SPECS/$SPEC --define "_topdir $RPMTOPDIR"
358 pushd $RPMTOPDIR/BUILD/kernel-${lnxmaj}/linux-${lnxmaj} && {
360 cp configs/kernel-${lnxmaj}-i686-smp.config .config
361 if ! make $OLDCONFIG > /dev/null; then
362 fatal 1 "error trying to make $OLDCONFIG while building a tarball from SRPM."
364 make include/linux/version.h
367 tar cjf $KERNEL_FILE linux-${lnxmaj}
374 download_and_build_tarball() {
378 local srpm=kernel-${lnxmaj}-${lnxrel}.src.rpm
380 echo "Downloading http://ftp.lustre.org/kernels/$target/old/$srpm..."
381 if ! wget -nv "http://ftp.lustre.org/kernels/$target/old/$srpm" \
382 -O "$KERNELDIR/$srpm" ; then
383 fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from ftp.lustre.org."
386 build_tarball $target $srpm
391 EXTRA_VERSION_save="$EXTRA_VERSION"
392 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
393 TARGET_FILE="$patchesdir/targets/$TARGET.target"
394 [ -r "$TARGET_FILE" ] && break
396 [ -r "$TARGET_FILE" ] || \
397 fatal 1 "Target $TARGET was not found."
399 echo "Loading target config file $TARGET.target..."
403 [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
404 [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
406 #CC was overwriten in TARGET_FILE
407 which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc"
409 if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then
410 KERNELDIR="$KERNELTREE/${lnxmaj}"
411 [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR"
414 if [ "$KERNELDIR" ] ; then
415 KERNEL_FILE="$KERNELDIR/$KERNEL"
416 if [ ! -r "$KERNEL_FILE" ] ; then
417 # see if we have an SRPM we can build a tarball for
418 KERNEL_SRPM=kernel-${lnxmaj}-${lnxrel}.src.rpm
419 if [ -r "$KERNELDIR/$KERNEL_SRPM" ] ; then
420 build_tarball $CANONICAL_TARGET $KERNEL_SRPM
422 if (( $DOWNLOAD )) ; then
423 echo "Downloading http://ftp.lustre.org/kernels/$CANONICAL_TARGET/old/$KERNEL..."
424 if ! wget -nv "http://ftp.lustre.org/kernels/$CANONICAL_TARGET/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then
425 # see if we can do it with an SRPM from the download site
426 download_and_build_tarball $CANONICAL_TARGET $KERNEL_FILE
429 fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
435 if [ "$SERIES" ] ; then
436 for series in $SERIES ; do
437 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
438 [ -r "$patchesdir/series/$series" ] && continue 2
440 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."
444 if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
445 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config"
448 for smptype in $SMPTYPES; do
449 [ "$smptype" = "''" ] && smptype=
450 if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config ]; then
451 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config"
452 KERNCONFSMPTYPE=$smptype
456 local lnxrelnew=$( echo ${lnxrel} | sed s/-/_/g )
458 [ -f "$CONFIG_FILE" ] || \
459 fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
460 if [ "$EXTRA_VERSION_save" ] ; then
461 EXTRA_VERSION="$EXTRA_VERSION_save"
462 elif ! $RELEASE; then
463 # if there is no patch series, then this is not a lustre specific
464 # kernel. don't make it look like one
465 if [ -n "$SERIES" ]; then
466 #remove the @VERSION@ (lustre version)
467 # EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
468 # EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
469 ! ( $PATCHLESS ) && EXTRA_VERSION="${EXTRA_VERSION}.${TIMESTAMP}"
472 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
474 [ -z $REUSEDKERNELMASK ] && \
475 # create mask for kernel RPM/builddir which could be reused
477 REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.*${TARGET_ARCH}
479 REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TARGET_ARCH}
481 REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TIMESTAMP}.${TARGET_ARCH}
483 # kernel-lustre-smp-2.6.9-55.0.2.EL_lustre.1.6.1.i686.rpm
485 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
488 for arch in $(uniqify "$ALL_ARCHS") ; do
489 if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then
490 BUILD_ARCHS="$BUILD_ARCHS $arch"
493 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
494 echo "Building for: $BUILD_ARCHS"
501 fatal 1 "tarflags(): File name argument missing."
513 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
520 echo "Untarring ${1##*/}..."
521 tar $(tarflags "$1") "$1"
526 DIRNAME="lustre-$TAG-$TIMESTAMP"
527 if [ "$LUSTRE" ] ; then
529 [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
531 if [ "$USE_DATESTAMP" ]; then
532 DATESTAMP="-D '$DATE'"
537 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
538 fatal 1 "There was an error checking out toplevel Lustre from CVS."
539 pushd "$DIRNAME" > /dev/null
540 ./lustrecvs "$TAG" || \
541 fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."
542 echo "Creating lustre tarball..."
543 sh autogen.sh || fatal 1 "There was an error running autogen.sh."
544 ./configure --disable-{modules,utils,liblustre,tests,doc} || \
545 fatal 1 "There was an error running ./configure to create makefiles."
546 make dist || fatal 1 "There was an error running 'make dist'."
548 fname=$(basename $DIRNAME/lustre-*.tar.gz)
549 cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."
551 ln -sf "$DIRNAME" lustre
558 [ -d linux ] || ln -sf linux* linux
563 [ "$SERIES" ] || return 0
564 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
565 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
566 pushd linux >/dev/null
567 for series in $SERIES ; do
568 echo -n "Applying series $series:"
569 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
570 [ -r "$patchesdir/series/$series" ] || continue
571 SERIES_FILE="$patchesdir/series/$series"
572 for patch in $(<"$SERIES_FILE") ; do
574 PATCH_FILE="$patchesdir/patches/$patch"
575 [ -r "$PATCH_FILE" ] || \
576 fatal 1 "Patch $patch does not exist in Lustre tree."
577 cat "$PATCH_FILE" >> "$FULL_PATCH" || \
578 fatal 1 "Error adding patch $patch to full patch."
579 patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
586 echo "Full patch has been saved in ${FULL_PATCH##*/}."
587 echo "Replacing .config files..."
588 [ -d linux/configs ] || mkdir linux/configs || \
589 fatal 1 "Error creating configs directory."
590 rm -f linux/configs/*
592 for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
593 [ "$patchesdir" ] && \
594 cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
596 [ "$copysuccess" = "1" ] || \
597 fatal 1 "Error copying in kernel configs."
602 TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
603 echo "Creating patched linux tarball $TARBALL..."
604 tar zcf "$TARBALL" "$(readlink linux)" \
605 --exclude "CVS" --exclude ".cvsignore" || \
606 --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
607 fatal 1 "Error creating patched Linux tarball."
612 [ -d linux ] || return 0
613 echo "Cleaning linux..."
614 [ -L linux ] && rm -rf $(readlink linux)
621 ENABLE_INIT_SCRIPTS=""
623 -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
624 -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
625 -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
626 -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
627 -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
628 -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
629 -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
630 -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
631 -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
632 -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
633 -e "s^@KERNEL_VERSION@^$VERSION^g" \
634 -e "s^@LINUX26@^$LINUX26^g" \
635 -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
636 -e "s^@LUSTRE_TARGET@^$TARGET^g" \
637 -e "s^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \
638 -e "s^@RHBUILD@^$RHBUILD^g" \
639 -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
640 -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
641 -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
642 < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
643 > lustre-kernel-2.4.spec
644 [ -d SRPMS ] || mkdir SRPMS
645 [ -d RPMS ] || mkdir RPMS
646 [ -d BUILD ] || mkdir BUILD
647 [ -d SOURCES ] || mkdir SOURCES
648 for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
649 suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} \
650 sles8-{pre,post,postun,update_{INITRD_MODULES,rcfile_setting}}.sh ; do
651 cp $TOPDIR/lustre/build/$script SOURCES
653 cp "$LUSTRE" "$KERNEL_FILE" SOURCES
654 if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
655 tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
657 touch SOURCES/external-patches.tar.gz
663 [ -d lustre ] || return 0
664 echo "Cleaning Lustre..."
665 [ -L lustre ] && rm -rf $(readlink lustre)
671 echo "Building kernel + Lustre RPMs for: $BUILD_ARCHS..."
673 for arch in $BUILD_ARCHS ; do
674 targets="--target $arch $targets"
677 local rpmbuildopt='-bb'
680 # echo NORPM mode. Only compiling.
681 # echo "XXX: need to fix lmake - add options to do rpmbuild -bc instead of -bb"
684 $RPMBUILD $targets $rpmbuildopt lustre-kernel-2.4.spec \
685 --define "_tmppath $TMPDIR" \
686 --define "_topdir $TOPDIR" || \
687 fatal 1 "Error building rpms for $BUILD_ARCHS."
689 if (( $DO_SRC )) ; then
690 $RPMBUILD -bs lustre-kernel-2.4.spec \
691 --define "_tmppath $TMPDIR" \
692 --define "_topdir $TOPDIR" || \
693 fatal 1 "Error building .src.rpm."
696 ( $(skeep_ldiskfs_rpm $TAG) ) && return
698 pushd $TOPDIR/BUILD/lustre*/ldiskfs || return 255
700 if [ "$?" != "0" ] ; then
704 cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
708 local ldiskfs_spec=lustre-ldiskfs.spec
709 [ -f "$ldiskfs_spec" ] && sed \
710 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
712 > ../lustre-ldiskfs.spec
714 $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
715 --define "_tmppath /var/tmp" \
716 --define "_topdir $TOPDIR"
717 if [ "$?" != "0" ] ; then
722 if (( $DO_SRC )) ; then
723 $RPMBUILD -bs ../lustre-ldiskfs.spec \
724 --define "_tmppath /var/tmp" \
725 --define "_topdir $TOPDIR"
726 if [ "$?" != "0" ] ; then
736 [ -d SRPMS ] || mkdir SRPMS
737 [ -d RPMS ] || mkdir RPMS
738 [ -d BUILD ] || mkdir BUILD
739 [ -d SOURCES ] || mkdir SOURCES
743 pushd lustre >/dev/null
745 echo "Building Lustre RPMs for: $BUILD_ARCHS..."
747 for arch in $BUILD_ARCHS ; do
748 targets="--target $arch $targets"
751 local confoptions="--with-linux=${LINUX}"
753 confoptions="--with-linux=${LINUX} --disable-server"
755 if [ ! "$LINUXOBJ" = "" ]; then
756 confoptions="$confoptions --with-linux-obj=${LINUXOBJ}"
759 ./configure $confoptions ${CONFIGURE_FLAGS}
760 if [ "$?" != "0" ] ; then
761 local saved_config="../config.log.$(date +%s)"
762 cp config.log $saved_config
763 chmod a+r $saved_config
764 echo "Saved config.log is at $saved_config"
771 # hack. Somebody move build/lustre.spec to lustre.spec for b1_6
773 [ -f lustre.spec ] && lustre_spec=lustre.spec
774 [ -f build/lustre.spec ] && lustre_spec=build/lustre.spec
776 [ -f "$lustre_spec" ] && sed \
777 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
781 local rpmbuildopt='-bb'
784 echo NORPM mode. Only compiling.
787 $RPMBUILD $targets $rpmbuildopt ../lustre.spec \
788 --define "_tmppath $TMPDIR" \
789 --define "_topdir $TOPDIR" || \
790 fatal 1 "Error building rpms for $BUILD_ARCHS."
793 ( $(skeep_ldiskfs_rpm $TAG) ) && return
795 pushd lustre/ldiskfs || return 255
797 if [ "$?" != "0" ] ; then
801 cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
805 local ldiskfs_spec=lustre-ldiskfs.spec
806 [ -f "$ldiskfs_spec" ] && sed \
807 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
809 > ../lustre-ldiskfs.spec
811 $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
812 --define "_tmppath /var/tmp" \
813 --define "_topdir $TOPDIR"
814 if [ "$?" != "0" ] ; then
819 if (( $DO_SRC )) ; then
820 $RPMBUILD -bs ../lustre-ldiskfs.spec \
821 --define "_tmppath /var/tmp" \
822 --define "_topdir $TOPDIR"
823 if [ "$?" != "0" ] ; then
833 [ "$STAGEDIR" ] || return 0
835 for arch in $BUILD_ARCHS ; do
836 rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
837 echo "${0##*/}: Copying RPMs into ${rpmdir}"
839 cp -v RPMS/${arch}/*.rpm "${rpmdir}"
840 if [ -d RPMS/noarch ] ; then
841 cp -v RPMS/noarch/*.rpm "${rpmdir}"
845 cp -v "$LUSTRE" "$STAGEDIR"
848 #check if we need to build separate ldiskfs RPM
853 if ! $LDISKFSRPM; then
855 elif $PATCHLESS; then
858 for skiptag in $SKIPLDISKFSRPM; do
859 [[ $tag == $skiptag ]] && skip=true && break
865 #get date of last changed target/config/series/patches
866 get_last_source_date()
868 local filelist="${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} \
870 local TOPDIRnew=$(echo ${TOPDIR} | sed -e s/\\//\\\\\\//g)
871 filelist="$filelist $( \
872 cat ${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} | \
873 sed -e s/^/${TOPDIRnew}\\/lustre\\/lustre\\/kernel_patches\\/patches\\// 2>&1)"
874 local sourcelastdate=$( find ${filelist} -name CVS -prune -o \
875 -type f -printf "%T@\n" 2>&1 | sort | tail -1 )
876 is_integer $sourcelastdate && echo $sourcelastdate
879 #check if variable is integer
883 [ "$invariable" = "" ] && return 255
884 local invariableint=$( echo $invariable | sed -e s/[^0-9]//g )
885 [ "$invariable" = "$invariableint" ] || return 255
888 #generate LUSTRE_EXTRA_VERSION from EXTRA_VERSION
892 [ "$KERNCONFSMPTYPE" = "" ] || smptype=$KERNCONFSMPTYPE
893 [ "$RPMSMPTYPE" = "" ] || smptype=$RPMSMPTYPE
895 LUSTRE_EXTRA_VERSION="${lnxmaj}-${EXTRA_VERSION}"
896 if [ "$PATCHLESS" = "true" -a "$DISTRO" = "sles10" ]; then
897 LUSTRE_EXTRA_VERSION="${LUSTRE_EXTRA_VERSION}-${smptype}"
899 LUSTRE_EXTRA_VERSION="${LUSTRE_EXTRA_VERSION}${smptype}"
901 LUSTRE_EXTRA_VERSION=$( echo $LUSTRE_EXTRA_VERSION | sed -e "s^-^_^g" )
904 #store RPMs and/or BUILD dir for feature reuse
908 if [ ! "$REUSEBUILD" = "" ] && [ -d "/$REUSEBUILD/" ] ; then
909 [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || mkdir "${REUSEBUILD}/${TIMESTAMP}"
910 [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || return 255
915 local lnxrelnew=$( echo ${lnxrel} | sed s/-/_/g )
916 local EXTRA_VERSIONnew=$( echo ${EXTRA_VERSION} | sed s/-/_/g )
917 local KERNELRPMnew=$(basename "$KERNELRPM")
918 if [ ! "$rpmonly" = "rpmonly" ]; then
920 if [ ! "$KERNELCOMPILEDIR" = "" ]; then
921 builddir="$KERNELCOMPILEDIR"
923 builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}"
924 [ "$KERNELCOMPILEDIR" = "" ] || builddir="$KERNELCOMPILEDIR"
925 [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}.${lnxrel}"
926 [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}-${lnxrel}"
927 if [ ! -d "$builddir" ]; then
928 pushd "BUILD/lustre-kernel-${lnxmaj}/lustre/" || return 255
929 local basebuilddir=$(ls -d linux-${lnxmaj}* | head -1)
930 [ "$basebuilddir" = "" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/${basebuilddir}"
934 [ -d "$builddir" ] || return 255
935 local dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}"
936 ( $PATCHLESS ) && dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-$KERNELRPMnew" && \
937 dstdir="${dstdir%.rpm}"
938 [ -d "$dstdir" ] && rm -rf "$dstdir"
939 mv "${builddir}" "$dstdir" || return 255
942 local kernelrpmname="kernel-lustre-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
943 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSNnew}.${TARGET_ARCH}.rpm"
944 ( $PATCHLESS ) && [ -f "$KERNELRPM" ] && kernelrpmname="$KERNELRPMnew"
945 if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
946 echo "RPM already exist in store directory tree"
948 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
950 #store kernel source rpm
951 kernelrpmname="kernel-lustre-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
952 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
953 ( $PATCHLESS ) && [ -f "$KERNELSOURCERPM" ] && kernelrpmname=$(basename "$KERNELSOURCERPM")
954 if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
955 echo "RPM already exist in store directory tree"
957 [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
961 #unpack kernel(/source/devel) RPM
965 local pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
966 local kernelbinaryrpm=
967 [ -d $pathtorpms ] || return 255
970 for arch in $TARGET_ARCHS_ALL; do
971 for smptype in $SMPTYPES; do
972 [ "$smptype" = "''" ] && smptype=
973 [ "$smptype" = "" ] || smptype="-${smptype}"
976 rpmfile="kernel${smptype}${prefix}-${lnxmaj}.${lnxrel}.${arch}.rpm"
977 kernelbinaryrpm="kernel${smptype}-${lnxmaj}.${lnxrel}.${arch}.rpm"
980 rpmfile="kernel${smptype}${prefix}-${lnxmaj}-${lnxrel}.${arch}.rpm"
981 kernelbinaryrpm="kernel${smptype}-${lnxmaj}-${lnxrel}.${arch}.rpm"
984 [ -f "${pathtorpms}/${arch}/${kernelbinaryrpm}" ] && KERNELRPM="${pathtorpms}/${arch}/${kernelbinaryrpm}"
985 [ -f "${pathtorpms}/${arch}/${rpmfile}" ] && RPMSMPTYPE=${smptype/-/} && break
987 [ -f "${pathtorpms}/${arch}/${kernelbinaryrpm}" ] && KERNELRPM="${pathtorpms}/${arch}/${kernelbinaryrpm}"
988 [ -f "${pathtorpms}/${arch}/${rpmfile}" ] && TARGET_ARCH="$arch" && BUILD_ARCHS="$arch"
989 [ -f "${pathtorpms}/${arch}/${rpmfile}" ] && break
991 [ -f "${pathtorpms}/${TARGET_ARCH}/${rpmfile}" ] || return 255
992 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
993 pushd $TOPDIR/reused || return 255
994 rpm2cpio < "${pathtorpms}/${TARGET_ARCH}/${rpmfile}" | cpio -idc > /dev/null 2>&1
995 if [ ${PIPESTATUS[0]} -eq 0 ]; then
996 local path2source=$(ls usr/src/kernels/ | grep ${lnxmaj})
997 [ -d "usr/src/kernels/${path2source}" ] && LINUX="$(pwd)/usr/src/kernels/${path2source}"
1005 #look for kernel source RPM
1006 find_linux_source_rpm()
1012 [ ! "$TARGET_ARCH" = "" ] && arch=$TARGET_ARCH && findarch=false
1014 if ! $findarch; then
1015 pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
1016 [ -d $pathtorpms ] || return 255
1019 rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
1022 rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
1025 rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
1028 [ -f "${pathtorpms}/${rpmfile}" ] || return 255
1029 KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
1031 for arch in $TARGET_ARCHS_ALL; do
1032 pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
1033 [ -d $pathtorpms ] || continue
1036 rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
1039 rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
1042 rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
1045 [ -f "${pathtorpms}/${rpmfile}" ] || continue
1046 KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
1051 [ -f "${KERNELSOURCERPM}" ] || return 255
1054 #unpack and make symlinks for reusing kernel RPM
1058 [ "$pathtorpm" = "" ] && return 255
1059 [ -f "$pathtorpm" ] || return 255
1060 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
1061 pushd $TOPDIR/reused || return 255
1063 rpm2cpio < $pathtorpm | cpio -idc
1064 [ ${PIPESTATUS[0]} -eq 0 ] || return 255
1067 if pushd usr/src/linux-*-obj/${TARGET_ARCH}; then
1068 local smptypes="$SMPTYPES"
1069 [ "$RPMSMPTYPE" = "" ] || smptypes=$RPMSMPTYPE
1070 ( ! $PATCHLESS ) && [ ! "$KERNCONFSMPTYPE" = "" ] && smptypes="$KERNCONFSMPTYPE"
1072 for cursmptype in $smptypes; do
1073 [ "$cursmptype" = "''" ] && continue
1074 [ -d $cursmptype ] && smptype=$cursmptype
1075 [ -d $smptype ] && break
1079 if [ "${smptype}" = "" ]; then
1081 return 255 # cannot detect smp type
1083 if pushd usr/src/linux-*-obj/${TARGET_ARCH}/$smptype/include2; then
1084 local base=$(readlink asm)
1085 if [ ! -d "/${base}/" ]; then
1087 base=$(basename "$base")
1088 if pushd ../../../../linux-*/include; then
1091 [ -d "$lsrc/${base}" ] && ln -s $lsrc/${base} asm
1095 read a b < <(echo $(pwd)/usr/src/linux-*)
1096 if [[ $a == $(pwd)/* && $b = $(pwd)/* ]]; then
1097 cp -f $a/include/linux/config.h $b/${TARGET_ARCH}/$smptype/include/linux/
1098 cp $b/${TARGET_ARCH}/$smptype/.config $a/
1099 [ -f "$b/${TARGET_ARCH}/$smptype/.config" ] && KERNELRPMCONFIG="$b/${TARGET_ARCH}/$smptype/.config"
1100 cp $b/${TARGET_ARCH}/$smptype/.kernelrelease $a/
1101 [ -f "$b/${TARGET_ARCH}/$smptype/.kernelrelease" ] && KERNELRPMRELEASE="$b/${TARGET_ARCH}/$smptype/.kernelrelease"
1103 LINUXOBJ=$b/${TARGET_ARCH}/$smptype
1104 # local fname=$(basename $kernel_rpm)
1105 # KERNELRPMSDIR=${kernel_rpm%$fname}
1109 [ "$LINUX" = "" ] && return 255
1110 [ -d "$LINUX" ] || return 255
1113 #build linux kernel rpm
1116 pushd $LINUX || return 255
1117 make binrpm-pkg || ( popd ; return 255 )
1119 [ -f ".version" ] && addlnxrel="-$(cat .version)"
1122 for arch in $TARGET_ARCHS_ALL; do
1123 [ -f "/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
1124 KERNELRPM="/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
1126 [ -f "/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
1127 KERNELRPM="/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
1130 [ "$KERNELRPM" = "" ] || return
1138 local nocopykernel=$2
1139 pushd $LINUX || fatal 1 "Kernel source not found"
1140 [ "$nofullmake" = "nofullmake" ] || make mrproper
1141 [ "$nofullmake" = "nofullmake" ] || rm -f rpm-release
1142 # [ "$nocopykernel" = "copyrpmkernel" ] || rm -f localversion-*
1143 [ "$nocopykernel" = "copykernel" ] && [ -f "$CONFIG_FILE" ] && cp $CONFIG_FILE .config
1144 if [ "$nocopykernel" = "copyrpmkernel" ]; then
1145 [ -f "$KERNELRPMCONFIG" ] && cp $KERNELRPMCONFIG .config
1146 if [ -f "$KERNELRPMRELEASE" ]; then
1147 cp $KERNELRPMRELEASE .
1149 sed -e "s/^EXTRAVERSION\s\+=\s\+.*$/EXTRAVERSION = -${lnxrel}/" < Makefile > Makefile.new
1150 [ -f "Makefile.new" ] && mv Makefile.new Makefile
1153 [ -f ".config" ] || ( popd ; echo "Cannot find .config file"; return 255 )
1154 make oldconfig || ( popd ; return 255 )
1155 make include/linux/version.h
1156 if [ ! "$nofullmake" = "nofullmake" ]; then
1157 make || ( popd ; return 255 )
1163 #build patchless lustre
1164 patchless_build_sequence()
1166 #try to build from kernel-devel RPM (RHEL)
1169 local rpmfound=false
1170 local buildsuccess=false
1171 local storeforreuse=false
1172 if [ "$KERNELRPMSBASE" = "" ] || [ ! -d "$KERNELRPMSBASE" ]; then
1175 [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
1176 unpack_linux_rpm "-devel" && rpmfound=true
1177 ( $rpmfound ) && build_lustre && buildsuccess=true && find_linux_source_rpm
1179 if ! $buildsuccess; then
1180 # cannot build from -devel. Try to build from kernel source RPM without rebuilding kernel
1182 # first unpack kernel binary RPM
1184 [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
1185 unpack_linux_rpm && rpmfound=true
1186 ! ( $rpmfound ) && echo "Cannot find kernel RPM"
1188 if ! $rpmfound; then #kernel RPM not found.
1190 build_sequence_reuse && buildsuccess=true
1191 if ! $buildsuccess; then
1192 # reuse failed. Try to build from tarbal
1195 unpack_linux && LINUX="$TOPDIR/linux" && \
1196 build_linux fullmake copykernel && build_linux_rpm
1197 ! [ "$KERNELRPM" = "" ] && build_lustre && storeforreuse=true && buildsuccess=true
1200 # next find and unpack source RPM
1202 find_linux_source_rpm && rpmfound=true
1204 reuse_kernel_rpm "$KERNELSOURCERPM" && build_linux nofullmake copyrpmkernel && build_lustre && buildsuccess=true
1208 if ! $buildsuccess && $rpmfound; then
1209 # build wrong. try to build kernel first
1210 REUSEDKERNELMASK=$(basename $KERNELRPM | sed s/\\.rpm//)
1211 build_sequence_reuse && buildsuccess=true
1214 if ! $buildsuccess && $rpmfound; then
1215 build_linux fullmake copyrpmkernel && build_lustre && buildsuccess=true && storeforreuse=true
1218 if $buildsuccess; then
1219 [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELRPM" ] && \
1220 cp "$KERNELRPM" RPMS/${TARGET_ARCH}/
1221 [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELSOURCERPM" ] && \
1222 cp "$KERNELSOURCERPM" RPMS/${TARGET_ARCH}/
1223 KERNELCOMPILEDIR="$LINUX"
1224 if $storeforreuse; then
1225 store_for_reuse || echo "Cannot store for feature reuse"
1230 # patchless build filed
1234 #check timestamp value. should bi 14-digits string
1238 local timestampnodig=$(echo $invalue | sed -e s/[0-9]*//g)
1239 [ "$timestampnodig" = "" ] || return 255
1240 local timestamplength="${#invalue}"
1241 [ $timestamplength -eq 14 ] || return 255
1244 # get list of suitable directories with potential reused staff
1245 get_reuse_dir_list()
1248 local reusedkernelmasknew=$2
1249 local buildtimestamp=
1251 local sourcelastdate=$(get_last_source_date)
1252 for buildtimestamp in $(ls "$REUSEBUILD/" 2>&1); do
1253 [ -d "$REUSEBUILD/$buildtimestamp" ] || continue
1254 check_timestamp "$buildtimestamp" || continue
1255 local buildtimestampstr=$(echo $buildtimestamp | \
1256 sed -e "s^\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)^\1-\2-\3 \4:\5:\6 GMT^g")
1257 local buildtimestampepoch=$(date --date="$buildtimestampstr" +%s )
1258 #check for suitable date
1259 if ! $PATCHLESS; then
1260 [ $buildtimestampepoch -ge $sourcelastdate ] || continue
1262 #check for suitable version
1263 if [ "$rpmonly" = "rpmonly" ]; then
1264 local reusedkernelprefix="kernel-lustre-"
1265 ( $PATCHLESS ) && reusedkernelprefix=
1266 local rpmmask="${reusedkernelprefix}${REUSEDKERNELMASK}"
1267 [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
1268 [ -f $REUSEBUILD/$buildtimestamp/${rpmmask}.rpm ] && \
1269 dirsforreuse="$dirsforreuse $REUSEBUILD/$buildtimestamp"
1271 local rpmmask="$REUSEDKERNELMASK"
1272 [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
1273 pushd $REUSEBUILD/$buildtimestamp/linux-${rpmmask} > /dev/null 2>&1 || continue
1275 dirsforreuse="$dirsforreuse $curdir"
1279 echo "$dirsforreuse"
1282 #try to reuse old RPM
1283 build_sequence_rpm_reuse()
1286 [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
1288 if ! [ "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse RPM
1289 local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
1290 REUSEDKERNELMASKnew="kernel-lustre-source-${REUSEDKERNELMASKnew}"
1291 local dirsforreuse="$(get_reuse_dir_list rpmonly $REUSEDKERNELMASKnew)"
1292 local buildsuccess=false
1294 for curdir in $(echo $dirsforreuse); do
1295 [ -d "$curdir" ] || continue
1296 local reusedkernelprefix="kernel-lustre-"
1297 local reusedkernelrpm=
1298 [ -f ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
1299 reusedkernelrpm=$(ls ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
1300 [ -f "$reusedkernelrpm" ] || continue
1302 local reusedkernelsourcerpm=
1303 [ -f ${curdir}/${REUSEDKERNELMASKnew}.rpm ] && \
1304 reusedkernelsourcerpm=$(ls ${curdir}/${REUSEDKERNELMASKnew}.rpm | head -1 )
1305 [ -f "$reusedkernelsourcerpm" ] || continue
1307 [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
1308 reuse_kernel_rpm "$reusedkernelsourcerpm" && build_linux nofullmake copyrpmkernel && build_lustre && buildsuccess=true
1309 ( $buildsuccess ) || continue
1310 if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
1311 [ -f "$reusedkernelrpm" ] && \
1312 cp -f "$reusedkernelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1314 [ -f "$reusedkernelsourcerpm" ] && \
1315 cp -f "$reusedkernelsourcerpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
1316 touch RPMS/${TARGET_ARCH}/kernel_was_reused
1324 #try to reuse old BUILD dir
1325 build_sequence_reuse()
1328 [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
1330 if [ ! "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse old kernel build directory
1331 local dirsforreuse="$(get_reuse_dir_list)"
1332 local buildsuccess=false
1334 local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
1335 for curdir in $(echo $dirsforreuse); do
1336 local reusedkernelrpm=
1337 local reusedkernelsourcerpm=
1338 [ -d "$curdir" ] || continue
1339 local reusedkernelprefix="kernel-lustre-"
1340 ( $PATCHLESS ) && reusedkernelprefix=
1341 [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
1342 reusedkernelrpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
1343 reusedkernelprefix="kernel-lustre-source-"
1344 [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm ] && \
1345 reusedkernelsourcerpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm | head -1 )
1346 if ! ( $NORPM ) && ! [ -f "$reusedkernelrpm" ]; then #kernel rpm not found. Build all
1349 if ! ( $NORPM ) && ! [ -f "$reusedkernelsourcerpm" ]; then #kernel source rpm not found. Build all
1353 build_lustre || continue
1356 if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
1357 [ -f "$reusedkernelrpm" ] && \
1358 cp -f "$reusedkernelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
1359 touch RPMS/${TARGET_ARCH}/kernel_was_reused
1360 [ -f "$reusedkernelsourcerpm" ] && \
1361 cp -f "$reusedkernelsourcerpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
1372 if (( $DO_SRC )) ; then
1378 prep_kernel_build || return 255
1379 clean_lustre || return 255
1381 build_kernel || return 255
1384 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
1386 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: -- "$@")
1388 if [ $? != 0 ] ; then
1392 eval set -- "$options"
1430 --linux | --with-linux)
1505 --disable-datestamp)
1512 CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests"
1516 usage 1 "Unrecognized option: $1"
1529 patchless_build_sequence && build_success=true
1530 elif [ -z "$LINUX" ] ; then
1531 [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
1532 if ! $build_success; then
1533 build_sequence_reuse && build_success=true
1534 if ! $build_success; then
1535 build_sequence && build_success=true
1536 if $build_success; then
1537 store_for_reuse || echo "Cannot store for feature reuse"
1544 ( $build_success ) || fatal 1 "Cannot build lustre"