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 # Assume that lbuild's support files can be found in the same
19 # canonicalized path as this very script.
20 LBUILD_SCRIPT=$(readlink -f ${0})
21 LBUILD_DIR=${LBUILD_DIR:-$(dirname ${LBUILD_SCRIPT})}
23 # include the exit_traps library
24 . ${LBUILD_DIR}/exit_traps.sh
25 . ${LBUILD_DIR}/funcs.sh
27 # our children should die when we do
28 push_exit_trap "kill -INT -$$ || true" kill_children
30 # increment this if you have made a change that should force a new kernel
33 #BUILD_GEN=2 # bz19952: remove -lustre tag from kernel RPM names
34 #BUILD_GEN=3 # bz19975: enable the building of src.rpms by default
35 #BUILD_GEN=4 # bz22281: use the git hash in the kernel extra version
36 #BUILD_GEN=5 # TT-107: don't cache the BUILD dir
37 BUILD_GEN=6 # TT-1092: don't cache the BUILD dir, to rebuild external OFED
45 # XXX - some recent hacking has pretty much neutered this option.
46 # search through this file for "-bb" and see how many places
47 # simply don't account for this option
52 TARGET_ARCH="$(uname -m)"
53 # change default behavior to only build for the current arch
54 TARGET_ARCHS="$TARGET_ARCH"
55 TARGET_ARCHS_ALL="$TARGET_ARCH"
56 [ "$TARGET_ARCH" = "i686" ] && TARGET_ARCHS_ALL="i686 i586 i386"
61 TMPDIR=${TMPDIR:-"/var/tmp"}
63 # this is the dir that should be used to store reuse products
65 # should cached products be used or force rebuilding?
67 # what does this do exactly? does it imply no kernel build?
71 SMPTYPES="smp bigsmp default ''"
78 # default to not adding -lustre- into the kernel RPM package names
79 KERNEL_LUSTRE_NAMING=false
80 # default not use kabi check.
98 # not in the target file any more
101 # build the lustre-tests rpm?
110 # Readlink is not present on some older distributions: emulate it.
114 if [ -L "$path" ]; then
115 ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
124 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
126 --external-patches=EXTERNAL_PATCHES
127 Directory similar to lustre/lustre/kernel_patches/ that lbuild should
128 look for seres and config files in before looking in the lustre
131 --extraversion=EXTRAVERSION
132 Text to use for the rpm release and kernel extraversion.
134 --timestamp=TIMESTAMP
135 Date of building lustre in format YYYYMMDDhhmmss
138 Try to reuse old kernel builds from DIR
141 Path to distro kernel RPM collection
150 Build lustre client only
153 Which distro using. Autodetect by default
155 --kerneldir=KERNELDIR
156 Directory containing Linux source tarballs referenced by target
159 --kerneltree=KERNELTREE
160 Directory containing dirs with Linux source tarballs referenced by target
161 files. Dir names in format kernel version ('2.6.9', etc.)
163 --linux=LINUX --with-linux=LINUX
164 Directory of Linux kernel sources. When this option is used, only
165 Lustre modules and userspace are built.
168 Path to an existing lustre source tarball to use.
171 Do not try to download a kernel from downloads.hpdd.intel.com
174 Do not build a .src.rpm, a full kernel patch, or a patched kernel
178 Build with ldiskfs support. (Deprecated, always true)
181 Do not build lustre-iokit RPM. Now true by default
187 Specifies that the files generated do not include timestamps, and
188 that this is an official release.
191 Build Lustre without ZFS.
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 The name of the target to build. The available targets are listed
205 --target-archs=TARGET_ARCHS
206 A (space delimited) list of architectures to build. By default,
207 all of the archs supported by the TARGET will be built, in
208 addition to a .src.rpm. This option can limit those, for machines
209 that can only build certain archs or if you only want a certain
210 arch built (for testing, or a one-off kernel).
212 Also note that by using a non-"base" arch (eg, i386) only kernels
213 will be built - there will be no lustre-lite-utils package.
216 Builds a Xen domX kernel.
219 Sets a variable to a given value.
228 # canonicalize a relative path to a file
232 if [ ! -f "$PATH" ]; then
236 local FILE=${PATH##*/}
239 echo $(canon_path "$DIR")/$FILE
243 # canonicalize a relative path to a dir
247 if [ ! -d "$PATH" ]; then
251 pushd "$PATH" >/dev/null || return 1
261 if [ -z "$LUSTRE" -o ! -r "$LUSTRE" ]; then
262 usage 1 "Could not find Lustre source tarball '$LUSTRE'."
265 if [ -z "$DISTRO" ] ; then
266 DISTRO=$(autodetect_distro)
270 DISTROMAJ=${DISTRO%%.*}
272 [ -z "$TARGET" ] && TARGET=$(autodetect_target "$DISTRO")
274 if [ -z "$LINUX" ]; then
275 [ "$KERNELDIR" -o "$KERNELTREE" ] || \
276 usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree."
278 [ -d "$KERNELDIR" -o -d "$KERNELTREE" ] || \
279 usage 1 "$KERNELDIR and $KERNELTREE are not a directory."
281 # TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target"
282 # [ -r "$TARGET_FILE" ] || \
283 # usage 1 "Target '$TARGET' was not found."
288 CANONICAL_TARGET="sles12"
291 CANONICAL_TARGET="rhel7"
294 CANONICAL_TARGET="rhel6"
297 CANONICAL_TARGET="rhel5"
300 CANONICAL_TARGET="rhel-2.6"
303 CANONICAL_TARGET="sles-2.6"
306 CANONICAL_TARGET="sles10-2.6"
308 2.6-sles11 | 3.0-sles11)
309 CANONICAL_TARGET="sles11"
312 CANONICAL_TARGET="oel5"
315 CANONICAL_TARGET="hp-pnnl-2.4"
323 CANONICAL_TARGET="$TARGET"
327 local timestampnodig=$(echo $TIMESTAMP | sed -e s/[0-9]*//g)
328 [ "$timestampnodig" = "" ] || TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
329 local timestamplength="${#TIMESTAMP}"
330 if [ $timestamplength -eq 12 ]; then
331 TIMESTAMP="${TIMESTAMP}00"
332 elif [ $timestamplength -ne 14 ]; then
333 TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S")
336 RPMBUILD=$(which rpmbuild 2>/dev/null | head -1)
337 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
338 RPMBUILD=$(which rpm 2>/dev/null | head -1)
339 if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then
340 usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
344 if [ -n "$CCACHE" ]; then
345 which "$DISTCC" &>/dev/null && export DISTCC RPM_BUILD_NCPUS
347 if which "$CCACHE" &>/dev/null; then
348 local ccache=$(which "$CCACHE")
349 local bindir="$TOPDIR/bin"
351 if [ ! -d $bindir ]; then
352 mkdir -p $bindir || fatal 1 "error trying to create $bindir"
354 rm ${bindir}/* > /dev/null 2>&1 || true
356 ln -s "$ccache" ${bindir}/ccache
357 ln -s "$ccache" ${bindir}/cc
358 ln -s "$ccache" ${bindir}/$CC
359 export PATH=$bindir:$PATH
360 export CCACHE && export CC="ccache $CC"
361 # zero the cache so we can see how effective we are being with it
365 # get some ccache stats when we are done
366 push_exit_trap '[ -n "$CCACHE" ] && ccache -s' "ccache_summary"
367 # should remove the ccache trap if lbuild is interrupted
368 trap 'echo "Received an INT TERM or HUP signal, terminating."; delete_exit_trap "ccache_summary"; exit 1' INT TERM HUP
376 # compare two versions $1 and $2. if $1 < $2, return 0 otherwise return 1.
378 [[ $1 == $2 ]] && return 1
380 local i val1=($1) val2=($2)
382 # padding zero to val1 if it needs
383 for ((i=${#val1[@]}; i<${#val2[@]}; i++)); do
386 for ((i=0; i<${#val1[@]}; i++)); do
387 [[ -z ${val2[i]} ]] && return 1
389 if [[ ${val1[i]} < ${val2[i]} ]]; then
391 elif [[ ${val1[i]} > ${val2[i]} ]]; then
401 echo $(echo "$*" | xargs -n 1 | sort -u)
409 if [ -z "$target" ]; then
410 fatal 1 "fetch_url() called without a target to fetch to"
413 if [ -d $target ]; then
414 target+="/${url##*/}"
418 if which wget >/dev/null 2>&1; then
419 if ! wget -nv "$url" -O "$target"; then
422 elif which curl >/dev/null 2>&1; then
423 if ! curl -n -L -s -o "$target" "$url"; then
427 fatal 1 "Could not find either wget or curl to fetch URLs."
437 local force="${3:-false}"
439 if $force || [ ! -r "$KERNELDIR/$srpm" ] ||
440 [ ! -s "$KERNELDIR/$srpm" ]; then
442 local location="https://downloads.hpdd.intel.com/public/kernels/$target/old"
443 # get the location from a distro specific method if it exists
444 if type -p kernel_srpm_location; then
445 location=$(kernel_srpm_location)
447 echo "Downloading $location/$srpm..."
448 if ! fetch_url "$location/$srpm" "$KERNELDIR/$srpm" 2>&1 ||
449 [ ! -s "$KERNELDIR/$srpm" ]; then
450 rm -f $KERNELDIR/$srpm
451 # punt to a distro specific method if it exists
452 if ! type -p download_srpm-$DISTROMAJ; then
453 fatal 1 "Could not download target $target's kernel SRPM $srpm from $location."
455 if ! download_srpm-$DISTROMAJ "$target" "$srpm" "$force"; then
456 fatal 1 "Could not download target $target's kernel SRPM $srpm using download_srpm-$DISTROMAJ."
461 fatal 1 "$srpm not found in directory $KERNELDIR."
472 local file=${from##*/}
478 local semaphore="$to-downloading"
481 if [ ! -f $semaphore ]; then
485 # make sure the download has not been aborted
486 local now=$(date +%s)
487 local file_mtime=$(stat -c %Y "$to")
488 local staleness=$((now - file_mtime))
489 # let's assume an active download will write at least once a minute
490 if [ $staleness -gt 60 ]; then
498 # if the semaphore file exists, the file is either still downloading
499 # or a download was aborted and we cannot trust the target file
500 if [ -f $semaphore ]; then
504 if ! is_downloading && [ -r "$to" ] && [ -s "$to" ]; then
511 if $force || ! is_downloaded; then
512 if is_downloading; then
513 echo "Somebody else is downloading $from..."
514 while is_downloading; do
515 echo "Waiting for $to to finish downloading"
518 if is_downloaded; then
521 echo "The download we were waiting for seems to have been aborted"
527 echo "Downloading $from..."
528 # flag others so they don't try to download also
529 push_exit_trap "rm -f $to $semaphore" "download"
531 if ! fetch_url "$from" "$to" || [ ! -s "$to" ]; then
532 # the trap will remove the files via the fatal below
533 fatal 1 "Could not download ${to##*/} from ${from%/*}/."
536 delete_exit_trap "download"
538 fatal 1 "${to##*/} not found in directory ${to%/*}."
547 local force="${1:-false}"
549 if [ -z "$OFED_VERSION" -o "$OFED_VERSION" = "inkernel" ]; then
553 local OFED_BASE_VERSION=$OFED_VERSION
554 if [[ $OFED_VERSION = *.*.*.* ]]; then
555 OFED_BASE_VERSION=${OFED_VERSION%.*}
558 local location="https://www.openfabrics.org/downloads/OFED/ofed-${OFED_BASE_VERSION}/"
560 if [[ $OFED_VERSION = *-[rR][cC][0-9] ]]; then
562 Mmv=${OFED_VERSION%%-[rR][cC][0-9]}
563 location="https://www.openfabrics.org/downloads/OFED/ofed-${Mmv}/"
566 if [[ $OFED_VERSION = daily-* ]]; then
568 Mmv=${OFED_VERSION/daily-/}
569 daily=${OFED_VERSION##$Mmv-}
570 location="https://www.openfabrics.org/downloads/OFED/ofed-${Mmv}-daily/"
571 # find the filename for the version for the date specified
572 OFED_VERSION=$(curl -s "$location" | sed -nre "/${Mmv}-/s/.*href=\"OFED-(${Mmv}-[0-9]{8,8}-[0-9]{4,4}).tgz.*$/\1/p" | tail -1)
573 if [ -z "$OFED_VERSION" ]; then
574 fatal 1 "Could not determine the filename of the OFED snapshot for ${daily}"
578 local file="OFED-${OFED_VERSION}.tgz"
579 download_file "$location/$file" "$KERNELTREE" "$force"
585 EXTRA_VERSION_save="$EXTRA_VERSION"
586 for patchesdir in "$EXTERNAL_PATCHES" \
587 "$TOPDIR/lustre/lustre/kernel_patches"; do
588 TARGET_FILE="$patchesdir/targets/$TARGET.target"
589 [ -r "$TARGET_FILE" ] && break
591 [ -r "$TARGET_FILE" ] || fatal 1 "Target $TARGET was not found."
593 echo "Loading target config file $TARGET.target..."
595 # if the caller specified an OFED_VERSION it should override whatever
596 # the target file specifies
597 local env_OFED_VERSION="$OFED_VERSION"
601 if [ -n "$env_OFED_VERSION" ]; then
602 OFED_VERSION="$env_OFED_VERSION"
605 # doesn't make any sense to build OFED for xen domX's
610 # XXX - set_rpm_smp_type is an ugly undeterministic hack. it needs to
611 # go away and the target just specify the $RPMSMPTYPE
612 [ -z "$RPMSMPTYPE" ] && set_rpm_smp_type
614 # CC might have been overwritten in TARGET_FILE
615 if [[ $CC != ccache\ * ]] && which "$CCACHE" &>/dev/null; then
616 export CCACHE && export CC="ccache $CC"
619 if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then
620 KERNELDIR="$KERNELTREE/${lnxmaj}"
621 [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR"
624 # verify the series is available
625 if [ "$SERIES" ]; then
626 for series in $SERIES; do
627 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
628 [ -r "$patchesdir/series/$series" ] && continue 2
630 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."
634 # set the location of the .config file
640 if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
641 CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH.config"
644 local lnxrelnew=${lnxrel//-/_}
646 # remember the EXTRA_VERSION before we diddle it here
647 # XXX - we really should not diddle with any values read in from the
648 # target file. if we want to modify a value, we should create
650 PRISTINE_EXTRA_VERSION=$EXTRA_VERSION
652 if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then
653 fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
656 if [ "$EXTRA_VERSION_save" ]; then
657 EXTRA_VERSION="$EXTRA_VERSION_save"
658 elif ! $RELEASE; then
659 # if there is no patch series, then this is not a lustre specific
660 # kernel. don't make it look like one
661 if $PATCHLESS || [ -n "$SERIES" ]; then
662 EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
665 # EXTRA_VERSION=${EXTRA_VERSION//-/_}
667 ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
670 for arch in $(uniqify "$ALL_ARCHS"); do
671 if [ -z "$TARGET_ARCHS" ] ||
672 [[ \ $TARGET_ARCHS\ = *\ $arch\ * ]]; then
673 BUILD_ARCHS="$BUILD_ARCHS $arch"
676 [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build."
677 echo "Building for: $BUILD_ARCHS"
683 echo -n '--wildcards '
686 fatal 1 "tarflags(): File name argument missing."
698 fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
707 local extractfile="$@"
709 echo "Untarring ${tarfile##*/}..."
710 tar $(tarflags "$tarfile") "$tarfile" $extractfile
716 if ! untar "$KERNELTREE/OFED-${OFED_VERSION}.tgz"; then
719 [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED
725 untar "$LUSTRE" || fatal 1 "Error unpacking Lustre tarball"
726 [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
732 local do_patch=${1:-true}
734 FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch"
735 [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
736 $do_patch && pushd linux >/dev/null
737 for series in $SERIES; do
738 echo -n "Applying series $series:"
739 for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
740 [ -r "$patchesdir/series/$series" ] || continue
741 SERIES_FILE="$patchesdir/series/$series"
742 for patch in $(<"$SERIES_FILE"); do
744 PATCH_FILE="$patchesdir/patches/$patch"
745 [ -r "$PATCH_FILE" ] || \
746 fatal 1 "Patch $patch does not exist in Lustre tree."
747 cat "$PATCH_FILE" >> "$FULL_PATCH" || {
749 fatal 1 "Error adding patch $patch to full patch."
752 patch -s -p1 < "$PATCH_FILE" 2>&1 || {
754 fatal 1 "Error applying patch $patch."
762 $do_patch && popd >/dev/null
763 echo "Full patch has been saved in ${FULL_PATCH##*/}."
770 local configure_args=""
774 pushd lustre >/dev/null
776 if ! build_lustre_dkms; then
777 popd >/dev/null # pushd lustre
781 echo "Building Lustre RPMs for: $BUILD_ARCHS..."
783 # If server we now build the spl and zfs modules against the lustre kernel.
784 # These are required prior to the building of lustre server. Client does
785 # not require spl/zfs. Use !PATCHLESS to indicate server which follows the
786 # line above so is at least consistant.
787 if [ $PATCHLESS == false ] && [ "x$WITH_ZFS" == "x" ]; then
788 if ! build_spl_zfs; then
789 popd >/dev/null # pushd lustre
795 configure_args="$configure_args --disable-server"
798 # ditto for the lustre-tests boolean
799 if ! $LUSTRE_TESTS; then
800 configure_args="$configure_args --disable-tests"
804 configure_args="$configure_args --disable-iokit"
807 if ! $OSDZFSRPM; then
808 configure_args="$configure_args --without-zfs"
811 if ! $OSDLDISKFSRPM; then
812 configure_args="$configure_args --disable-ldiskfs"
815 configure_args="$configure_args --with-linux=$linux"
816 configure_args="$configure_args ${linuxobj:+--with-linux-obj=$linuxobj}"
818 # allow environment setting to override ldiskfs series selection
819 [ -n "$LDISKFS_SERIES" ] && export LDISKFS_SERIES
821 ./configure $configure_args $CONFIGURE_FLAGS 2>&1 ||
822 fatal 1 "Error in configure."
824 fatal 1 "Error building rpms for $BUILD_ARCHS."
826 # move RPMs into place where they are expected to be
827 for arch in $BUILD_ARCHS; do
828 mv -f lustre-*.${arch}.rpm $TOPDIR/RPMS/${arch}/
830 mv -f lustre-*.src.rpm $TOPDIR/SRPMS/
837 # Only zfs Lustre DKMS Server is supported
838 build_lustre_dkms() {
839 local ver=$(eval echo $(awk '/LUSTRE_VERSION_STRING/ {print $3}' lustre/include/lustre_ver.h))
840 echo "Building Lustre DKMS RPMs for: $BUILD_ARCHS..."
841 ./configure --enable-dist || return 255
844 $RPMBUILD --define="_topdir $TOPDIR" --without servers -bs lustre-dkms.spec || return 255
845 $RPMBUILD --rebuild --define="_topdir $TOPDIR" --without servers $TOPDIR/SRPMS/lustre-client-dkms-$ver-*.src.rpm || return 255
847 $RPMBUILD --define="_topdir $TOPDIR" -bs lustre-dkms.spec || return 255
848 $RPMBUILD --rebuild --define="_topdir $TOPDIR" $TOPDIR/SRPMS/lustre-dkms-$ver-*.src.rpm || return 255
856 # Fetch spl/zfs from the git repo and prepare for lustre build
859 # SPLZFSGITREPO - URI of directory where spl.git and zfs.git are located
860 # SPLZFSTAG - Tag to checkout of clone repositories
861 # SPLZFSVER - Version to checkout of both (format zfs/spl-$SPLZFSVER)
863 # return 0 if successful, else 255
865 # make sure the RPM build environment is set up
870 # The spl/zfs spec files expect RPM_BUILD_ROOT to point to the root of the
871 # destination for the rpms
872 export RPM_BUILD_ROOT=$TOPDIR
873 SPLZFSVER=${SPLZFSVER:-0.6.4.2}
874 SPLZFSTAG=${SPLZFSTAG:-}
876 # The files expect a kver to be set to the kernel version .
877 local kver=$(find_linux_release)
879 # build and install the spl and zfs (and -devel) RPMs for lustre to use
881 for pkg in spl zfs; do
885 [ "$pkg" == "zfs" ] && spldir="$(ls -d $TOPDIR/usr/src/spl-*/|tail -1)"
887 # need to fetch the repo in order to build it.
888 # default to github but allow override
889 git clone ${SPLZFSGITREPO:-"https://github.com/zfsonlinux"}/$pkg.git $pkg 2>&1
891 pushd $pkg || return 255
892 if [ -n "$SPLZFSTAG" ]; then
893 git checkout $SPLZFSTAG
895 git checkout -b lbuild $pkg-$SPLZFSVER
898 # This differentiates between older zfs versions
899 if [ -f $pkg-modules.spec.in ]; then
902 speclist="$pkg.spec $rpmpkg.spec"
904 rpmpkg=kmod-$pkg-devel
906 speclist="$pkg.spec $pkg-kmod.spec $pkg-dkms.spec"
909 sh autogen.sh || return 255
911 if ! ./configure --with-linux=${LINUX} --with-linux-obj=${LINUXOBJ:-$LINUX} \
912 ${spldir:+--with-spl="${spldir}"} 2>&1 ||
913 ! make dist 2>&1; then
919 ln -f $pkg/$pkg-*.tar.gz $TOPDIR/SOURCES ||
920 error "failed to link $pkg/$pkg-*.tar.gz into $TOPDIR/SOURCES"
921 if [ -f $pkg/scripts/kmodtool ]; then
922 ln -f $pkg/scripts/kmodtool $TOPDIR/SOURCES/
932 # set search dir for our own kmodtool to find correct
934 export KERNELSOURCE=$(dirname ${LINUX})
935 # Manually build rpms
936 for spec in $speclist; do
937 echo "Building RPMs from $pkg/$specdir/$spec"
938 if ! $RPMBUILD $rpmb $pkg/$specdir/$spec \
940 --define "require_kdir ${LINUX}" \
941 ${LINUXOBJ:+--define "require_kobj ${LINUXOBJ}"} \
942 ${spldir:+--define "require_spldir ${spldir}"} \
943 --define "kver $kver" \
944 --define "kernels $kver" \
945 --define "_tmppath /var/tmp" \
946 --define "kernelbuildroot $TOPDIR/reused" \
947 --define "_topdir $TOPDIR" 2>&1; then
952 # We have built the rpms for the package. Now we need to extract the
953 # contained files so we can build further things against them
954 local rpms=$(ls -1 $TOPDIR/RPMS/*/$rpmpkg-*.rpm)
956 # cpio only extract to pwd so we need to go there.
960 rpm2cpio $rpm | cpio -id
963 if [ "$pkg" == "zfs" ]; then
964 # We also need to extract both the zfs and zfs-devel rpms
965 # the zfs rpm is needed because it has the actual libraries in
966 # it and the zfs-devel rpm only has unversioned symlinks to the
967 # libraries in the zfs rpm
968 # this will all change one day when we have a libzfs rpm per
969 # https://github.com/zfsonlinux/zfs/issues/2329
970 # and it looks like it could be one day soon:
971 # https://github.com/zfsonlinux/zfs/pull/2341
972 local devel_rpms=$(ls -1 $TOPDIR/RPMS/*/{$pkg-devel,$pkg-$SPLZFSVER,lib*}-*.rpm)
973 for rpm in $devel_rpms; do
974 rpm2cpio $rpm | cpio -id
976 CONFIGURE_FLAGS="--with-$pkg-devel=$TOPDIR ${CONFIGURE_FLAGS}"
980 CONFIGURE_FLAGS="--with-$pkg=$(ls -d $TOPDIR/usr/src/$pkg-*/|tail -1) ${CONFIGURE_FLAGS}"
981 CONFIGURE_FLAGS="--with-$pkg-obj=$(ls -d $TOPDIR/usr/src/$pkg-*/$kver*|tail -1) ${CONFIGURE_FLAGS}"
991 [ "$STAGEDIR" ] || return 0
993 for arch in $BUILD_ARCHS; do
994 rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
995 echo "${0##*/}: Copying RPMs into ${rpmdir}"
997 for rpm in $(ls RPMS/${arch}/*.rpm RPMS/noarch/*.rpm); do
998 cp -v $rpm "${rpmdir}"
1002 cp -v "$LUSTRE" "$STAGEDIR"
1006 set_rpm_smp_type() {
1008 local infact_arch="${TARGET_ARCH}"
1011 [ "$infact_arch" == "i586" ] && infact_arch="i686"
1014 for smp_type in $SMP_ARCHS; do
1015 [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break
1018 for smp_type in $BIGSMP_ARCHS; do
1019 [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break
1022 for smp_type in $PPC64_ARCHS; do
1023 [ $infact_arch == $smp_type ] && RPMSMPTYPE=ppc64 && break
1026 for smp_type in $DEFAULT_ARCHS; do
1027 [ $infact_arch == $smp_type ] && RPMSMPTYPE=default && break
1032 # This function takes a linux include tree and digs out the linux release
1033 # from it. It is never called directly, only called from the distro
1034 # specific function find_linux_release() in lbuild-{rhel,sles}.
1035 _find_linux_release() {
1037 local LINUXRELEASEHEADER=""
1039 LINUXRELEASEHEADER=$SRC/include/linux/version.h
1040 if [ -s $SRC/include/generated/utsrelease.h ]; then
1041 LINUXRELEASEHEADER=$SRC/include/generated/utsrelease.h
1042 elif [ -s $SRC/include/linux/utsrelease.h ]; then
1043 LINUXRELEASEHEADER=$SRC/include/linux/utsrelease.h
1046 if [ ! -s $LINUXRELEASEHEADER ]; then
1047 fatal 1 "could not find UTS_RELEASE"
1050 sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER
1053 # unpack kernel(/source/devel) RPM
1055 # This function and it's setting of $LINUX and $LINUXOBJ is a total hack that
1056 # needs to completely refactored. It completely ingores that $BUILD_ARCHS may
1057 # contain a list of arches for which rpmbuild commands (including the one for
1059 unpack_linux_devel_rpm() {
1060 local kernelrpm="${1}"
1062 [ -f "$kernelrpm" ] || return 255
1063 [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused || return 255
1065 pushd $TOPDIR/reused &>/dev/null || return 255
1067 if ! rpm2cpio < "$kernelrpm" | cpio -id > /dev/null 2>&1; then
1071 # call a distro specific hook, if available
1072 if type -p unpack_linux_devel_rpm-$DISTROMAJ; then
1073 if ! unpack_linux_devel_rpm-$DISTROMAJ "$kernelrpm"; then
1080 find_linux_devel_paths $TOPDIR/reused
1088 local kib_prefix="$2"
1091 # build kernel-ib{,-devel}/compat-rdma{,-devel}
1093 # ofed 1.3 had a bug in the rpm spec
1094 if [ "$OFED_VERSION" = "1.3" ]; then
1098 local OFED_CORE="--with-core-mod --with-ipoib-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod"
1099 local OFED_HARDWARE="--with-mthca-mod --with-mlx4-mod --with-mlx4_en-mod --with-cxgb3-mod --with-nes-mod --with-qib-mod"
1101 if compare_version $OFED_VERSION 3.0; then
1102 OFED_CORE="$OFED_CORE --with-madeye-mod --with-rds-mod"
1104 OFED_HARDWARE="$OFED_HARDWARE --with-mlx5-mod --with-cxgb4-mod --with-ocrdma-mod --with-qib-mod"
1107 # some I/B drivers are architecture dependent and kernel-ib's configure
1108 # does not figure it out for us ~sigh~
1109 case "$TARGET_ARCH" in
1111 OFED_HARDWARE="$OFED_HARDWARE --with-ehca-mod"
1114 # we're no longer shipping the OFED iSCSI target
1115 #OFED_ISCSI="--with-srp-mod --with-srp-target-mod"
1116 OFED_ISCSI="--with-srp-mod"
1117 ## ISER module has no backport support as of OFED 1.5 (i.e. only builds on
1118 ##kernels >= 2.6.30)
1119 #if [[ $OFED_VERSION = 1.[0-4]* ]]; then
1120 # OFED_ISCSI="$OFED_ISCSI --with-iser-mod"
1123 # assume we are just rebuilding the SRPM
1124 local BUILD_TYPE=${BUILD_TYPE:-"--rebuild"}
1125 local SOURCE="${TOPDIR}/OFED/SRPMS/${kib_prefix}-*.src.rpm"
1127 # but switch to building from the SPEC if we need to apply patches
1128 if ls ${TOPDIR}/lustre/contrib/patches/ofed/* >/dev/null; then
1130 rpm --define "_topdir ${TOPDIR}" -ivh $SOURCE
1131 SOURCE="${TOPDIR}/SPECS/${kib_prefix}.spec"
1132 local file ed_fragment1 ed_fragment2 n=1
1133 for file in $(ls ${TOPDIR}/lustre/contrib/patches/ofed/*.patch); do
1134 ed_fragment1="$ed_fragment1
1135 Patch$n: ${file%%*/}"
1136 ed_fragment2="$ed_fragment2
1138 cp $file ${TOPDIR}/SOURCES
1141 for file in $(ls ${TOPDIR}/lustre/contrib/patches/ofed/*.ed); do
1142 # Only apply the ed-scripts that should be used for the canonical target
1143 # ed-files in ${TOPDIR}/lustre/contrib/patches/ofed/ have to follow the naming
1145 # <two-digits>-<descriptive-name>:<canonical_target_1>: ...:<canonical_target_N>.ed
1146 # To apply the same change to multiple canonical target simply specify
1147 # a list of colon separated canoncial target names in the file name.
1148 echo "$file" | grep -q -e ":${CANONICAL_TARGET}:" \
1149 -e ":${CANONICAL_TARGET}.ed$"
1150 if [ $? -eq 0 ] ; then
1151 ed_fragment3="$ed_fragment3
1157 if [ $n -gt 1 ]; then
1171 local linuxrelease=$(find_linux_release)
1172 if compare_version $OFED_VERSION 3.0; then
1173 local OFA_KERNEL_RELEASE=$(echo -n ${linuxrelease} | sed -e 's/-/_/g')
1175 if ! $RPMBUILD $BUILD_TYPE --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
1176 ${FIND_REQUIRES:+--define "__find_requires $FIND_REQUIRES"} \
1177 --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
1178 --define "KVERSION ${linuxrelease}" \
1179 --define "$K_SRC ${linux}" \
1180 --define "LIB_MOD_DIR /lib/modules/${linuxrelease}/updates" \
1181 ${OFA_KERNEL_RELEASE:+--define "_release $OFA_KERNEL_RELEASE"} \
1182 --define "configure_options --without-quilt $OFED_CORE $OFED_HARDWARE $OFED_ISCSI" \
1183 ${SOURCE} 2>&1; then
1184 fatal 1 "Error building ${kib_rpm}"
1193 local signature="$4"
1194 local use_links="$5"
1201 local default_iface=$(/sbin/ip route get 192.1.1.1 | sed -ne 's/.* dev \(.*\) * src .*/\1/p')
1202 if [ -z "$default_iface" ]; then
1203 fatal 1 "Failed to determine the default route interface"
1205 local unique_id=$(/sbin/ip addr show dev $default_iface | sed -ne '/ inet /s/ *inet \(.*\)\/.*/\1/p' | head -1)
1206 if [ -z "$unique_id" ]; then
1207 fatal 1 "Failed to determine a unique id from interface $default_interface"
1210 local finallocation="$location"/"$signature"/"$module"
1211 location="$location"/"$signature-${unique_id}"/"$module"
1212 mkdir -p "$location"
1213 # the cleanup script removes any directory that doesn't have a
1214 # .lastused, so let's try to prevent that as soon as we can
1215 # this solution still slightly racy with the cleanup script
1216 # but the race is a lot tighter now
1217 touch -t 197001010000 "$location/.lastused"
1218 ## use eval/echo here to make sure shell expansions are performed
1219 #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then
1221 for article in $(eval echo $articles); do
1222 if ! cp -a${linkflag} "$article" "$location"; then
1223 error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()"
1224 # rename the cache location so that it's not cached
1225 # product, but is around for analysis
1226 mv "$location"{,-bad-$(date +%s)} ||
1227 error "failed to clean up a failed cache attempt" \
1228 "in \"$location\" -- manual cleanup will be" \
1234 # flag the cache as complete (i.e. in case lbuild was previously
1235 # interrupted while caching)
1236 touch "$location/.lastused"
1238 # put the temporary location into the final location
1240 mkdir -p "${finallocation%/*}"
1241 mv "$location" "$finallocation"
1242 rmdir "${location%/*}"
1250 local use_links="${3:-false}"
1251 local signature="$4"
1253 if [ -n "$REUSEBUILD" ] && [ -d "$REUSEBUILD/$signature/$module" ]; then
1254 if [ ! -f "$REUSEBUILD/$signature/$module/.lastused" ]; then
1255 # the .lastused flag is populated at the end of the caching to
1256 # signal that the caching was completed. if that flag is not
1257 # there, then the cache is invalid (and should be removed in fact)
1258 mv "$REUSEBUILD/$signature/$module"{,-bad-$(date +%s)} ||
1259 fatal 1 "failed to clean up a bad cache in location $REUSEBUILD/$signature/$module\" -- manual cleanup will be necessary"
1263 # so that we know how stale this entry is
1264 touch $REUSEBUILD/$signature/$module/.lastused
1267 if ls $REUSEBUILD/$signature/$module/* >/dev/null 2>&1; then
1268 cp -al $REUSEBUILD/$signature/$module/* $dest/
1271 # copying is pretty heavy
1272 # cp -a $REUSEBUILD/$signature/$module/* $dest/
1273 # do some creative symlinking instead
1275 for dir in BUILD SRPMS SPECS; do
1276 if ls $REUSEBUILD/$signature/$module/$dir/* >/dev/null 2>&1; then
1277 ln -s $REUSEBUILD/$signature/$module/$dir/* $dest/$dir
1280 # sources have to be copied by file because we need SOURCES to
1281 # be a dir we can write into
1282 # could overrun ls's arg list here
1283 #ls $REUSEBUILD/$signature/$module/SOURCES/* |
1284 find $REUSEBUILD/$signature/$module/SOURCES/ -type f |
1285 xargs ln -t $dest/SOURCES -s
1287 # same for RPMS/* dirs
1288 # could overrun ls's arg list here
1289 #ls $REUSEBUILD/$signature/$module/RPMS/$TARGET_ARCH/* |
1291 for dir in $REUSEBUILD/$signature/$module/RPMS/*; do
1292 mkdir -p $dest/RPMS/${dir##*/}
1294 xargs ln -t $dest/RPMS/${dir##*/} -s
1306 if [[ $arch = i[3456]86 ]]; then
1314 build_kernel_with_srpm() {
1317 if [ -z "$outfd" ] || [ $outfd = 1 ]; then
1318 fatal 1 "You must supply a file descriptor to ${FUNCNAME[0]} and it cannot be 1"
1321 # need to generate the patch for this target
1322 do_patch_linux false >&${outfd} # sets global $FULL_PATCH (yeah, yuck)
1324 # get an md5sum of the kernel patch + config for reuse check
1325 # XXX really, there needs to be a signature and a CONFIG_FILE per arch
1329 local release_str="RELEASE=$RELEASE\n"
1332 if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then
1333 local REUSE_SIGNATURE=$({ echo -en $release_str;
1336 cat "$TARGET_FILE" |
1337 sed -e '/_VERSION=/s/_[0-9]*_g.*$//g';
1339 cat "$LBUILD_DIR/lbuild";
1340 cat "$LBUILD_DIR/lbuild-$DISTROMAJ"; } |
1341 md5sum | cut -d" " -f1)
1342 # see if we can link to the reuse pool
1343 # XXX - hrm. i'm not convinced this doesn't belong in the reuse
1345 local CAN_LINK_FOR_REUSE=false
1346 touch $REUSEBUILD/$$
1347 if cp -al $REUSEBUILD/$$ $TOPDIR/ 2>/dev/null; then
1348 CAN_LINK_FOR_REUSE=true
1353 # the extra version string to use for the kernel (which might be a reused
1355 local kernel_extra_version=""
1356 if ! $USE_BUILD_CACHE || ! reuse kernel "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
1357 "$REUSE_SIGNATURE"; then
1358 # nothing cached, build from scratch
1359 if [ ! -r "$KERNELDIR/$KERNEL_SRPM" ]; then
1360 echo "Downloading kernel SRPM" >&${outfd}
1361 download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&${outfd}
1364 if ! rpm -ivh $KERNELDIR/$KERNEL_SRPM \
1365 --define "_topdir $TOPDIR" >&${outfd} 2>&1; then
1366 # should we clean this up or leave it for analysis?
1368 fatal 1 "Error installing kernel SRPM."
1371 # put the Lustre kernel patch into the RPM build tree
1372 cp $FULL_PATCH $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch
1373 prepare_and_build_srpm >&${outfd} ||
1374 fatal 1 "failed to prepare_and_build_srpm"
1376 if [ -z "$REUSE_SIGNATURE" ]; then
1377 echo "No reuse signature was caculated so not storing the built kernel" >&${outfd}
1379 # store the resulting kernel RPM build tree for future use
1380 echo "Storing the built kernel for future reuse" >&${outfd}
1381 if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,SRPMS,RPMS}" \
1382 "kernel" "$REUSEBUILD" "$REUSE_SIGNATURE" \
1383 "$CAN_LINK_FOR_REUSE"; then
1384 error "Failed to store kernel RPMS for reuse"
1385 echo "unknown" >&${outfd}
1391 # figure out the EXTRA_VERSION of the kernel we built or are re-using
1393 if ! KERNEL_RPM=$(find_rpm "$TOPDIR/RPMS/$TARGET_ARCH/" provides "^kernel(-default)? ="); then
1394 fatal 1 "Failed to find a kernel RPM in $TOPDIR/RPMS/$TARGET_ARCH/"
1396 kernel_extra_version=$(rpm -q --queryformat "%{RELEASE}" -p $TOPDIR/RPMS/$TARGET_ARCH/$KERNEL_RPM)
1398 # should now have the following RPMs
1399 # $TOPDIR/RPMS/$arch/kernel-lustre-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1400 # $TOPDIR/RPMS/$arch/kernel-lustre-devel-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1401 # $TOPDIR/RPMS/$arch/kernel-lustre-headers-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1402 # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-common-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1403 # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
1405 echo $kernel_extra_version
1413 # REUSEBUILD, USE_BUILD_CACHE
1418 local ofed_version="$2"
1422 # if an ofed version is given, then it means use OFED proper,
1423 # not any vendor specific "inkernel" version
1424 if [ -z "$ofed_version" ]; then
1428 if [ "$ofed_version" = "inkernel" ]; then
1429 # see if there is a distro specific override for this and use
1431 # XXX we need to better integrate a distro specific override with
1432 # the rest of this function so that all of the reuse cache
1433 # stuff is leveraged given that 80% of this function is reuse
1434 if type -p build_ofed-$DISTROMAJ; then
1436 ofed_location=$(build_ofed-$DISTROMAJ ${STDOUT})
1437 local rc=${PIPESTATUS[0]}
1438 CONFIGURE_FLAGS="--with-o2ib=${ofed_location} ${CONFIGURE_FLAGS}"
1443 elif compare_version $OFED_VERSION 3.0; then
1444 kib_prefix="ofa_kernel"
1447 kib_prefix="compat-rdma"
1448 kib_rpm="compat-rdma"
1451 # build kernel-ib/compat-rdma
1452 if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then
1453 local REUSE_SIGNATURE=$({ echo "$ofed_version";
1454 echo "$(find_linux_release;
1455 echo "$BUILD_GEN")";
1456 cat "${linux}/include/linux/autoconf.h";
1457 cat "$LBUILD_DIR/lbuild";
1458 cat "$LBUILD_DIR/lbuild-$DISTROMAJ"; } |
1459 md5sum | cut -d" " -f1)
1460 # see if we can link to the reuse pool
1461 # XXX - hrm. i'm not convinced this doesn't belong in the reuse
1463 local CAN_LINK_FOR_REUSE=false
1464 touch $REUSEBUILD/$$
1465 if cp -al $REUSEBUILD/$$ $TOPDIR/; then
1466 CAN_LINK_FOR_REUSE=true
1471 if ! $USE_BUILD_CACHE || ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
1472 "$REUSE_SIGNATURE"; then
1473 if [ -n "$REUSE_SIGNATURE" ]; then
1474 # stash away the existing built articles for a moment
1476 mv {BUILD,{S,}RPMS,S{OURCE,PEC}S} bak
1479 find . | cpio -pudlm ..
1483 create_rpmbuild_dirs
1486 build_kernel_ib "${linux}" "${kib_prefix}" "${kib_rpm}"
1488 if [ -z "$REUSE_SIGNATURE" ]; then
1489 echo "No reuse signature was caculated so not storing the built ofed"
1491 # store the resulting RPM build tree for future use
1492 echo "Storing the built ofed for future reuse"
1493 if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
1494 "ofed" "$REUSEBUILD" "$REUSE_SIGNATURE" \
1495 "$CAN_LINK_FOR_REUSE"; then
1496 error "Failed to store OFED RPMS for reuse"
1500 # put the stuff we stashed away back
1505 pushd "$TOPDIR" >/dev/null
1506 rm -rf ${kib_rpm}-devel
1507 mkdir ${kib_rpm}-devel
1509 # the actual ofed RPMs don't have the -rc$n or -$date string appened that
1510 # might be present on the file
1511 #local linuxrelease=$(find_linux_release)
1512 #ofed_version=$(echo $ofed_version |
1513 # sed -re 's/-(20[0-9]{6,6}-[0-9]{4,4}|rc[0-9]*)$//')
1515 # OFED version will have 'hyphen' for minor release. (e.g. 3.5-1, instead
1516 # of 3.5.1) compat-rdma and compat-rdma-devel could have same version
1517 # number, but currectly not. Once OFED fix this in the future release, we
1518 # can remove following filter.
1519 #ofed_version=$(echo $ofed_version |
1520 # sed -re 's/-([0-9]*-[rR][cC][0-9]*)$//')
1521 #local rpm=$(ls $TOPDIR/RPMS/*/${kib_rpm}-devel-${ofed_version}-${linuxrelease//-/_}.*.rpm)
1522 # I dont' know why we have gone through the trouble to filter out the name
1523 # of the rpm there should only be one ${kib_rpm}-devel built
1524 local rpm=$(ls $TOPDIR/RPMS/*/${kib_rpm}-devel-*.rpm)
1525 if ! rpm2cpio < $rpm | cpio -id; then
1526 fatal 1 "could not unpack the ${kib_rpm}-devel rpm."
1528 CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/${kib_prefix} ${CONFIGURE_FLAGS}"
1535 if ! $PATCHLESS; then
1536 local kernel_extra_version
1537 if ! kernel_extra_version=$(build_kernel_with_srpm ${STDOUT}); then
1538 fatal 1 "Failed to build the kernel from it's SRPM"
1541 for arch in $BUILD_ARCHS; do
1542 local kernel_devel_rpm
1543 if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name $KERNEL_LUSTRE_NAMING) ="); then
1544 fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/"
1547 # install the -devel RPM in preparation for modules builds
1548 if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \
1549 "$TOPDIR/RPMS/$arch/$kernel_devel_rpm"; then
1550 fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm"
1554 # need to find and unpack the vendor's own kernel-devel for patchless
1557 if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE"); then
1558 fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in $KERNELRPMSBASE/$lnxmaj/$DISTROMAJ"
1560 if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then
1561 fatal 1 "Could not find the Linux tree in $kernelrpm"
1565 # ~sigh~ have to make copies of and modify some of the rpm
1566 # infrastructure files so that find-requires can find our unpacked
1567 # kernel-devel artifacts
1568 cp $RPM_HELPERS_DIR/{symset-table,find-requires{,.ksyms}} .
1569 FIND_REQUIRES="$(pwd)/find-requires"
1570 chmod 755 {symset-table,find-requires{,.ksyms}}
1572 tmp="${tmp//\//\\/}"
1573 ed find-requires <<EOF
1577 /|.*find-requires.ksyms/s/|/| bash -x/
1578 g/ [^ ]*\/\(find-requires\.ksyms\)/s// $tmp\/\1/g
1581 ed find-requires.ksyms <<EOF
1585 g/\/.*\/\(symset-table\)/s//$tmp\/\1/g
1588 ed symset-table <<EOF
1592 g/\(\/boot\/\)/s//$tmp\/reused\1/g
1593 g/\(\/usr\/src\/kernels\/\)/s//$tmp\/reused\1/g
1597 build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" ||
1598 fatal 1 "error building OFED"
1601 if build_lustre "$LINUX" "$LINUXOBJ"; then
1602 # the build worked. resolve any symlinked files (i.e. from reuse)
1603 # in RPMS/$arch to real files so that that that huge mess of
1604 # complication known as LTS can copy them yet somewhere else.
1605 # is it any wonder this whole process is so damn so? anyone ever
1606 # heard of hardlinks? it's this cool new thing that allows you save
1607 # tons of time and space by creating... well you can go read about
1608 # them if you have not heard about them yet.
1609 # can i say how much the implemenation of all of this really impedes
1612 for dir in RPMS/*; do
1614 for file in $(ls); do
1615 if [ -h $file ]; then
1622 # also, for i?86, make sure all of the RPMs are in RPMS/$TARGET_ARCH
1623 # as that's where LTS expects to find them
1624 for dir in RPMS/*; do
1625 if [ $dir = RPMS/$TARGET_ARCH ]; then
1630 if [ -n "$files" ]; then
1631 cp -al $files ../$TARGET_ARCH
1641 create_rpmbuild_dirs() {
1643 [ -d RPMS ] || mkdir RPMS
1644 for arch in $BUILD_ARCHS; do
1645 if [[ $arch = i?86 ]]; then
1646 # some stupidity in the sles11 kernel spec requires an RPMS/i386
1647 # even if the target arch is i686
1648 [ -d RPMS/i386 ] || mkdir RPMS/i386
1650 [ -d RPMS/$arch ] || mkdir RPMS/$arch
1652 [ -d RPMS/noarch ] || mkdir RPMS/noarch
1653 [ -d BUILD ] || mkdir BUILD
1654 [ -d SOURCES ] || mkdir SOURCES
1655 [ -d SPECS ] || mkdir SPECS
1656 [ -d SRPMS ] || mkdir SRPMS
1678 [[ $list\ == *\ $item\ * ]]
1682 #########################################################################
1683 # Generate a backtrace through the call stack.
1687 #########################################################################
1691 local funcname="" sourcefile="" lineno="" n
1693 echo "Call stack: (most recent first)"
1694 for (( n = $strip ; n < ${#FUNCNAME[@]} ; ++n )) ; do
1695 funcname=${FUNCNAME[$n - 1]}
1696 sourcefile=$(basename ${BASH_SOURCE[$n]})
1697 lineno=${BASH_LINENO[$n - 1]}
1701 # Display function arguments
1702 if [[ ! -z "${BASH_ARGV[@]}" ]]; then
1703 local args newarg j p=0
1704 for (( j = ${BASH_ARGC[$n - 1]}; j > 0; j-- )); do
1705 newarg=${BASH_ARGV[$j + $p - 1]}
1706 args="${args:+${args} }'${newarg}'"
1708 let p+=${BASH_ARGC[$n - 1]}
1710 echo " ${funcname} ${args:+${args} }at ${sourcefile}:${lineno}"
1714 echo "BEGIN BACKTRACE"
1716 #echo ${BASH_LINENO[*]}
1717 #echo ${BASH_SOURCE[*]}
1718 #echo ${FUNCNAME[*]}
1719 local i=$((${#FUNCNAME[@]} - 1))
1720 while [ $i -ge 0 ]; do
1721 local lineno=${BASH_LINENO[$i]}
1725 local SOURCELINE="${BASH_SOURCE[$i + 1]}:${lineno}"
1726 # Can't figure out how to get function args from other frames...
1727 local FUNCTION="${FUNCNAME[$i]}()"
1728 echo "$SOURCELINE:$FUNCTION"
1732 echo "END BACKTRACE"
1738 seen_list=$(new_list)
1740 echo "An unexpected error has occurred at ${BASH_SOURCE[0]##*/}:$((LINENO-1)).
1741 Unfortunately the above line number in the message may or may not be correct,
1742 but details have been send to the lbuild maintainer. Attempting to continue."; (echo "Untrapped error"
1744 # have we seen this one
1745 echo "checking seen list for ${BASH_SOURCE[0]}:${BASH_LINENO[0]}"
1747 if is_list_member "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}"; then
1748 echo "seen this one already"
1750 seen_list=$(add_list "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}")
1753 ) ; set $xtrace' ERR
1756 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
1758 options=$(getopt -o D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ccache,norpm,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,noiokit,ofed-version:,publish,disable-zfs,release,set-value:,src,stage:,target:,target-archs:,with-linux:,xen -- "$@")
1760 if [ $? != 0 ]; then
1764 eval set -- "$options"
1795 if ! KERNELTREE=$(canon_path "$2"); then
1796 fatal 1 "Could not determine the canonical location of $2"
1800 --linux | --with-linux)
1801 if ! LINUX=$(canon_path "$2"); then
1802 fatal 1 "Could not determine the canonical location of $2"
1811 if ! REUSEBUILD=$(canon_path "$2"); then
1812 fatal 1 "Could not determine the canonical location of $2"
1828 if ! KERNELRPMSBASE=$(canon_path "$2"); then
1829 fatal 1 "Could not determine the canonical location of $2"
1838 if ! LUSTRE=$(canon_filepath "$2"); then
1839 fatal 1 "Could not determine the canonical location of $2"
1892 # there are actually some lustre configure flags that we need to
1893 # handle ourselves (but we still give them to configure)
1894 if [[ \ $@\ == *\ --disable-tests\ * ]]; then
1901 usage 1 "Unrecognized option: $1"
1912 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
1914 unpack_ofed || fatal 1 "Error unpacking OFED tarball"
1917 # make sure the RPM build environment is set up
1918 create_rpmbuild_dirs
1920 # if an unpacked kernel source tree was given on the command line
1921 # just build lustre with it (nothing distro kernel specific here)
1922 if [ -n "$LINUX" ]; then
1923 find_linux_release() {
1924 _find_linux_release $LINUX
1926 build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" ||
1927 fatal 1 "error building OFED"
1928 build_lustre "$LINUX" "$LINUXOBJ"
1930 if [ ! -f "${LBUILD_DIR}/lbuild-$DISTROMAJ" ]; then
1931 fatal 1 "${LBUILD_DIR}/lbuild-$DISTROMAJ not found"
1933 source ${LBUILD_DIR}/lbuild-$DISTROMAJ
1934 build_with_srpm || fatal 1 "Failed to build_with_srpm"