3 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
5 # this is an alternative FD for stdout, to be used especially when we are
6 # taking stdout from a function as it's return value. i.e. foo=$(bar)
7 # this is a workaround until a version of bash where we can put xtrace
13 if [[ $SHELLOPTS = *xtrace* ]]; then
18 # include the exit_traps library
19 . ${0%/lbuild}/exit_traps.sh
21 # our children should die when we do
22 push_exit_trap "kill -INT -$$ || true" kill_children
26 # CVSROOT is inherited from the environment
31 # XXX - some recent hacking has pretty much neutered this option.
32 # search through this file (and lbuild.old_school -- but that will
33 # be going away soon) for "-bb" and see how many places
34 # simply don't account for this option
40 TARGET_ARCH=$(uname -m)
42 TARGET_ARCHS_ALL=$TARGET_ARCH
43 [ "$TARGET_ARCH" = "i686" ] && TARGET_ARCHS_ALL="i686 i586 i386"
49 TMPDIR=${TMPDIR:-"/var/tmp"}
51 # this is a dir to try reuse old kernel RPMs in (although, it seems to be
52 # unused in any real manner
54 # this is the dir that should be used to store reuse products
56 # should cached products be used or force rebuilding?
58 # what does this do exactly? does it imply no kernel build?
61 SKIPLDISKFSRPM="v1_4_* b1_4"
62 SMPTYPES="smp bigsmp default ''"
68 # default to not adding -lustre- into the kernel RPM package names
69 KERNEL_LUSTRE_NAMING=false
86 # not in the target file any more
89 # build the lustre-tests rpm?
101 # Readlink is not present on some older distributions: emulate it.
105 if [ -L "$path" ]; then
106 ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
121 [ -n "$msg" ] && echo -e "\n${0##*/}: $msg" >&3
135 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
138 Specifies the CVS Root to use when pulling files from CVS. The
139 environment variable \$CVSROOT is used if this option is not
142 --external-patches=EXTERNAL_PATCHES
143 Directory similar to lustre/lustre/kernel_patches/ that lbuild should
144 look for seres and config files in before looking in the lustre
147 --extraversion=EXTRAVERSION
148 Text to use for the rpm release and kernel extraversion.
150 --timestamp=TIMESTAMP
151 Date of building lustre in format YYYYMMDDhhmmss
154 Try to reuse old kernel RPMs from DIR
157 Try to reuse old kernel builds from DIR
160 Path to distro kernel RPM collection
166 Do not build RPMs (compile only mode)
169 Build lustre client only
172 Which distro using. Autodetect by default
174 --kerneldir=KERNELDIR
175 Directory containing Linux source tarballs referenced by target
178 --kerneltree=KERNELTREE
179 Directory containing dirs with Linux source tarballs referenced by target
180 files. Dir names in format kernel version ('2.6.9', etc.)
182 --linux=LINUX --with-linux=LINUX
183 Directory of Linux kernel sources. When this option is used, only
184 Lustre modules and userspace are built.
187 Path to an existing lustre source tarball to use instead of
191 Do not try to download a kernel from downloads.lustre.org
194 Do not build a .src.rpm, a full kernel patch, or a patched kernel
198 Do ldiskfs RPM. Now true by default
204 Specifies that the files generated do not include timestamps, and
205 that this is an official release.
208 Build a .src.rpm, a full kernel patch, and a patched kernel tarball.
211 Directory used to stage packages for release. RPMs will be placed
212 more or less in DIR/<target>-<arch>, and the tarball will be
216 A CVS branch/tag name to build from when pulling from CVS.
219 The name of the target to build. The available targets are listed
222 --target-archs=TARGET_ARCHS
223 A (space delimited) list of architectures to build. By default,
224 all of the archs supported by the TARGET will be built, in
225 addition to a .src.rpm. This option can limit those, for machines
226 that can only build certain archs or if you only want a certain
227 arch built (for testing, or a one-off kernel).
229 Also note that by using a non-"base" arch (eg, i386) only kernels
230 will be built - there will be no lustre-lite-utils package.
233 Prevents the datestamp flag (-D) from being passed to cvs for
234 checkouts. This is a workaround for a problem encountered when
235 using lbuild with tinderbox.
238 Builds a Xen domX kernel.
247 # canonicalize a relative path
251 if [ ! -d "$PATH" ]; then
255 pushd "$PATH" >/dev/null || return 1
265 if [ "$LUSTRE" ]; then
266 [ -r "$LUSTRE" ] || \
267 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
270 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
272 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
275 if [ -z "$LINUX" ]; then
276 [ "$KERNELDIR" -o "$KERNELTREE" ] || \
277 usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree."
279 [ -d "$KERNELDIR" -o -d "$KERNELTREE" ] || \
280 usage 1 "$KERNELDIR and $KERNELTREE are not a directory."
284 usage 1 "When building a snapshot, a tag name must be used."
287 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
288 # TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
289 # [ -r "$TARGET_FILE" ] || \
290 # usage 1 "Target '$TARGET' was not found."
295 CANONICAL_TARGET="rhel5"
298 CANONICAL_TARGET="rhel-2.6"
301 CANONICAL_TARGET="sles-2.6"
304 CANONICAL_TARGET="sles10-2.6"
307 CANONICAL_TARGET="sles11"
310 CANONICAL_TARGET="oel5"
313 CANONICAL_TARGET="hp-pnnl-2.4"
321 CANONICAL_TARGET="$TARGET"
325 local timestampnodig=$(echo $TIMESTAMP | sed -e s/[0-9]*//g)
326 [ "$timestampnodig" = "" ] || TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
327 local timestamplength="${#TIMESTAMP}"
328 if [ $timestamplength -eq 12 ]; then
329 TIMESTAMP="${TIMESTAMP}00"
330 elif [ $timestamplength -ne 14 ]; then
331 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
334 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
335 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
336 RPMBUILD=$(which rpm 2>/dev/null | head -1)
337 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
338 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
342 if [ -n "$CCACHE" ]; then
343 which "$DISTCC" &>/dev/null && export DISTCC RPM_BUILD_NCPUS
345 if which "$CCACHE" &>/dev/null; then
346 local ccache=$(which "$CCACHE")
347 local bindir="$TOPDIR/bin"
349 if [ ! -d $bindir ]; then
350 mkdir -p $bindir || fatal 1 "error trying to create $bindir"
352 rm ${bindir}/* > /dev/null 2>&1 || true
354 ln -s "$ccache" ${bindir}/ccache
355 ln -s "$ccache" ${bindir}/cc
356 ln -s "$ccache" ${bindir}/$CC
357 export PATH=$bindir:$PATH
358 export CCACHE && export CC="ccache $CC"
359 # zero the cache so we can see how effective we are being with it
363 # get some ccache stats when we are done
364 push_exit_trap '[ -n "$CCACHE" ] && ccache -s' "ccache_summary"
365 # should remove the ccache trap if lbuild is interrupted
366 trap 'echo "Received an INT TERM or HUP signal, terminating."; delete_exit_trap "ccache_summary"; exit 1' INT TERM HUP
370 [ -z "$DISTRO" ] && DISTRO=$(autodetect_distro)
376 # autodetect used Distro
377 autodetect_distro() {
382 if [ -f /etc/SuSE-release ]; then
384 version=$(grep ^VERSION /etc/SuSE-release)
385 version=${version#*= }
386 elif [ -f /etc/redhat-release ]; then
387 name=$(head -1 /etc/redhat-release)
388 version=$(echo "$distroname" |
389 sed -e 's/^[^0-9.]*//g' | sed -e 's/[ \.].*//')
391 if [ -z "$name" -o -z "$version" ]; then
392 fatal 1 "I don't know how to determine distro type/version.\nEither update autodetect_distro() or use the --distro argument"
395 echo ${name}${version}
402 echo $(echo "$*" | xargs -n 1 | sort -u)
409 local force="${3:-false}"
411 if $force || [ ! -r "$KERNELDIR/$srpm" ] ||
412 [ ! -s "$KERNELDIR/$srpm" ]; then
414 local location="http://downloads.lustre.org/public/kernels/$target/old"
415 echo "Downloading $location/$srpm..."
416 if ! wget -nv "$location/$srpm" -O "$KERNELDIR/$srpm" 2>&1 ||
417 [ ! -s "$KERNELDIR/$srpm" ]; then
418 rm -f $KERNELDIR/$srpm
419 fatal 1 "Could not download target $target's kernel SRPM $srpm from $location."
422 fatal 1 "$srpm not found in directory $KERNELDIR."
433 local file=${from##*/}
439 local semaphore="$to-downloading"
442 if [ ! -f $semaphore ]; then
446 # make sure the download has not been aborted
447 local now=$(date +%s)
448 local file_mtime=$(stat -c %Y "$to")
449 local staleness=$((now - file_mtime))
450 # let's assume an active download will write at least once a minute
451 if [ $staleness -gt 60 ]; then
459 # if the semaphore file exists, the file is either still downloading
460 # or a download was aborted and we cannot trust the target file
461 if [ -f $semaphore ]; then
465 if ! is_downloading && [ -r "$to" ] && [ -s "$to" ]; then
472 if $force || ! is_downloaded; then
473 if is_downloading; then
474 echo "Somebody else is downloading $from..."
475 while is_downloading; do
476 echo "Waiting for $to to finish downloading"
479 if is_downloaded; then
482 echo "The download we were waiting for seems to have been aborted"
488 echo "Downloading $from..."
489 # flag others so they don't try to download also
490 push_exit_trap "rm -f $to $semaphore" "download"
492 if ! wget -nv "$from" -O "$to" || [ ! -s "$to" ]; then
493 # the trap will remove the files via the fatal below
494 fatal 1 "Could not download ${to##*/} from ${from%%/*}/."
497 delete_exit_trap "download"
499 fatal 1 "${to##*/} not found in directory ${to%/*}."
508 local force="${1:-false}"
510 local location="http://downloads.lustre.org/public/OFED/"
513 if [[ $OFED_VERSION = daily-* ]]; then
514 OFED_VERSION=${OFED_VERSION/daily-/}
515 Mmv=${OFED_VERSION%%-*}
516 daily=${OFED_VERSION##$Mmv-}
517 location="http://www.openfabrics.org/downloads/OFED/ofed-${Mmv}-daily/"
518 # find the filename for the version for the date specified
519 OFED_VERSION=$(curl -s "$location" | sed -nre "/${daily}-/s/.*href=\"OFED-(${Mmv//./\\.}-${daily}-[0-9]{4,4}).tgz.*$/\1/p" | tail -1)
520 if [ -z "$OFED_VERSION" ]; then
521 fatal 1 "Could not determine the filename of the OFED snapshot for ${daily}"
525 if [ -z "$OFED_VERSION" -o "$OFED_VERSION" = "inkernel" ]; then
529 local file="OFED-${OFED_VERSION}.tgz"
530 download_file "$location/$file" "$KERNELTREE" "$force"
535 local force="${1:-false}"
537 local location="http://downloads.lustre.org/public/RDAC/"
539 if [ -z "$RDAC_VERSION" -o "$RDAC_VERSION" = "inkernel" ]; then
543 local file="rdac-LINUX-${RDAC_VERSION}-source.tar.gz"
544 download_file "$location/$file" "$KERNELTREE" "$force"
548 download_mptlinux() {
549 local force="${1:-false}"
551 local location="http://downloads.lustre.org/public/MPTLINUX/"
553 if [ -z "$MPTLINUX_VERSION" -o "$MPTLINUX_VERSION" = "inkernel" ]; then
557 file="MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip"
558 download_file "$location/$file" "$KERNELTREE" "$force"
564 EXTRA_VERSION_save="$EXTRA_VERSION"
565 for patchesdir in "$EXTERNAL_PATCHES" \
566 "$TOPDIR/lustre/lustre/kernel_patches"; do
567 TARGET_FILE="$patchesdir/targets/$TARGET.target"
568 [ -r "$TARGET_FILE" ] && break
570 [ -r "$TARGET_FILE" ] || fatal 1 "Target $TARGET was not found."
572 echo "Loading target config file $TARGET.target..."
574 # if the caller specified an OFED_VERSION it should override whatever
575 # the target file specifies
576 local env_OFED_VERSION="$OFED_VERSION"
580 if [ -n "$env_OFED_VERSION" ]; then
581 OFED_VERSION="$env_OFED_VERSION"
584 # doesn't make any sense to build OFED for xen domX's
589 # XXX - set_rpm_smp_type is an ugly undeterministic hack. it needs to
590 # go away and the target just specify the $RPMSMPTYPE
591 [ -z "$RPMSMPTYPE" ] && set_rpm_smp_type
593 # CC might have been overwriten in TARGET_FILE
594 if [[ $CC != ccache\ * ]] && which "$CCACHE" &>/dev/null; then
595 export CCACHE && export CC="ccache $CC"
598 if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then
599 KERNELDIR="$KERNELTREE/${lnxmaj}"
600 [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR"
603 # verify the series is available
604 if [ "$SERIES" ]; then
605 for series in $SERIES; do
606 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
607 [ -r "$patchesdir/series/$series" ] && continue 2
609 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."
613 # set the location of the .config file
619 if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
620 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH${RPMSMPTYPE:+-}${RPMSMPTYPE}.config"
623 local lnxrelnew=${lnxrel//-/_}
625 # remember the EXTRA_VERSION before we diddle it here
626 # XXX - we really should not diddle with any values read in from the
627 # target file. if we want to modify a value, we should create
629 PRISTINE_EXTRA_VERSION=$EXTRA_VERSION
631 if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then
632 fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
635 if [ "$EXTRA_VERSION_save" ]; then
636 EXTRA_VERSION="$EXTRA_VERSION_save"
637 elif ! $RELEASE; then
638 # if there is no patch series, then this is not a lustre specific
639 # kernel. don't make it look like one
640 if [ -n "$SERIES" ]; then
641 #remove the @VERSION@ (lustre version)
642 # EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
643 # EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
644 ! ( $PATCHLESS ) && EXTRA_VERSION="${EXTRA_VERSION}.${TIMESTAMP}"
647 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
649 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
652 for arch in $(uniqify "$ALL_ARCHS"); do
653 if [ -z "$TARGET_ARCHS" ] ||
654 [[ \ $TARGET_ARCHS\ = *\ $arch\ * ]]; then
655 BUILD_ARCHS="$BUILD_ARCHS $arch"
658 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
659 echo "Building for: $BUILD_ARCHS"
667 fatal 1 "tarflags(): File name argument missing."
679 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
688 echo "Untarring ${file##*/}..."
689 tar $(tarflags "$file") "$file"
695 if ! untar "$KERNELTREE/OFED-${OFED_VERSION}.tgz"; then
698 [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED
704 if ! untar "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz"; then
707 [ -d rdac-LINUX ] || ln -sf rdac-LINUX-[0-9][0-9].* rdac-LINUX
713 if ! unzip -p $KERNELTREE/MPTLINUX_RHEL5_SLES10_PH15-4.16.00.00-2.zip | tar xzvf - srpms-2/mptlinux-4.16.00.00-2.src.rpm; then
716 mv srpms-2/mptlinux-4.16.00.00-2.src.rpm .
722 if [ -z "$LUSTRE" ]; then
725 if [ -n "$USE_DATESTAMP" ]; then
726 DATESTAMP="-D '$DATE'"
729 local DIRNAME="lustre-$TAG-$TIMESTAMP"
731 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
732 fatal 1 "There was an error checking out toplevel Lustre from CVS."
733 pushd "$DIRNAME" > /dev/null
734 ./lustrecvs "$TAG" || \
735 fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."
736 echo "Creating lustre tarball..."
737 sh autogen.sh || fatal 1 "There was an error running autogen.sh."
738 ./configure --disable-{modules,utils,liblustre,tests,doc} || \
739 fatal 1 "There was an error running ./configure to create makefiles."
740 make dist || fatal 1 "There was an error running 'make dist'."
741 LUSTRE=$PWD/lustre-*.tar.gz
745 untar "$LUSTRE" || fatal 1 "Error unpacking Lustre tarball"
746 [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
752 local do_patch=${1:-true}
754 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
755 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
756 $do_patch && pushd linux >/dev/null
757 for series in $SERIES; do
758 echo -n "Applying series $series:"
759 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
760 [ -r "$patchesdir/series/$series" ] || continue
761 SERIES_FILE="$patchesdir/series/$series"
762 for patch in $(<"$SERIES_FILE"); do
764 PATCH_FILE="$patchesdir/patches/$patch"
765 [ -r "$PATCH_FILE" ] || \
766 fatal 1 "Patch $patch does not exist in Lustre tree."
767 cat "$PATCH_FILE" >> "$FULL_PATCH" || {
769 fatal 1 "Error adding patch $patch to full patch."
772 patch -s -p1 < "$PATCH_FILE" 2>&1 || {
774 fatal 1 "Error applying patch $patch."
782 $do_patch && popd >/dev/null
783 echo "Full patch has been saved in ${FULL_PATCH##*/}."
793 pushd lustre >/dev/null
795 echo "Building Lustre RPMs for: $BUILD_ARCHS..."
797 for arch in $BUILD_ARCHS; do
798 targets="--target $arch $targets"
801 local confoptions="--with-linux=${linux}"
803 confoptions="--with-linux=${linux} --disable-server"
805 if [ "$linuxobj" != "" ]; then
806 confoptions="$confoptions --with-linux-obj=${linuxobj}"
809 ./configure $confoptions ${CONFIGURE_FLAGS} 2>&1
810 if [ "$?" != "0" ]; then
811 local saved_config="../config.log.$(date +%s)"
812 cp config.log $saved_config
813 chmod a+r $saved_config
814 echo "Saved config.log is at $saved_config"
818 echo "config.log contents:"
826 # hack. Somebody move build/lustre.spec to lustre.spec for b1_6
828 [ -f lustre.spec ] && lustre_spec=lustre.spec
829 [ -f build/lustre.spec ] && lustre_spec=build/lustre.spec
831 [ -f "$lustre_spec" ] && sed \
832 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
836 local rpmbuildopt='-bb'
839 echo NORPM mode. Only compiling.
842 # convert the $PATCHLESS boolean to an empty/not-empty boolean
843 # as silly as this seems, it makes the syntax of the rpmbuild command
844 # simpler and not need an eval to deal with the quotes in the quotes
845 local is_patchless=""
850 # ditto for the lustre-tests boolean
851 local lustre_tests=""
852 if ! $LUSTRE_TESTS; then
856 $RPMBUILD $targets $rpmbuildopt ../lustre.spec \
857 ${is_patchless:+--define "lustre_name lustre-client"} \
858 ${lustre_tests:+--define "build_lustre_tests 0"} \
859 --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \
860 --define "_tmppath $TMPDIR" \
861 --define "_topdir $TOPDIR" 2>&1 || \
862 fatal 1 "Error building rpms for $BUILD_ARCHS."
865 ( $(skeep_ldiskfs_rpm $TAG) ) && return
867 pushd lustre/ldiskfs || return 255
869 if [ "$?" != "0" ]; then
873 cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
877 local ldiskfs_spec=lustre-ldiskfs.spec
878 [ -f "$ldiskfs_spec" ] && sed \
879 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
881 > ../lustre-ldiskfs.spec
883 if ! $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
884 --define "_tmppath /var/tmp" \
885 --define "_topdir $TOPDIR" 2>&1; then
891 if ! $RPMBUILD -bs ../lustre-ldiskfs.spec \
892 --define "_tmppath /var/tmp" \
893 --define "_topdir $TOPDIR" 2>&1; then
904 [ "$STAGEDIR" ] || return 0
906 for arch in $BUILD_ARCHS; do
907 rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
908 echo "${0##*/}: Copying RPMs into ${rpmdir}"
910 cp -v RPMS/${arch}/*.rpm "${rpmdir}"
911 if [ -d RPMS/noarch ]; then
912 cp -v RPMS/noarch/*.rpm "${rpmdir}"
916 cp -v "$LUSTRE" "$STAGEDIR"
920 #check if we need to build separate ldiskfs RPM
921 skeep_ldiskfs_rpm() {
926 if ! $LDISKFSRPM; then
928 elif $PATCHLESS; then
931 for skiptag in $SKIPLDISKFSRPM; do
932 [[ $tag == $skiptag ]] && skip=true && break
936 pushd $TOPDIR/BUILD/lustre-[1-9]* >/dev/null
937 grep -q '^SERVER_TRUE[ \t]=[ \t]#$' autoMakefile && skip=true
944 #generate LUSTRE_EXTRA_VERSION from EXTRA_VERSION
945 gen_lustre_version() {
947 LUSTRE_EXTRA_VERSION="${lnxmaj}-${EXTRA_VERSION}${FLAVOR_DELIMITER}${RPMSMPTYPE}"
948 LUSTRE_EXTRA_VERSION=${LUSTRE_EXTRA_VERSION//-/_}
954 local infact_arch="${TARGET_ARCH}"
957 [ "$infact_arch" == "i586" ] && infact_arch="i686"
960 for smp_type in $SMP_ARCHS; do
961 [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break
964 for smp_type in $BIGSMP_ARCHS; do
965 [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break
968 for smp_type in $DEFAULT_ARCHS; do
969 [ $infact_arch == $smp_type ] && RPMSMPTYPE=default && break
974 # This function takes a linux source pool and digs out the linux release
976 find_linux_release() {
979 local LINUXRELEASEHEADER=$SRCDIR/include/linux/version.h
980 if [ -s $SRCDIR/include/linux/utsrelease.h ]; then
981 LINUXRELEASEHEADER=$SRCDIR/include/linux/utsrelease.h
984 sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER
988 # XXX this needs to be re-written as a wrapper around find_rpm
989 # or just gotten rid of. :-)
993 local pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
994 [ -d $pathtorpms ] || return 255
996 local kernelbinaryrpm rpmfile
997 local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}"
1000 for arch in $TARGET_ARCHS_ALL; do
1001 local found_rpm="" rpm
1002 for rpm in ${pathtorpms}/${arch}/*.rpm; do
1003 if rpm -q --provides -p "$rpm" 2>&3 | grep -q "kernel${prefix} = $wanted_kernel" 2>&3; then
1010 [ -f "$found_rpm" ] && break
1018 # unpack kernel(/source/devel) RPM
1020 # This function and it's setting of $LINUX and $LINUXOBJ is a total hack that
1021 # needs to completely refactored. It completely ingores that $BUILD_ARCHS may
1022 # contain a list of arches for which rpmbuild commands (including the one for
1024 unpack_linux_devel_rpm() {
1025 local kernelrpm="${1}"
1027 [ -f "$kernelrpm" ] || return 255
1028 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused || return 255
1030 pushd $TOPDIR/reused &>/dev/null || return 255
1032 if ! rpm2cpio < "$kernelrpm" | cpio -id > /dev/null 2>&1; then
1036 # call a distro specific hook, if available
1037 if type -p unpack_linux_devel_rpm-$DISTRO; then
1038 unpack_linux_devel_rpm-$DISTRO "$kernelrpm"
1043 find_linux_devel_paths $TOPDIR/reused
1052 # build kernel-ib{,-devel}
1054 # ofed 1.3 had a bug in the rpm spec
1055 if [ "$OFED_VERSION" = "1.3" ]; then
1059 local OFED_CORE="--with-core-mod --with-ipoib-mod --with-sdp-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-rds-mod --with-qlgc_vnic-mod --with-madeye-mod"
1060 local OFED_HARDWARE="--with-mthca-mod --with-mlx4-mod --with-mlx4_en-mod --with-cxgb3-mod --with-nes-mod"
1061 # some I/B drivers are architecture dependent and kernel-ib's configure
1062 # does not figure it out for us ~sigh~
1063 case "$TARGET_ARCH" in
1065 OFED_HARDWARE="$OFED_HARDWARE --with-ehca-mod"
1068 # we're no longer shipping the OFED iSCSI
1069 #OFED_ISCSI="--with-srp-mod --with-srp-target-mod"
1070 ## ISER module has no backport support as of OFED 1.5 (i.e. only builds on
1071 ##kernels >= 2.6.30)
1072 #if [[ $OFED_VERSION = 1.[0-4]* ]]; then
1073 # OFED_ISCSI="$OFED_ISCSI --with-iser-mod"
1076 # assume we are just rebuilding the SRPM
1077 local BUILD_TYPE=${BUILD_TYPE:-"--rebuild"}
1078 local SOURCE="${TOPDIR}/OFED/SRPMS/ofa_kernel-*.src.rpm"
1080 # but switch to building from the SPEC if we need to apply patches
1081 if ls ${TOPDIR}/lustre/build/patches/ofed/* >/dev/null; then
1083 rpm --define "_topdir ${TOPDIR}" -ivh $SOURCE
1084 SOURCE="${TOPDIR}/SPECS/ofa_kernel.spec"
1085 local file ed_fragment1 ed_fragment2 n=1
1086 for file in ${TOPDIR}/lustre/build/patches/ofed/*; do
1087 ed_fragment1="$ed_fragment1
1088 Patch$n: ${file%%*/}"
1089 ed_fragment2="$ed_fragment2
1091 cp $file ${TOPDIR}/SOURCES
1106 local linuxrelease=$(find_linux_release "$linux")
1107 if ! $RPMBUILD $BUILD_TYPE --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
1108 --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
1109 --define "KVERSION ${linuxrelease}" \
1110 --define "$K_SRC ${linux}" \
1111 --define "LIB_MOD_DIR /lib/modules/${linuxrelease}/updates" \
1112 ${OFA_KERNEL_RELEASE:+--define "_release $OFA_KERNEL_RELEASE"} \
1113 --define "configure_options --without-quilt $OFED_CORE $OFED_HARDWARE $OFED_ISCSI" \
1114 ${SOURCE} 2>&1; then
1115 fatal 1 "Error building kernel-ib"
1124 local signature="$4"
1125 local use_links="$5"
1132 location="$location"/"$signature"/"$module"
1133 mkdir -p "$location"
1134 # the cleanup script removes any directory that doesn't have a
1135 # .lastused, so let's try to prevent that as soon as we can
1136 # this solution still slightly racy with the cleanup script
1137 # but the race is a lot tighter now
1138 touch -t 197001010000 "$location/.lastused"
1139 ## use eval/echo here to make sure shell expansions are performed
1140 #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then
1142 for article in $(eval echo $articles); do
1143 if ! cp -a${linkflag} "$article" "$location"; then
1144 error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()"
1145 # rename the cache location so that it's not cached
1146 # product, but is around for analysis
1147 mv "$location"{,-bad-$(date +%s)} ||
1148 error "failed to clean up a failed cache attempt" \
1149 "in \"$location\" -- manual cleanup will be" \
1155 # flag the cache as complete (i.e. in case lbuild was previously
1156 # interrupted while caching)
1157 touch "$location/.lastused"
1166 local use_links="${3:-false}"
1167 local signature="$4"
1169 if [ -n "$REUSEBUILD" ] && [ -d "$REUSEBUILD/$signature/$module" ]; then
1170 if [ ! -f "$REUSEBUILD/$signature/$module/.lastused" ]; then
1171 # the .lastused flag is populated at the end of the caching to
1172 # signal that the caching was completed. if that flag is not
1173 # there, then the cache is invalid (and should be removed in fact)
1174 mv "$REUSEBUILD/$signature/$module"{,-bad-$(date +%s)} ||
1175 fatal 1 "failed to clean up a bad cache in location $REUSEBUILD/$signature/$module\" -- manual cleanup will be necessary"
1179 # so that we know how stale this entry is
1180 touch $REUSEBUILD/$signature/$module/.lastused
1183 if ls $REUSEBUILD/$signature/$module/* >/dev/null 2>&1; then
1184 cp -al $REUSEBUILD/$signature/$module/* $dest/
1187 # copying is pretty heavy
1188 # cp -a $REUSEBUILD/$signature/$module/* $dest/
1189 # do some creative symlinking instead
1191 for dir in BUILD SRPMS SPECS; do
1192 if ls $REUSEBUILD/$signature/$module/$dir/* >/dev/null 2>&1; then
1193 ln -s $REUSEBUILD/$signature/$module/$dir/* $dest/$dir
1196 # sources have to be copied by file because we need SOURCES to
1197 # be a dir we can write into
1198 # could overrun ls's arg list here
1199 #ls $REUSEBUILD/$signature/$module/SOURCES/* |
1200 find $REUSEBUILD/$signature/$module/SOURCES/ -type f |
1201 xargs ln -t $dest/SOURCES -s
1203 # same for RPMS/* dirs
1204 # could overrun ls's arg list here
1205 #ls $REUSEBUILD/$signature/$module/RPMS/$TARGET_ARCH/* |
1207 for dir in $REUSEBUILD/$signature/$module/RPMS/*; do
1208 mkdir -p $dest/RPMS/${dir##*/}
1210 xargs ln -t $dest/RPMS/${dir##*/} -s
1223 if [[ $arch = i[3456]86 ]]; then
1232 # in a given directory, find the first rpm matching given requirements
1236 local match_type="$2"
1239 pushd "$dir" > /dev/null || \
1240 fatal 1 "Unable to chdir to directory \"$dir\" in find_rpm()"
1243 for file in $(ls *.rpm); do
1244 if [ ! -f "$file" ]; then
1247 case "$match_type" in
1249 # match is any valid ERE (i.e. given to egrep) match
1250 if rpm -q --provides -p "$file" 2>&3 | egrep -q "$match"; then
1258 fatal 1 "Unknown match type \"$match_type\" given to find_rpm()"
1267 build_kernel_with_srpm() {
1270 if [ -z "$outfd" ] || [ $outfd = 1 ]; then
1271 fatal 1 "You must supply a file descriptor to ${FUNCNAME[0]} and it cannot be 1"
1274 # need to generate the patch for this target
1275 do_patch_linux false >&${outfd} # sets global $FULL_PATCH (yeah, yuck)
1277 # get an md5sum of the kernel patch + config for reuse check
1278 # XXX really, there needs to be a signature and a CONFIG_FILE per arch
1282 local release_str="RELEASE=$RELEASE\n"
1285 if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then
1286 local REUSE_SIGNATURE=$({ echo -en $release_str;
1288 cat $CONFIG_FILE $TARGET_FILE $FULL_PATCH; } |
1289 md5sum | cut -d" " -f1)
1290 # see if we can link to the reuse pool
1291 # XXX - hrm. i'm not convinced this doesn't belong in the reuse
1293 local CAN_LINK_FOR_REUSE=false
1294 touch $REUSEBUILD/$$
1295 if cp -al $REUSEBUILD/$$ $TOPDIR/ 2>/dev/null; then
1296 CAN_LINK_FOR_REUSE=true
1301 # the extra version string to use for the kernel (which might be a reused
1303 local kernel_extra_version=""
1304 if ! $USE_BUILD_CACHE || ! reuse kernel "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
1305 "$REUSE_SIGNATURE"; then
1306 # nothing cached, build from scratch
1307 if [ ! -r "$KERNELDIR/$KERNEL_SRPM" ]; then
1308 echo "Downloading kernel SRPM"
1309 download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&${outfd}
1312 if ! rpm -ivh $KERNELDIR/$KERNEL_SRPM \
1313 --define "_topdir $TOPDIR" >&${outfd} 2>&1; then
1314 # should we clean this up or leave it for analysis?
1316 fatal 1 "Error installing kernel SRPM."
1319 # put the Lustre kernel patch into the RPM build tree
1320 cp $FULL_PATCH $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch
1321 prepare_and_build_srpm >&${outfd} ||
1322 fatal 1 "failed to prepare_and_build_srpm"
1324 if [ -z "$REUSE_SIGNATURE" ]; then
1325 echo "No reuse signature was caculated so not storing the built kernel" >&${outfd}
1327 # store the resulting kernel RPM build tree for future use
1328 echo "Storing the built kernel for future reuse" >&${outfd}
1329 if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
1330 "kernel" "$REUSEBUILD" "$REUSE_SIGNATURE" \
1331 "$CAN_LINK_FOR_REUSE"; then
1332 error "Failed to store kernel RPMS for reuse"
1339 # figure out the EXTRA_VERSION of the kernel we built or are re-using
1341 if ! KERNEL_RPM=$(find_rpm "$TOPDIR/RPMS/$TARGET_ARCH/" provides "^kernel ="); then
1342 fatal 1 "Failed to find a kernel RPM in $TOPDIR/RPMS/$TARGET_ARCH/"
1344 kernel_extra_version=$(rpm -q --queryformat "%{RELEASE}" -p $TOPDIR/RPMS/$TARGET_ARCH/$KERNEL_RPM)
1346 # should now have the following RPMs
1347 # $TOPDIR/RPMS/$arch/kernel-lustre-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1348 # $TOPDIR/RPMS/$arch/kernel-lustre-devel-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1349 # $TOPDIR/RPMS/$arch/kernel-lustre-headers-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1350 # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-common-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1351 # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1353 echo $kernel_extra_version
1362 if [ -z "$version" -o "$version" = "inkernel" ]; then
1367 for arch in $BUILD_ARCHS; do
1368 targets="--target $arch $targets"
1371 local rpmbuildopt='-bb'
1374 echo NORPM mode. Only compiling.
1377 # if only we could just rebuild the src.rpm. but the included spec
1378 # is a real pig's breakfast. just check out the patch we need to
1379 # apply to it to make it useful.
1380 #$RPMBUILD --rebuild \
1381 # --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
1382 # ${TOPDIR}/mptlinux-*.src.rpm
1383 rpm -ivh --define "_topdir ${TOPDIR}" ${TOPDIR}/mptlinux-*.src.rpm
1385 # now the big honkin' patch to the spec file
1386 pushd ${TOPDIR}/SPECS
1387 # to regen this patch use:
1388 # !!cd ~/rpm/SPECS/ && diff -u mptlinux.spec{.dist,}
1389 patch -p0 < ${TOPDIR}/lustre/build/mptlinux.spec.patch || fatal 1 "failed to patch mptlinux.spec"
1393 for arch in $BUILD_ARCHS; do
1394 targets="--target $arch $targets"
1397 local rpmbuildopt='-bb'
1400 echo NORPM mode. Only compiling.
1403 if ! $RPMBUILD $targets $rpmbuildopt \
1404 --define "_tmppath /var/tmp" \
1405 --define "_topdir ${TOPDIR}" \
1406 --define "kernel_obj $linux" \
1407 ${TOPDIR}/SPECS/mptlinux.spec 2>&1; then
1411 if ! $RPMBUILD -bs \
1412 --define "_tmppath /var/tmp" \
1413 --define "_topdir ${TOPDIR}" \
1414 --define "kernel_obj $linux" \
1415 ${TOPDIR}/SPECS/mptlinux.spec 2>&1; then
1429 if [ -z "$version" -o "$version" = "inkernel" ]; then
1433 # note that we use an _, not a . before the spec on purpose. we are not
1434 # allowed to have more than one file with a .spec trailer in a tarball
1435 # that is supposed to be usable with rpmbuild
1436 cp lustre/build/rdac_spec ${TOPDIR}/SPECS/rdac.spec || fatal 1 "Could not find rdac.spec in lustre/build"
1439 for arch in $BUILD_ARCHS; do
1440 targets="--target $arch $targets"
1443 local rpmbuildopt='-bb'
1446 echo NORPM mode. Only compiling.
1451 rhel5) distro="REDHAT"
1453 sles1*) distro="SUSE"
1455 *) echo "$DISTRO not supported by RDAC, skipping"
1459 if ! $RPMBUILD $targets $rpmbuildopt --define "dist $distro" \
1460 --define "_tmppath /var/tmp" \
1461 --define "_topdir ${TOPDIR}" \
1462 --define "kernel_obj $linux" \
1463 ${TOPDIR}/SPECS/rdac.spec 2>&1; then
1467 if ! $RPMBUILD -bs --define "dist $distro" \
1468 --define "_tmppath /var/tmp" \
1469 --define "_topdir ${TOPDIR}" \
1470 --define "kernel_obj $linux" \
1471 ${TOPDIR}/SPECS/rdac.spec 2>&1; then
1482 # REUSEBUILD, USE_BUILD_CACHE
1487 local ofed_version="$2"
1489 # before lustre, build kernel-ib
1490 if [ -z "$ofed_version" -o "$ofed_version" = "inkernel" ]; then
1494 if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then
1495 local REUSE_SIGNATURE=$({ echo "$ofed_version";
1496 echo "$(find_linux_release ${linux})";
1497 cat "${linux}/include/linux/autoconf.h"; } |
1498 md5sum | cut -d" " -f1)
1499 # see if we can link to the reuse pool
1500 # XXX - hrm. i'm not convinced this doesn't belong in the reuse
1502 local CAN_LINK_FOR_REUSE=false
1503 touch $REUSEBUILD/$$
1504 if cp -al $REUSEBUILD/$$ $TOPDIR/; then
1505 CAN_LINK_FOR_REUSE=true
1510 if ! $USE_BUILD_CACHE || ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
1511 "$REUSE_SIGNATURE"; then
1512 if [ -n "$REUSE_SIGNATURE" ]; then
1513 # stash away the existing built articles for a moment
1515 mv {BUILD,{S,}RPMS,S{OURCE,PEC}S} bak
1518 find . | cpio -pudlm ..
1522 create_rpmbuild_dirs
1525 build_kernel_ib "${linux}"
1527 if [ -z "$REUSE_SIGNATURE" ]; then
1528 echo "No reuse signature was caculated so not storing the built ofed"
1530 # store the resulting RPM build tree for future use
1531 echo "Storing the built ofed for future reuse"
1532 if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
1533 "ofed" "$REUSEBUILD" "$REUSE_SIGNATURE" \
1534 "$CAN_LINK_FOR_REUSE"; then
1535 error "Failed to store OFED RPMS for reuse"
1539 # put the stuff we stashed away back
1544 pushd "$TOPDIR" >/dev/null
1545 rm -rf kernel-ib-devel
1546 mkdir kernel-ib-devel
1548 # the actual ofed RPMs don't have the -rc$n or -$date string appened that
1549 # might be present on the file
1550 local linuxrelease=$(find_linux_release "$linux")
1551 ofed_version=$(echo $ofed_version |
1552 sed -re 's/-(20[0-9]{6,6}-[0-9]{4,4}|rc[0-9]*)$//')
1553 local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${ofed_version}-${linuxrelease//-/_}.*.rpm)
1554 rpm2cpio -itv < $rpm | cpio -id
1555 CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
1562 if ! $PATCHLESS; then
1563 local kernel_extra_version
1564 if ! kernel_extra_version=$(build_kernel_with_srpm ${STDOUT}); then
1565 fatal 1 "Failed to build the kernel from it's SRPM"
1568 for arch in $BUILD_ARCHS; do
1569 local kernel_devel_rpm
1570 if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name $KERNEL_LUSTRE_NAMING) ="); then
1571 fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/"
1574 # install the -devel RPM in preparation for the lustre build
1575 if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \
1576 "$TOPDIR/RPMS/$arch/$kernel_devel_rpm"; then
1577 fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm"
1581 # need to find and unpack the vendor's own kernel-devel for patchless
1584 if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE"); then
1585 fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in ${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
1587 if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then
1588 fatal 1 "Could not find the Linux tree in $kernelrpm"
1592 build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" ||
1593 fatal 1 "error building OFED"
1595 if ! $PATCHLESS; then
1596 # only need RDAC for the server
1597 build_rdac "${LINUXOBJ:-$LINUX}" "$RDAC_VERSION" ||
1598 fatal 1 "error building RDAC"
1601 build_mptlinux "${LINUXOBJ:-$LINUX}" "$MPTLINUX_VERSION" ||
1602 fatal 1 "error building mptlinux"
1605 if build_lustre "$LINUX" "$LINUXOBJ"; then
1606 # the build worked. resolve any symlinked files (i.e. from reuse)
1607 # in RPMS/$arch to real files so that that that huge mess of
1608 # complication known as LTS can copy them yet somewhere else.
1609 # is it any wonder this whole process is so damn so? anyone ever
1610 # heard of hardlinks? it this cool new thing that allows you save
1611 # tons of time and space by creating... well you can go read about
1612 # them if you have not heard about them yet.
1613 # can i say how much the implemenation of all of this really impedes
1615 pushd RPMS/$TARGET_ARCH
1617 if [ -h $file ]; then
1629 create_rpmbuild_dirs() {
1631 [ -d RPMS ] || mkdir RPMS
1632 for arch in $BUILD_ARCHS; do
1633 if [[ $arch = i?86 ]]; then
1634 # some stupidity in the sles11 kernel spec requires an RPMS/i386
1635 # even if the target arch is i686
1636 [ -d RPMS/i386 ] || mkdir RPMS/i386
1638 [ -d RPMS/$arch ] || mkdir RPMS/$arch
1640 [ -d BUILD ] || mkdir BUILD
1641 [ -d SOURCES ] || mkdir SOURCES
1642 [ -d SPECS ] || mkdir SPECS
1643 [ -d SRPMS ] || mkdir SRPMS
1665 [[ $list\ == *\ $item\ * ]]
1669 #########################################################################
1670 # Generate a backtrace through the call stack.
1674 #########################################################################
1678 local funcname="" sourcefile="" lineno="" n
1680 echo "Call stack: (most recent first)"
1681 for (( n = $strip ; n < ${#FUNCNAME[@]} ; ++n )) ; do
1682 funcname=${FUNCNAME[$n - 1]}
1683 sourcefile=$(basename ${BASH_SOURCE[$n]})
1684 lineno=${BASH_LINENO[$n - 1]}
1688 # Display function arguments
1689 if [[ ! -z "${BASH_ARGV[@]}" ]]; then
1690 local args newarg j p=0
1691 for (( j = ${BASH_ARGC[$n - 1]}; j > 0; j-- )); do
1692 newarg=${BASH_ARGV[$j + $p - 1]}
1693 args="${args:+${args} }'${newarg}'"
1695 let p+=${BASH_ARGC[$n - 1]}
1697 echo " ${funcname} ${args:+${args} }at ${sourcefile}:${lineno}"
1701 echo "BEGIN BACKTRACE"
1703 #echo ${BASH_LINENO[*]}
1704 #echo ${BASH_SOURCE[*]}
1705 #echo ${FUNCNAME[*]}
1706 local i=$((${#FUNCNAME[@]} - 1))
1707 while [ $i -ge 0 ]; do
1708 local lineno=${BASH_LINENO[$i]}
1712 local SOURCELINE="${BASH_SOURCE[$i + 1]}:${lineno}"
1713 # Can't figure out how to get function args from other frames...
1714 local FUNCTION="${FUNCNAME[$i]}()"
1715 echo "$SOURCELINE:$FUNCTION"
1719 echo "END BACKTRACE"
1725 seen_list=$(new_list)
1727 echo "An unexpected error has occurred at ${BASH_SOURCE[0]##*/}:$((LINENO-1)).
1728 Unfortunately the above line number in the message may or may not be correct,
1729 but details have been send to the lbuild maintainer. Attempting to continue."; (echo "Untrapped error"
1731 # have we seen this one
1732 echo "checking seen list for ${BASH_SOURCE[0]}:${BASH_LINENO[0]}"
1734 if is_list_member "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}"; then
1735 echo "seen this one already"
1737 seen_list=$(add_list "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}")
1743 ) | mail -s "Untrapped error at ${BASH_SOURCE[0]##*/}:$((LINENO-15)) on $HOSTNAME" brian@sun.com >&2; set $xtrace' ERR
1746 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
1748 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,ofed-version:,publish,release,set-value:,src,stage:,tag:,target:,target-archs:,with-linux:,xen -- "$@")
1750 if [ $? != 0 ]; then
1754 eval set -- "$options"
1789 if ! KERNELTREE=$(canon_path "$2"); then
1790 fatal 1 "Could not determine the canonical location of $2"
1794 --linux | --with-linux)
1795 if ! LINUX=$(canon_path "$2"); then
1796 fatal 1 "Could not determine the canonical location of $2"
1809 if ! REUSEBUILD=$(canon_path "$2"); then
1810 fatal 1 "Could not determine the canonical location of $2"
1827 if ! KERNELRPMSBASE=$(canon_path "$2"); then
1828 fatal 1 "Could not determine the canonical location of $2"
1879 --disable-datestamp)
1893 # there are actually some lustre configure flags that we need to
1894 # handle ourselves (but we still give them to configure)
1895 if [[ \ $@\ == *\ --disable-tests\ * ]]; then
1899 CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests"
1903 usage 1 "Unrecognized option: $1"
1914 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1916 unpack_ofed || fatal 1 "Error unpacking OFED tarball"
1919 if [ -n "$MPTLINUX_VERSION" -a "$MPTLINUX_VERSION" != "inkernel" ]; then
1921 unpack_mptlinux || fatal 1 "Error unpacking MPTLINUX distribution"
1924 # make sure the RPM build environment is set up
1925 create_rpmbuild_dirs
1927 if [ -n "$RDAC_VERSION" -a "$RDAC_VERSION" != "inkernel" ]; then
1929 # we don't actually need to unpack this. just put it in the SOURCES dir
1930 #unpack_rdac || fatal 1 "Error unpacking RDAC tarball"
1931 cp "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz" ${TOPDIR}/SOURCES/ ||
1932 fatal 1 "Error copying RDAC source tarball to RPM SOURCES dir"
1935 # if an unpacked kernel source tree was given on the command line
1936 # just build lustre with it (nothing distro kernel specific here)
1937 if [ -n "$LINUX" ]; then
1938 build_mptlinux "${LINUXOBJ:-$LINUX}" "$MPTLINUX_VERSION" ||
1939 fatal 1 "error building mptlinux"
1940 build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" ||
1941 fatal 1 "error building OFED"
1942 if ! $PATCHLESS; then
1943 build_rdac "${LINUXOBJ:-$LINUX}" "$RDAC_VERSION" ||
1944 fatal 1 "error building RDAC"
1946 build_lustre "$LINUX" "$LINUXOBJ"
1948 if [ -f "${0%/*}/lbuild-$DISTRO" ]; then
1949 source ${0%/*}/lbuild-$DISTRO
1951 build_with_srpm || fatal 1 "Failed to build_with_srpm"
1953 EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
1954 source ${0%/*}/lbuild.old_school
1956 old_school_download_kernel
1960 patchless_build_sequence && build_success=true
1962 [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
1963 if ! $build_success; then
1964 build_sequence_reuse && build_success=true
1965 if ! $build_success; then
1966 build_sequence && build_success=true
1967 if $build_success; then
1968 store_for_reuse || echo "Cannot store for future reuse"
1973 ( $build_success ) || fatal 1 "Cannot build lustre"