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 # XXX - i think these two parameters/arguments/variables need to be
52 # cleaned up and merged. they effectively do the same thing
55 # what does this do exactly? does it imply no kernel build?
58 SKIPLDISKFSRPM="v1_4_* b1_4"
59 SMPTYPES="smp bigsmp default ''"
65 # default to not adding -lustre- into the kernel RPM package names
66 KERNEL_LUSTRE_NAMING=false
83 # not in the target file any more
95 # Readlink is not present on some older distributions: emulate it.
99 if [ -L "$path" ]; then
100 ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
115 [ -n "$msg" ] && echo -e "\n${0##*/}: $msg" >&3
129 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
132 Specifies the CVS Root to use when pulling files from CVS. The
133 environment variable \$CVSROOT is used if this option is not
136 --external-patches=EXTERNAL_PATCHES
137 Directory similar to lustre/lustre/kernel_patches/ that lbuild should
138 look for seres and config files in before looking in the lustre
141 --extraversion=EXTRAVERSION
142 Text to use for the rpm release and kernel extraversion.
144 --timestamp=TIMESTAMP
145 Date of building lustre in format YYYYMMDDhhmmss
148 Try to reuse old kernel RPMs from DIR
151 Try to reuse old kernel builds from DIR
154 Path to distro kernel RPM collection
160 Do not build RPMs (compile only mode)
163 Build lustre client only
166 Which distro using. Autodetect by default
168 --kerneldir=KERNELDIR
169 Directory containing Linux source tarballs referenced by target
172 --kerneltree=KERNELTREE
173 Directory containing dirs with Linux source tarballs referenced by target
174 files. Dir names in format kernel version ('2.6.9', etc.)
176 --linux=LINUX --with-linux=LINUX
177 Directory of Linux kernel sources. When this option is used, only
178 Lustre modules and userspace are built.
181 Path to an existing lustre source tarball to use instead of
185 Do not try to download a kernel from downloads.lustre.org
188 Do not build a .src.rpm, a full kernel patch, or a patched kernel
192 Do ldiskfs RPM. Now true by default
198 Specifies that the files generated do not include timestamps, and
199 that this is an official release.
202 Build a .src.rpm, a full kernel patch, and a patched kernel tarball.
205 Directory used to stage packages for release. RPMs will be placed
206 more or less in DIR/<target>-<arch>, and the tarball will be
210 A CVS branch/tag name to build from when pulling from CVS.
213 The name of the target to build. The available targets are listed
216 --target-archs=TARGET_ARCHS
217 A (space delimited) list of architectures to build. By default,
218 all of the archs supported by the TARGET will be built, in
219 addition to a .src.rpm. This option can limit those, for machines
220 that can only build certain archs or if you only want a certain
221 arch built (for testing, or a one-off kernel).
223 Also note that by using a non-"base" arch (eg, i386) only kernels
224 will be built - there will be no lustre-lite-utils package.
227 Prevents the datestamp flag (-D) from being passed to cvs for
228 checkouts. This is a workaround for a problem encountered when
229 using lbuild with tinderbox.
232 Builds a Xen domX kernel.
241 # canonicalize a relative path
245 if [ ! -d "$PATH" ]; then
249 pushd "$PATH" >/dev/null || return 1
259 if [ "$LUSTRE" ]; then
260 [ -r "$LUSTRE" ] || \
261 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
264 usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre."
266 usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
269 if [ -z "$LINUX" ]; then
270 [ "$KERNELDIR" -o "$KERNELTREE" ] || \
271 usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree."
273 [ -d "$KERNELDIR" -o -d "$KERNELTREE" ] || \
274 usage 1 "$KERNELDIR and $KERNELTREE are not a directory."
278 usage 1 "When building a snapshot, a tag name must be used."
281 [ "$TARGET" ] || usage 1 "A target must be specified with --target."
282 # TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
283 # [ -r "$TARGET_FILE" ] || \
284 # usage 1 "Target '$TARGET' was not found."
289 CANONICAL_TARGET="rhel5"
292 CANONICAL_TARGET="rhel-2.6"
295 CANONICAL_TARGET="sles-2.6"
298 CANONICAL_TARGET="sles10-2.6"
301 CANONICAL_TARGET="sles11"
304 CANONICAL_TARGET="oel5"
307 CANONICAL_TARGET="hp-pnnl-2.4"
315 CANONICAL_TARGET="$TARGET"
319 local timestampnodig=$(echo $TIMESTAMP | sed -e s/[0-9]*//g)
320 [ "$timestampnodig" = "" ] || TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
321 local timestamplength="${#TIMESTAMP}"
322 if [ $timestamplength -eq 12 ]; then
323 TIMESTAMP="${TIMESTAMP}00"
324 elif [ $timestamplength -ne 14 ]; then
325 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
328 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
329 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
330 RPMBUILD=$(which rpm 2>/dev/null | head -1)
331 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
332 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
336 if [ -n "$CCACHE" ]; then
337 which "$DISTCC" &>/dev/null && export DISTCC RPM_BUILD_NCPUS
339 if which "$CCACHE" &>/dev/null; then
340 local ccache=$(which "$CCACHE")
341 local bindir="$TOPDIR/bin"
343 if [ ! -d $bindir ]; then
344 mkdir -p $bindir || fatal 1 "error trying to create $bindir"
346 rm ${bindir}/* > /dev/null 2>&1 || true
348 ln -s "$ccache" ${bindir}/ccache
349 ln -s "$ccache" ${bindir}/cc
350 ln -s "$ccache" ${bindir}/$CC
351 export PATH=$bindir:$PATH
352 export CCACHE && export CC="ccache $CC"
353 # zero the cache so we can see how effective we are being with it
357 # get some ccache stats when we are done
358 push_exit_trap '[ -n "$CCACHE" ] && ccache -s' "ccache_summary"
359 # should remove the ccache trap if lbuild is interrupted
360 trap 'echo "Received an INT TERM or HUP signal, terminating."; delete_exit_trap "ccache_summary"; exit 1' INT TERM HUP
364 [ -z "$DISTRO" ] && DISTRO=$(autodetect_distro)
370 # autodetect used Distro
371 autodetect_distro() {
376 if [ -f /etc/SuSE-release ]; then
378 version=$(grep ^VERSION /etc/SuSE-release)
379 version=${version#*= }
380 elif [ -f /etc/redhat-release ]; then
381 name=$(head -1 /etc/redhat-release)
382 version=$(echo "$distroname" |
383 sed -e 's/^[^0-9.]*//g' | sed -e 's/[ \.].*//')
385 if [ -z "$name" -o -z "$version" ]; then
386 fatal 1 "I don't know how to determine distro type/version.\nEither update autodetect_distro() or use the --distro argument"
389 echo ${name}${version}
396 echo $(echo "$*" | xargs -n 1 | sort -u)
403 local force="${3:-false}"
405 if $force || [ ! -r "$KERNELDIR/$srpm" ] ||
406 [ ! -s "$KERNELDIR/$srpm" ]; then
408 local location="http://downloads.lustre.org/public/kernels/$target/old"
409 echo "Downloading $location/$srpm..."
410 if ! wget -nv "$location/$srpm" -O "$KERNELDIR/$srpm" 2>&1 ||
411 [ ! -s "$KERNELDIR/$srpm" ]; then
412 rm -f $KERNELDIR/$srpm
413 fatal 1 "Could not download target $target's kernel SRPM $srpm from $location."
416 fatal 1 "$srpm not found in directory $KERNELDIR."
427 local file=${from##*/}
433 local semaphore="$to-downloading"
436 if [ ! -f $semaphore ]; then
440 # make sure the download has not been aborted
441 local now=$(date +%s)
442 local file_mtime=$(stat -c %Y "$to")
443 local staleness=$((now - file_mtime))
444 # let's assume an active download will write at least once a minute
445 if [ $staleness -gt 60 ]; then
453 # if the semaphore file exists, the file is either still downloading
454 # or a download was aborted and we cannot trust the target file
455 if [ -f $semaphore ]; then
459 if ! is_downloading && [ -r "$to" ] && [ -s "$to" ]; then
466 if $force || ! is_downloaded; then
467 if is_downloading; then
468 echo "Somebody else is downloading $from..."
469 while is_downloading; do
470 echo "Waiting for $to to finish downloading"
473 if is_downloaded; then
476 echo "The download we were waiting for seems to have been aborted"
482 echo "Downloading $from..."
483 # flag others so they don't try to download also
484 push_exit_trap "rm -f $to $semaphore" "download"
486 if ! wget -nv "$from" -O "$to" || [ ! -s "$to" ]; then
487 # the trap will remove the files via the fatal below
488 fatal 1 "Could not download ${to##*/} from ${from%%/*}/."
491 delete_exit_trap "download"
493 fatal 1 "${to##*/} not found in directory ${to%/*}."
502 local force="${1:-false}"
504 local location="http://downloads.lustre.org/public/OFED/"
507 if [[ $OFED_VERSION = daily-* ]]; then
508 OFED_VERSION=${OFED_VERSION/daily-/}
509 Mmv=${OFED_VERSION%%-*}
510 daily=${OFED_VERSION##$Mmv-}
511 location="http://www.openfabrics.org/downloads/OFED/ofed-${Mmv}-daily/"
512 # find the filename for the version for the date specified
513 OFED_VERSION=$(curl -s "$location" | sed -nre "/${daily}-/s/.*href=\"OFED-([0-9]+\.[0-9]+-${daily}-[0-9]{4,4}).tgz.*$/\1/p" | tail -1)
514 if [ -z "$OFED_VERSION" ]; then
515 fatal 1 "Could not determine the filename of the OFED snapshot for ${daily}"
519 if [ -z "$OFED_VERSION" -o "$OFED_VERSION" = "inkernel" ]; then
523 local file="OFED-${OFED_VERSION}.tgz"
524 download_file "$location/$file" "$KERNELTREE" "$force"
529 local force="${1:-false}"
531 local location="http://downloads.lustre.org/public/RDAC/"
533 if [ -z "$RDAC_VERSION" -o "$RDAC_VERSION" = "inkernel" ]; then
537 local file="rdac-LINUX-${RDAC_VERSION}-source.tar.gz"
538 download_file "$location/$file" "$KERNELTREE" "$force"
542 download_mptlinux() {
543 local force="${1:-false}"
545 local location="http://downloads.lustre.org/public/MPTLINUX/"
547 if [ -z "$MPTLINUX_VERSION" -o "$MPTLINUX_VERSION" = "inkernel" ]; then
551 file="MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip"
552 download_file "$location/$file" "$KERNELTREE" "$force"
558 EXTRA_VERSION_save="$EXTRA_VERSION"
559 for patchesdir in "$EXTERNAL_PATCHES" \
560 "$TOPDIR/lustre/lustre/kernel_patches"; do
561 TARGET_FILE="$patchesdir/targets/$TARGET.target"
562 [ -r "$TARGET_FILE" ] && break
564 [ -r "$TARGET_FILE" ] || fatal 1 "Target $TARGET was not found."
566 echo "Loading target config file $TARGET.target..."
568 # if the caller specified an OFED_VERSION it should override whatever
569 # the target file specifies
570 local env_OFED_VERSION="$OFED_VERSION"
574 if [ -n "$env_OFED_VERSION" ]; then
575 OFED_VERSION="$env_OFED_VERSION"
578 # doesn't make any sense to build OFED for xen domX's
583 # XXX - set_rpm_smp_type is an ugly undeterministic hack. it needs to
584 # go away and the target just specify the $RPMSMPTYPE
585 [ -z "$RPMSMPTYPE" ] && set_rpm_smp_type
587 # CC might have been overwriten in TARGET_FILE
588 if [[ $CC != ccache\ * ]] && which "$CCACHE" &>/dev/null; then
589 export CCACHE && export CC="ccache $CC"
592 if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then
593 KERNELDIR="$KERNELTREE/${lnxmaj}"
594 [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR"
597 # verify the series is available
598 if [ "$SERIES" ]; then
599 for series in $SERIES; do
600 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
601 [ -r "$patchesdir/series/$series" ] && continue 2
603 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."
607 # set the location of the .config file
613 if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
614 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH${RPMSMPTYPE:+-}${RPMSMPTYPE}.config"
617 local lnxrelnew=${lnxrel//-/_}
619 # remember the EXTRA_VERSION before we diddle it here
620 # XXX - we really should not diddle with any values read in from the
621 # target file. if we want to modify a value, we should create
623 PRISTINE_EXTRA_VERSION=$EXTRA_VERSION
625 if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then
626 fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
629 if [ "$EXTRA_VERSION_save" ]; then
630 EXTRA_VERSION="$EXTRA_VERSION_save"
631 elif ! $RELEASE; then
632 # if there is no patch series, then this is not a lustre specific
633 # kernel. don't make it look like one
634 if [ -n "$SERIES" ]; then
635 #remove the @VERSION@ (lustre version)
636 # EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
637 # EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
638 ! ( $PATCHLESS ) && EXTRA_VERSION="${EXTRA_VERSION}.${TIMESTAMP}"
641 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
643 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
646 for arch in $(uniqify "$ALL_ARCHS"); do
647 if [ -z "$TARGET_ARCHS" ] ||
648 [[ \ $TARGET_ARCHS\ = *\ $arch\ * ]]; then
649 BUILD_ARCHS="$BUILD_ARCHS $arch"
652 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
653 echo "Building for: $BUILD_ARCHS"
661 fatal 1 "tarflags(): File name argument missing."
673 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
682 echo "Untarring ${file##*/}..."
683 tar $(tarflags "$file") "$file"
689 if ! untar "$KERNELTREE/OFED-${OFED_VERSION}.tgz"; then
692 [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED
698 if ! untar "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz"; then
701 [ -d rdac-LINUX ] || ln -sf rdac-LINUX-[0-9][0-9].* rdac-LINUX
707 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
710 mv srpms-2/mptlinux-4.16.00.00-2.src.rpm .
716 if [ -z "$LUSTRE" ]; then
719 if [ -n "$USE_DATESTAMP" ]; then
720 DATESTAMP="-D '$DATE'"
723 local DIRNAME="lustre-$TAG-$TIMESTAMP"
725 cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
726 fatal 1 "There was an error checking out toplevel Lustre from CVS."
727 pushd "$DIRNAME" > /dev/null
728 ./lustrecvs "$TAG" || \
729 fatal 1 "There was an error checking out Lustre/Portals/Build from CVS."
730 echo "Creating lustre tarball..."
731 sh autogen.sh || fatal 1 "There was an error running autogen.sh."
732 ./configure --disable-{modules,utils,liblustre,tests,doc} || \
733 fatal 1 "There was an error running ./configure to create makefiles."
734 make dist || fatal 1 "There was an error running 'make dist'."
735 LUSTRE=$PWD/lustre-*.tar.gz
739 untar "$LUSTRE" || fatal 1 "Error unpacking Lustre tarball"
740 [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
746 local do_patch=${1:-true}
748 FULL_PATCH="$PWD/lustre-kernel-${TARGET}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}.patch"
749 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
750 $do_patch && pushd linux >/dev/null
751 for series in $SERIES; do
752 echo -n "Applying series $series:"
753 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
754 [ -r "$patchesdir/series/$series" ] || continue
755 SERIES_FILE="$patchesdir/series/$series"
756 for patch in $(<"$SERIES_FILE"); do
758 PATCH_FILE="$patchesdir/patches/$patch"
759 [ -r "$PATCH_FILE" ] || \
760 fatal 1 "Patch $patch does not exist in Lustre tree."
761 cat "$PATCH_FILE" >> "$FULL_PATCH" || {
763 fatal 1 "Error adding patch $patch to full patch."
766 patch -s -p1 < "$PATCH_FILE" 2>&1 || {
768 fatal 1 "Error applying patch $patch."
776 $do_patch && popd >/dev/null
777 echo "Full patch has been saved in ${FULL_PATCH##*/}."
787 pushd lustre >/dev/null
789 echo "Building Lustre RPMs for: $BUILD_ARCHS..."
791 for arch in $BUILD_ARCHS; do
792 targets="--target $arch $targets"
795 local confoptions="--with-linux=${linux}"
797 confoptions="--with-linux=${linux} --disable-server"
799 if [ "$linuxobj" != "" ]; then
800 confoptions="$confoptions --with-linux-obj=${linuxobj}"
803 ./configure $confoptions ${CONFIGURE_FLAGS} 2>&1
804 if [ "$?" != "0" ]; then
805 local saved_config="../config.log.$(date +%s)"
806 cp config.log $saved_config
807 chmod a+r $saved_config
808 echo "Saved config.log is at $saved_config"
812 echo "config.log contents:"
820 # hack. Somebody move build/lustre.spec to lustre.spec for b1_6
822 [ -f lustre.spec ] && lustre_spec=lustre.spec
823 [ -f build/lustre.spec ] && lustre_spec=build/lustre.spec
825 [ -f "$lustre_spec" ] && sed \
826 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
830 local rpmbuildopt='-bb'
833 echo NORPM mode. Only compiling.
836 # convert the $PATCHLESS boolean to an empty/no-empty boolean
837 # as silly as this seems, it makes the syntax of the rpmbuild command
838 # simpler and not need an eval to deal with the quotes in the quotes
839 local is_patchless=""
843 $RPMBUILD $targets $rpmbuildopt ../lustre.spec \
844 ${is_patchless:+--define "lustre_name lustre-client"} \
845 --define "_tmppath $TMPDIR" \
846 --define "_topdir $TOPDIR" 2>&1 || \
847 fatal 1 "Error building rpms for $BUILD_ARCHS."
850 ( $(skeep_ldiskfs_rpm $TAG) ) && return
852 pushd lustre/ldiskfs || return 255
854 if [ "$?" != "0" ]; then
858 cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
862 local ldiskfs_spec=lustre-ldiskfs.spec
863 [ -f "$ldiskfs_spec" ] && sed \
864 -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
866 > ../lustre-ldiskfs.spec
868 if ! $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
869 --define "_tmppath /var/tmp" \
870 --define "_topdir $TOPDIR" 2>&1; then
876 if ! $RPMBUILD -bs ../lustre-ldiskfs.spec \
877 --define "_tmppath /var/tmp" \
878 --define "_topdir $TOPDIR" 2>&1; then
889 [ "$STAGEDIR" ] || return 0
891 for arch in $BUILD_ARCHS; do
892 rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
893 echo "${0##*/}: Copying RPMs into ${rpmdir}"
895 cp -v RPMS/${arch}/*.rpm "${rpmdir}"
896 if [ -d RPMS/noarch ]; then
897 cp -v RPMS/noarch/*.rpm "${rpmdir}"
901 cp -v "$LUSTRE" "$STAGEDIR"
905 #check if we need to build separate ldiskfs RPM
906 skeep_ldiskfs_rpm() {
911 if ! $LDISKFSRPM; then
913 elif $PATCHLESS; then
916 for skiptag in $SKIPLDISKFSRPM; do
917 [[ $tag == $skiptag ]] && skip=true && break
921 pushd $TOPDIR/BUILD/lustre-[1-9]* >/dev/null
922 grep -q '^SERVER_TRUE[ \t]=[ \t]#$' autoMakefile && skip=true
929 #generate LUSTRE_EXTRA_VERSION from EXTRA_VERSION
930 gen_lustre_version() {
932 LUSTRE_EXTRA_VERSION="${lnxmaj}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}${TARGET_DELIMITER}${RPMSMPTYPE}"
933 LUSTRE_EXTRA_VERSION=${LUSTRE_EXTRA_VERSION//-/_}
939 local infact_arch="${TARGET_ARCH}"
942 [ "$infact_arch" == "i586" ] && infact_arch="i686"
945 for smp_type in $SMP_ARCHS; do
946 [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break
949 for smp_type in $BIGSMP_ARCHS; do
950 [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break
953 for smp_type in $DEFAULT_ARCHS; do
954 [ $infact_arch == $smp_type ] && RPMSMPTYPE=default && break
959 # This function takes a linux source pool and digs out the linux release
961 find_linux_release() {
964 local LINUXRELEASEHEADER=$SRCDIR/include/linux/version.h
965 if [ -s $SRCDIR/include/linux/utsrelease.h ]; then
966 LINUXRELEASEHEADER=$SRCDIR/include/linux/utsrelease.h
969 sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER
973 # XXX this needs to be re-written as a wrapper around find_rpm
974 # or just gotten rid of. :-)
977 local delimiter=${2:-"-"}
979 local pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
980 [ -d $pathtorpms ] || return 255
982 local kernelbinaryrpm rpmfile
983 local wanted_kernel="${lnxmaj}${delimiter}${lnxrel}"
986 for arch in $TARGET_ARCHS_ALL; do
987 local found_rpm="" rpm
988 for rpm in ${pathtorpms}/${arch}/*.rpm; do
989 if rpm -q --provides -p "$rpm" | grep -q "kernel${prefix} = $wanted_kernel"; then
995 [ -f "$found_rpm" ] && break
1003 # unpack kernel(/source/devel) RPM
1005 # This function and it's setting of $LINUX and $LINUXOBJ is a total hack that
1006 # needs to completely refactored. It completely ingores that $BUILD_ARCHS may
1007 # contain a list of arches for which rpmbuild commands (including the one for
1009 unpack_linux_devel_rpm() {
1010 local kernelrpm="${1}"
1011 # it's worth noting that neither sles10 nor rhel5 appear to use their
1012 # extra_version delimiter for the dirname under /usr/src, so we could
1013 # probably just get rid of this parameter
1014 local delimiter=${2:-"-"}
1016 [ -f "$kernelrpm" ] || return 255
1017 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused || return 255
1019 pushd $TOPDIR/reused &>/dev/null || return 255
1021 if ! rpm2cpio < "$kernelrpm" | cpio -id > /dev/null 2>&1; then
1025 # call a distro specific hook, if available
1026 if type -p unpack_linux_devel_rpm-$DISTRO; then
1027 unpack_linux_devel_rpm-$DISTRO "$kernelrpm"
1032 find_linux_devel_paths $TOPDIR/reused
1038 # XXX - this rhel/sles goop needs abstracting out into the
1039 # lbuild-{rhel5,sles10} method files
1040 find_linux_devel_paths() {
1046 # RHEL-style and SLES-style rpms
1047 # XXX - until bug 19336 cleans this up, we need to extricate the
1048 # ${lnxmin}- from the $lnxrel
1049 local paths="kernels/${lnxmaj}${lnxmin}${delimiter}${lnxrel}-${TARGET_ARCH} linux-${lnxmaj}${lnxmin}${delimiter}${lnxrel##${lnxmin#.}-}"
1052 for path in $paths; do
1055 if [ -d "$src/$path/" ]; then
1056 LINUX="$(pwd)/$src/$path"
1058 # SLES has a separate -obj tree
1059 if [ -d "$src/${path}-obj" ]; then
1060 local src="$src/${path}-obj"
1061 local objects="$TARGET_ARCH/$RPMSMPTYPE"
1063 # Novell, are you *TRYING* to make life hard for me?
1064 if [ -d "$src/powerpc" ]; then
1065 objects="powerpc/$TARGET_ARCH"
1066 elif [ $TARGET_ARCH == 'i686' ]; then
1067 objects="i386/$RPMSMPTYPE"
1070 LINUXOBJ="$(pwd)/$src/$objects"
1073 if [ -z "$LINUX" ]; then
1076 # dig out the release version
1077 LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
1078 if [ -z "$LINUXRELEASE" ]; then
1079 echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
1090 # build kernel-ib{,-devel}
1092 # ofed 1.3 had a bug in the rpm spec
1093 if [ "$OFED_VERSION" = "1.3" ]; then
1097 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"
1098 local OFED_HARDWARE="--with-mthca-mod --with-mlx4-mod --with-mlx4_en-mod --with-cxgb3-mod --with-nes-mod"
1099 # some I/B drivers are architecture dependent and kernel-ib's configure
1100 # does not figure it out for us ~sigh~
1101 case "$TARGET_ARCH" in
1103 OFED_HARDWARE="$OFED_HARDWARE --with-ehca-mod"
1106 # we're no longer shipping the OFED iSCSI
1107 #OFED_ISCSI="--with-srp-mod --with-srp-target-mod"
1108 ## ISER module has no backport support as of OFED 1.5 (i.e. only builds on
1109 ##kernels >= 2.6.30)
1110 #if [[ $OFED_VERSION = 1.[0-4]* ]]; then
1111 # OFED_ISCSI="$OFED_ISCSI --with-iser-mod"
1114 # assume we are just rebuilding the SRPM
1115 local BUILD_TYPE=${BUILD_TYPE:-"--rebuild"}
1116 local SOURCE="${TOPDIR}/OFED/SRPMS/ofa_kernel-*.src.rpm"
1118 # but switch to building from the SPEC if we need to apply patches
1119 if ls ${TOPDIR}/lustre/build/patches/ofed/* >/dev/null; then
1121 rpm --define "_topdir ${TOPDIR}" -ivh $SOURCE
1122 SOURCE="${TOPDIR}/SPECS/ofa_kernel.spec"
1123 local file ed_fragment1 ed_fragment2 n=1
1124 for file in ${TOPDIR}/lustre/build/patches/ofed/*; do
1125 ed_fragment1="$ed_fragment1
1126 Patch$n: ${file%%*/}"
1127 ed_fragment2="$ed_fragment2
1129 cp $file ${TOPDIR}/SOURCES
1144 local linuxrelease=$(find_linux_release "$linux")
1145 if ! $RPMBUILD $BUILD_TYPE --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
1146 --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
1147 --define "KVERSION ${linuxrelease}" \
1148 --define "$K_SRC ${linux}" \
1149 --define "LIB_MOD_DIR /lib/modules/${linuxrelease}/updates" \
1150 ${OFA_KERNEL_RELEASE:+--define "_release $OFA_KERNEL_RELEASE"} \
1151 --define "configure_options --without-quilt $OFED_CORE $OFED_HARDWARE $OFED_ISCSI" \
1152 ${SOURCE} 2>&1; then
1153 fatal 1 "Error building kernel-ib"
1162 local signature="$4"
1163 local use_links="$5"
1170 location="$location"/"$signature"/"$module"
1171 mkdir -p "$location"
1172 # the cleanup script removes any directory that doesn't have a
1173 # .lastused, so let's try to prevent that as soon as we can
1174 # this solution still slightly racy with the cleanup script
1175 # but the race is a lot tighter now
1176 touch -t 197001010000 "$location/.lastused"
1177 ## use eval/echo here to make sure shell expansions are performed
1178 #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then
1180 for article in $(eval echo $articles); do
1181 if ! cp -a${linkflag} "$article" "$location"; then
1182 error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()"
1183 # rename the cache location so that it's not cached
1184 # product, but is around for analysis
1185 mv "$location"{,-bad-$(date +%s)} ||
1186 error "failed to clean up a failed cache attempt" \
1187 "in \"$location\" -- manual cleanup will be" \
1193 # flag the cache as complete (i.e. in case lbuild was previously
1194 # interrupted while caching)
1195 touch "$location/.lastused"
1204 local use_links="${3:-false}"
1205 local signature="$4"
1207 if [ -n "$REUSEBUILD" ] && [ -d "$REUSEBUILD/$signature/$module" ]; then
1208 if [ ! -f "$REUSEBUILD/$signature/$module/.lastused" ]; then
1209 # the .lastused flag is populated at the end of the caching to
1210 # signal that the caching was completed. if that flag is not
1211 # there, then the cache is invalid (and should be removed in fact)
1212 mv "$REUSEBUILD/$signature/$module"{,-bad-$(date +%s)} ||
1213 fatal 1 "failed to clean up a bad cache in location $REUSEBUILD/$signature/$module\" -- manual cleanup will be necessary"
1217 # so that we know how stale this entry is
1218 touch $REUSEBUILD/$signature/$module/.lastused
1221 if ls $REUSEBUILD/$signature/$module/* >/dev/null 2>&1; then
1222 cp -al $REUSEBUILD/$signature/$module/* $dest/
1225 # copying is pretty heavy
1226 # cp -a $REUSEBUILD/$signature/$module/* $dest/
1227 # do some creative symlinking instead
1229 for dir in BUILD SRPMS SPECS; do
1230 if ls $REUSEBUILD/$signature/$module/$dir/* >/dev/null 2>&1; then
1231 ln -s $REUSEBUILD/$signature/$module/$dir/* $dest/$dir
1234 # sources have to be copied by file because we need SOURCES to
1235 # be a dir we can write into
1236 # could overrun ls's arg list here
1237 #ls $REUSEBUILD/$signature/$module/SOURCES/* |
1238 find $REUSEBUILD/$signature/$module/SOURCES/ -type f |
1239 xargs ln -t $dest/SOURCES -s
1241 # same for RPMS/* dirs
1242 # could overrun ls's arg list here
1243 #ls $REUSEBUILD/$signature/$module/RPMS/$TARGET_ARCH/* |
1245 for dir in $REUSEBUILD/$signature/$module/RPMS/*; do
1246 mkdir -p $dest/RPMS/${dir##*/}
1248 xargs ln -t $dest/RPMS/${dir##*/} -s
1261 if [[ $arch = i[3456]86 ]]; then
1270 # in a given directory, find the first rpm matching given requirements
1274 local match_type="$2"
1277 pushd "$dir" > /dev/null || \
1278 fatal 1 "Unable to chdir to directory \"$dir\" in find_rpm()"
1281 for file in $(ls *.rpm); do
1282 if [ ! -f "$file" ]; then
1285 case "$match_type" in
1287 # match is any valid ERE (i.e. given to egrep) match
1288 if rpm -q --provides -p "$file" | egrep -q "$match"; then
1296 fatal 1 "Unknown match type \"$match_type\" given to find_rpm()"
1305 build_kernel_with_srpm() {
1308 if [ -z "$outfd" ] || [ $outfd = 1 ]; then
1309 fatal 1 "You must supply a file descriptor to ${FUNCNAME[0]} and it cannot be 1"
1312 # need to generate the patch for this target
1313 do_patch_linux false >&${outfd} # sets global $FULL_PATCH (yeah, yuck)
1315 # get an md5sum of the kernel patch + config for reuse check
1316 # XXX really, there needs to be a signature and a CONFIG_FILE per arch
1320 local release_str="RELEASE=$RELEASE\n"
1322 local REUSE_SIGNATURE=$({ echo -en $release_str; echo $BUILD_GEN; cat $CONFIG_FILE $TARGET_FILE $FULL_PATCH; } | md5sum | cut -d" " -f1)
1324 # see if we can link to the reuse pool
1325 # XXX - hrm. i'm not convinced this doesn't belong in the reuse "library"
1326 local CAN_LINK_FOR_REUSE=false
1327 touch $REUSEBUILD/$$
1328 if cp -al $REUSEBUILD/$$ $TOPDIR/ 2>/dev/null; then
1329 CAN_LINK_FOR_REUSE=true
1333 # the extra version string to use for the kernel (which might be a reused
1335 local kernel_extra_version=""
1336 if $REUSERPM && ! reuse kernel "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
1337 "$REUSE_SIGNATURE"; then
1338 # nothing cached, build from scratch
1339 if [ ! -r "$KERNELDIR/$KERNEL_SRPM" ]; then
1340 echo "Downloading kernel SRPM"
1341 download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&${outfd}
1344 if ! rpm -ivh $KERNELDIR/$KERNEL_SRPM \
1345 --define "_topdir $TOPDIR" >&${outfd} 2>&1; then
1346 # should we clean this up or leave it for analysis?
1348 fatal 1 "Error installing kernel SRPM."
1351 # put the Lustre kernel patch into the RPM build tree
1352 cp $FULL_PATCH $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch
1353 prepare_and_build_srpm >&${outfd} ||
1354 fatal 1 "failed to prepare_and_build_srpm"
1356 # store the resulting kernel RPM build tree for future use
1357 echo "caching the built kenel for future builds..." >&${outfd}
1358 if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
1359 "kernel" "$REUSEBUILD" "$REUSE_SIGNATURE" \
1360 "$CAN_LINK_FOR_REUSE"; then
1361 error "Failed to store kernel RPMS for reuse"
1367 # figure out the EXTRA_VERSION of the kernel we built or are re-using
1369 if ! KERNEL_RPM=$(find_rpm "$TOPDIR/RPMS/$TARGET_ARCH/" provides "^kernel ="); then
1370 fatal 1 "Failed to find a kernel RPM in $TOPDIR/RPMS/$TARGET_ARCH/"
1372 kernel_extra_version=$(rpm -q --queryformat "%{RELEASE}" -p $TOPDIR/RPMS/$TARGET_ARCH/$KERNEL_RPM)
1374 # should now have the following RPMs
1375 # $TOPDIR/RPMS/$arch/kernel-lustre-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1376 # $TOPDIR/RPMS/$arch/kernel-lustre-devel-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1377 # $TOPDIR/RPMS/$arch/kernel-lustre-headers-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1378 # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-common-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1379 # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1381 echo $kernel_extra_version
1390 if [ -z "$version" -o "$version" = "inkernel" ]; then
1395 for arch in $BUILD_ARCHS; do
1396 targets="--target $arch $targets"
1399 local rpmbuildopt='-bb'
1402 echo NORPM mode. Only compiling.
1405 # if only we could just rebuild the src.rpm. but the included spec
1406 # is a real pig's breakfast. just check out the patch we need to
1407 # apply to it to make it useful.
1408 #$RPMBUILD --rebuild \
1409 # --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
1410 # ${TOPDIR}/mptlinux-*.src.rpm
1411 rpm -ivh --define "_topdir ${TOPDIR}" ${TOPDIR}/mptlinux-*.src.rpm
1413 # now the big honkin' patch to the spec file
1414 pushd ${TOPDIR}/SPECS
1415 # to regen this patch use:
1416 # !!cd ~/rpm/SPECS/ && diff -u mptlinux.spec{.dist,}
1417 patch -p0 < ${TOPDIR}/lustre/build/mptlinux.spec.patch || fatal 1 "failed to patch mptlinux.spec"
1421 for arch in $BUILD_ARCHS; do
1422 targets="--target $arch $targets"
1425 local rpmbuildopt='-bb'
1428 echo NORPM mode. Only compiling.
1431 if ! $RPMBUILD $targets $rpmbuildopt \
1432 --define "_tmppath /var/tmp" \
1433 --define "_topdir ${TOPDIR}" \
1434 --define "kernel_obj $linux" \
1435 ${TOPDIR}/SPECS/mptlinux.spec; then
1439 if ! $RPMBUILD -bs \
1440 --define "_tmppath /var/tmp" \
1441 --define "_topdir ${TOPDIR}" \
1442 --define "kernel_obj $linux" \
1443 ${TOPDIR}/SPECS/mptlinux.spec; then
1457 if [ -z "$version" -o "$version" = "inkernel" ]; then
1461 # note that we use an _, not a . before the spec on purpose. we are not
1462 # allowed to have more than one file with a .spec trailer in a tarball
1463 # that is supposed to be usable with rpmbuild
1464 cp lustre/build/rdac_spec ${TOPDIR}/SPECS/rdac.spec || fatal 1 "Could not find rdac.spec in lustre/build"
1467 for arch in $BUILD_ARCHS; do
1468 targets="--target $arch $targets"
1471 local rpmbuildopt='-bb'
1474 echo NORPM mode. Only compiling.
1479 rhel5) distro="REDHAT"
1481 sles1*) distro="SUSE"
1483 *) echo "$DISTRO not supported by RDAC, skipping"
1487 if ! $RPMBUILD $targets $rpmbuildopt --define "dist $distro" \
1488 --define "_tmppath /var/tmp" \
1489 --define "_topdir ${TOPDIR}" \
1490 --define "kernel_obj $linux" \
1491 ${TOPDIR}/SPECS/rdac.spec; then
1495 if ! $RPMBUILD -bs --define "dist $distro" \
1496 --define "_tmppath /var/tmp" \
1497 --define "_topdir ${TOPDIR}" \
1498 --define "kernel_obj $linux" \
1499 ${TOPDIR}/SPECS/rdac.spec; then
1510 # REUSEBUILD, REUSERPM
1515 local ofed_version="$2"
1517 # before lustre, build kernel-ib
1518 if [ -z "$ofed_version" -o "$ofed_version" = "inkernel" ]; then
1522 if [ -n "$REUSEBUILD" ]; then
1523 # see if we can link to the reuse pool
1524 # XXX - hrm. i'm not convinced this doesn't belong in the reuse
1526 local CAN_LINK_FOR_REUSE=false
1527 touch $REUSEBUILD/$$
1528 if cp -al $REUSEBUILD/$$ $TOPDIR/; then
1529 CAN_LINK_FOR_REUSE=true
1534 local REUSE_SIGNATURE=$({ echo "$ofed_version";
1535 echo "$(find_linux_release ${linux})";
1536 cat "${linux}/include/linux/autoconf.h"; } |
1537 md5sum | cut -d" " -f1)
1538 if ! $REUSERPM || ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
1539 "$REUSE_SIGNATURE"; then
1540 # stash away the existing built articles for a moment
1542 mv {BUILD,{S,}RPMS,S{OURCE,PEC}S} bak
1545 find . | cpio -pudlm ..
1549 create_rpmbuild_dirs
1551 build_kernel_ib "${linux}"
1552 if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
1553 "ofed" "$REUSEBUILD" "$REUSE_SIGNATURE" \
1554 "$CAN_LINK_FOR_REUSE"; then
1555 error "Failed to store OFED RPMS for reuse"
1559 # put the stuff we stashed away back
1563 pushd "$TOPDIR" >/dev/null
1564 rm -rf kernel-ib-devel
1565 mkdir kernel-ib-devel
1567 # the actual ofed RPMs don't have the -rc$n or -$date string appened that
1568 # might be present on the file
1569 local linuxrelease=$(find_linux_release "$linux")
1570 ofed_version=$(echo $ofed_version |
1571 sed -re 's/-(20[0-9]{6,6}-[0-9]{4,4}|rc[0-9]*)$//')
1572 local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${ofed_version}-${linuxrelease//-/_}.*.rpm)
1573 rpm2cpio -itv < $rpm | cpio -id
1574 CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
1581 if ! $PATCHLESS; then
1582 local kernel_extra_version
1583 if ! kernel_extra_version=$(build_kernel_with_srpm ${STDOUT}); then
1584 fatal 1 "Failed to build the kernel from it's SRPM"
1587 for arch in $BUILD_ARCHS; do
1588 local kernel_devel_rpm
1589 if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name $KERNEL_LUSTRE_NAMING) ="); then
1590 fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/"
1593 # install the -devel RPM in preparation for the lustre build
1594 # note that the EXTRA_VERSION_DELIMITER is *NOT* used in the
1595 # version of the directory name under /usr/src
1596 if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \
1597 "$TOPDIR/RPMS/$arch/$kernel_devel_rpm" "-"; then
1598 fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm"
1602 # need to find and unpack the vendor's own kernel-devel for patchless
1605 if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE" ${EXTRA_VERSION_DELIMITER:-"-"}); then
1606 fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in ${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
1608 if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then
1609 fatal 1 "Could not find the Linux tree in $kernelrpm"
1613 build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" ||
1614 fatal 1 "error building OFED"
1616 if ! $PATCHLESS; then
1617 # only need RDAC for the server
1618 build_rdac "${LINUXOBJ:-$LINUX}" "$RDAC_VERSION" ||
1619 fatal 1 "error building RDAC"
1622 build_mptlinux "${LINUXOBJ:-$LINUX}" "$MPTLINUX_VERSION" ||
1623 fatal 1 "error building mptlinux"
1626 if build_lustre "$LINUX" "$LINUXOBJ"; then
1627 # the build worked. resolve any symlinked files (i.e. from reuse)
1628 # in RPMS/$arch to real files so that that that huge mess of
1629 # complication known as LTS can copy them yet somewhere else.
1630 # is it any wonder this whole process is so damn so? anyone ever
1631 # heard of hardlinks? it this cool new thing that allows you save
1632 # tons of time and space by creating... well you can go read about
1633 # them if you have not heard about them yet.
1634 # can i say how much the implemenation of all of this really impedes
1636 pushd RPMS/$TARGET_ARCH
1638 if [ -h $file ]; then
1650 create_rpmbuild_dirs() {
1652 [ -d RPMS ] || mkdir RPMS
1653 for arch in $BUILD_ARCHS; do
1654 if [[ $arch = i?86 ]]; then
1655 # some stupidity in the sles11 kernel spec requires an RPMS/i386
1656 # even if the target arch is i686
1657 [ -d RPMS/i386 ] || mkdir RPMS/i386
1659 [ -d RPMS/$arch ] || mkdir RPMS/$arch
1661 [ -d BUILD ] || mkdir BUILD
1662 [ -d SOURCES ] || mkdir SOURCES
1663 [ -d SPECS ] || mkdir SPECS
1664 [ -d SRPMS ] || mkdir SRPMS
1686 [[ $list\ == *\ $item\ * ]]
1690 #########################################################################
1691 # Generate a backtrace through the call stack.
1695 #########################################################################
1699 local funcname="" sourcefile="" lineno="" n
1701 echo "Call stack: (most recent first)"
1702 for (( n = $strip ; n < ${#FUNCNAME[@]} ; ++n )) ; do
1703 funcname=${FUNCNAME[$n - 1]}
1704 sourcefile=$(basename ${BASH_SOURCE[$n]})
1705 lineno=${BASH_LINENO[$n - 1]}
1709 # Display function arguments
1710 if [[ ! -z "${BASH_ARGV[@]}" ]]; then
1711 local args newarg j p=0
1712 for (( j = ${BASH_ARGC[$n - 1]}; j > 0; j-- )); do
1713 newarg=${BASH_ARGV[$j + $p - 1]}
1714 args="${args:+${args} }'${newarg}'"
1716 let p+=${BASH_ARGC[$n - 1]}
1718 echo " ${funcname} ${args:+${args} }at ${sourcefile}:${lineno}"
1722 echo "BEGIN BACKTRACE"
1724 #echo ${BASH_LINENO[*]}
1725 #echo ${BASH_SOURCE[*]}
1726 #echo ${FUNCNAME[*]}
1727 local i=$((${#FUNCNAME[@]} - 1))
1728 while [ $i -ge 0 ]; do
1729 local lineno=${BASH_LINENO[$i]}
1733 local SOURCELINE="${BASH_SOURCE[$i + 1]}:${lineno}"
1734 # Can't figure out how to get function args from other frames...
1735 local FUNCTION="${FUNCNAME[$i]}()"
1736 echo "$SOURCELINE:$FUNCTION"
1740 echo "END BACKTRACE"
1746 seen_list=$(new_list)
1748 echo "An unexpected error has occurred at ${BASH_SOURCE[0]##*/}:$((LINENO-1)).
1749 Unfortunately the above line number in the message may or may not be correct,
1750 but details have been send to the lbuild maintainer. Attempting to continue."; (echo "Untrapped error"
1752 # have we seen this one
1753 echo "checking seen list for ${BASH_SOURCE[0]}:${BASH_LINENO[0]}"
1755 if is_list_member "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}"; then
1756 echo "seen this one already"
1758 seen_list=$(add_list "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}")
1764 ) | mail -s "Untrapped error at ${BASH_SOURCE[0]##*/}:$((LINENO-15)) on $HOSTNAME" brian@sun.com >&2; set $xtrace' ERR
1767 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
1769 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 -- "$@")
1771 if [ $? != 0 ]; then
1775 eval set -- "$options"
1810 if ! KERNELTREE=$(canon_path "$2"); then
1811 fatal 1 "Could not determine the canonical location of $2"
1815 --linux | --with-linux)
1816 if ! LINUX=$(canon_path "$2"); then
1817 fatal 1 "Could not determine the canonical location of $2"
1830 if ! REUSEBUILD=$(canon_path "$2"); then
1831 fatal 1 "Could not determine the canonical location of $2"
1848 if ! KERNELRPMSBASE=$(canon_path "$2"); then
1849 fatal 1 "Could not determine the canonical location of $2"
1900 --disable-datestamp)
1915 CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests"
1919 usage 1 "Unrecognized option: $1"
1929 EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
1931 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1933 unpack_ofed || fatal 1 "Error unpacking OFED tarball"
1936 if [ -n "$MPTLINUX_VERSION" -a "$MPTLINUX_VERSION" != "inkernel" ]; then
1938 unpack_mptlinux || fatal 1 "Error unpacking MPTLINUX distribution"
1941 # make sure the RPM build environment is set up
1942 create_rpmbuild_dirs
1944 if [ -n "$RDAC_VERSION" -a "$RDAC_VERSION" != "inkernel" ]; then
1946 # we don't actually need to unpack this. just put it in the SOURCES dir
1947 #unpack_rdac || fatal 1 "Error unpacking RDAC tarball"
1948 cp "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz" ${TOPDIR}/SOURCES/ ||
1949 fatal 1 "Error copying RDAC source tarball to RPM SOURCES dir"
1952 # if an unpacked kernel source tree was given on the command line
1953 # just build lustre with it (nothing distro kernel specific here)
1954 if [ -n "$LINUX" ]; then
1955 build_mptlinux "${LINUXOBJ:-$LINUX}" "$MPTLINUX_VERSION" ||
1956 fatal 1 "error building mptlinux"
1957 build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" ||
1958 fatal 1 "error building OFED"
1959 if ! $PATCHLESS; then
1960 build_rdac "${LINUXOBJ:-$LINUX}" "$RDAC_VERSION" ||
1961 fatal 1 "error building RDAC"
1963 build_lustre "$LINUX" "$LINUXOBJ"
1965 if [ -f "${0%/*}/lbuild-$DISTRO" ]; then
1966 source ${0%/*}/lbuild-$DISTRO
1968 build_with_srpm || fatal 1 "Failed to build_with_srpm"
1970 source ${0%/*}/lbuild.old_school
1972 old_school_download_kernel
1976 patchless_build_sequence && build_success=true
1978 [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
1979 if ! $build_success; then
1980 build_sequence_reuse && build_success=true
1981 if ! $build_success; then
1982 build_sequence && build_success=true
1983 if $build_success; then
1984 store_for_reuse || echo "Cannot store for future reuse"
1989 ( $build_success ) || fatal 1 "Cannot build lustre"