SMPTYPES="smp bigsmp default ''"
KERNCONFSMPTYPE=
PATCHLESS=false
+XEN=false
LINUXOBJ=
REUSEDKERNELMASK=
DISTRO=
checkouts. This is a workaround for a problem encountered when
using lbuild with tinderbox.
+ --xen
+ Builds a Xen domX kernel.
+
EOF
# list_targets
. "$TARGET_FILE"
+ # doesn't make any sense to build OFED for xen domX's
+ if $XEN; then
+ OFED_VERSION=""
+ fi
+
[ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
[ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
fi
fi
fi
- if [ -n "$OFED_VERSION" ] && \
+ if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ] && \
[ ! -r "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ] ; then
if (( $DOWNLOAD )) ; then
local location="http://downloads.lustre.org/public/OFED/"
done
fi
+ local XENPOSTFIX=""
+ if $XEN; then
+ XENPOSTFIX="-xen"
+ fi
if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
- CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config"
+ CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH.config"
fi
local smptype
for smptype in $SMPTYPES; do
[ "$smptype" = "''" ] && smptype=
if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config ]; then
- CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config"
+ CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH-${smptype}.config"
KERNCONFSMPTYPE=$smptype
fi
done
- local lnxrelnew=$( echo ${lnxrel} | sed s/-/_/g )
+ local lnxrelnew=${lnxrel//-/_}
- [ -f "$CONFIG_FILE" ] || \
+ if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then
fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
+ fi
+
if [ "$EXTRA_VERSION_save" ] ; then
EXTRA_VERSION="$EXTRA_VERSION_save"
elif ! $RELEASE; then
BUILD_ARCHS=
for arch in $(uniqify "$ALL_ARCHS") ; do
- if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep "$arch" >/dev/null 2>/dev/null ; then
+ if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep -w "$arch" >/dev/null 2>/dev/null ; then
BUILD_ARCHS="$BUILD_ARCHS $arch"
fi
done
prep_kernel_build()
{
+ local lmakeopts="\"\""
+ if $XEN; then
+ lmakeopts="--xen"
+ fi
# make .spec file
ENABLE_INIT_SCRIPTS=""
sed \
-e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
-e "s^@SUSEBUILD@^$SUSEBUILD^g" \
-e "s^@UP_ARCHS@^$UP_ARCHS^g" \
+ -e "s^@LMAKEOPTS@^$lmakeopts^g" \
< $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
> lustre-kernel-2.4.spec
[ -d SRPMS ] || mkdir SRPMS
[ "$KERNCONFSMPTYPE" = "" ] || smptype=$KERNCONFSMPTYPE
[ "$RPMSMPTYPE" = "" ] || smptype=$RPMSMPTYPE
- LUSTRE_EXTRA_VERSION="${lnxmaj}-${EXTRA_VERSION}"
- if [ "$PATCHLESS" = "true" -a "$DISTRO" = "sles10" ]; then
- LUSTRE_EXTRA_VERSION="${LUSTRE_EXTRA_VERSION}-${smptype}"
- else
- LUSTRE_EXTRA_VERSION="${LUSTRE_EXTRA_VERSION}${smptype}"
- fi
- LUSTRE_EXTRA_VERSION=$( echo $LUSTRE_EXTRA_VERSION | sed -e "s^-^_^g" )
+ LUSTRE_EXTRA_VERSION="${lnxmaj}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}${TARGET_DELIMITER}${smptype}"
+ LUSTRE_EXTRA_VERSION=${LUSTRE_EXTRA_VERSION//-/_}
}
#store RPMs and/or BUILD dir for future reuse
return 255
fi
- local lnxrelnew=$( echo ${lnxrel} | sed s/-/_/g )
- local EXTRA_VERSIONnew=$( echo ${EXTRA_VERSION} | sed s/-/_/g )
- local KERNELRPMnew=$(basename "$KERNELRPM")
+ local lnxrelnew=${lnxrel//-/_}
+ local EXTRA_VERSIONnew=${EXTRA_VERSION//-/_}
+ local KERNELRPMnew=$(basename "$KERNELRPM")
if [ ! "$rpmonly" = "rpmonly" ]; then
local builddir=
if [ ! "$KERNELCOMPILEDIR" = "" ]; then
builddir="$KERNELCOMPILEDIR"
else
builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}"
- [ "$KERNELCOMPILEDIR" = "" ] || builddir="$KERNELCOMPILEDIR"
+ [ "$KERNELCOMPILEDIR" = "" ] || builddir="$KERNELCOMPILEDIR"
[ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}.${lnxrel}"
[ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}-${lnxrel}"
- if [ ! -d "$builddir" ]; then
+ if [ ! -d "$builddir" ]; then
pushd "BUILD/lustre-kernel-${lnxmaj}/lustre/" || return 255
local basebuilddir=$(ls -d linux-${lnxmaj}* | head -1)
[ "$basebuilddir" = "" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/${basebuilddir}"
popd
- fi
+ fi
fi
[ -d "$builddir" ] || return 255
- local dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}"
- ( $PATCHLESS ) && dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-$KERNELRPMnew" && \
- dstdir="${dstdir%.rpm}"
- [ -d "$dstdir" ] && rm -rf "$dstdir"
+ local dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}"
+ ( $PATCHLESS ) && dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-$KERNELRPMnew" && \
+ dstdir="${dstdir%.rpm}"
+ [ -d "$dstdir" ] && rm -rf "$dstdir"
mv "${builddir}" "$dstdir" || return 255
+ if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
+ # move the OFED kernel-ib-devel tree as well
+ mv "${builddir%/*}/kernel-ib-devel/usr/src/ofa_kernel" "${dstdir%/*}" || return 255
+ fi
fi
#store kernel rpm
local kernelrpmname="kernel-lustre-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
[ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSNnew}.${TARGET_ARCH}.rpm"
- ( $PATCHLESS ) && [ -f "$KERNELRPM" ] && kernelrpmname="$KERNELRPMnew"
+ ( $PATCHLESS ) && [ -f "$KERNELRPM" ] && kernelrpmname="$KERNELRPMnew"
if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
echo "RPM already exist in store directory tree"
else
else
[ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
fi
+ if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
+ # store kernel-ib RPMs
+ local rpmname
+ for rpmname in "kernel-ib" "kernel-ib-devel"; do
+ rpmname="${rpmname}-${OFED_VERSION}"
+ if $PATCHLESS; then
+ rpmname="${rpmname}-${LINUXRELEASE//-/_}"
+ else
+ rpmname="${rpmname}-${lnxmaj}${EXTRA_VERSION_DELIMITER//-/_}${EXTRA_VERSIONnew}${TARGET_DELIMITER//-/_}${KERNCONFSMPTYPE}"
+ fi
+ rpmname="${rpmname}.${TARGET_ARCH}.rpm"
+ if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${rpmname}" ]; then
+ echo "RPM already exist in store directory tree"
+ else
+ [ -f "RPMS/${TARGET_ARCH}/${rpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${rpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
+ fi
+ done
+ fi
}
set_rpm_smp_type()
done
}
+# This function takes a linux source pool and digs out the linux release
+# from it
+find_linux_release() {
+ local SRCDIR="$1"
+
+ local LINUXRELEASEHEADER=$SRCDIR/include/linux/version.h
+ if [ -s $SRCDIR/include/linux/utsrelease.h ]; then
+ LINUXRELEASEHEADER=$SRCDIR/include/linux/utsrelease.h
+ fi
+
+ sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER
+
+}
+
#unpack kernel(/source/devel) RPM
unpack_linux_rpm()
{
RC=255
else
# dig out the release version
- local LINUXRELEASEHEADER=version.h
- if test -s ${LINUXOBJ:-$LINUX}/include/linux/utsrelease.h ; then
- LINUXRELEASEHEADER=utsrelease.h
- fi
- LINUXRELEASE=$(sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' ${LINUXOBJ:-$LINUX}/include/linux/$LINUXRELEASEHEADER)
+ LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
if [ -z "$LINUXRELEASE" ]; then
- echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}/include/linux/$LINUXRELEASEHEADER"
+ echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
RC=255
fi
fi
reuse_kernel_rpm()
{
local pathtorpm=$1
+ local pathtokernelibrpm=$2
[ "$pathtorpm" = "" ] && return 255
[ -f "$pathtorpm" ] || return 255
[ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
rpm2cpio < $pathtorpm | cpio -idc
[ ${PIPESTATUS[0]} -eq 0 ] || return 255
+ if [ -n "$pathtokernelibrpm" ] && [ -f "$pathtokernelibrpm" ]; then
+ rpm2cpio < $pathtokernelibrpm | cpio -idc
+ [ ${PIPESTATUS[0]} -eq 0 -o ${PIPESTATUS[1]} -eq 0 ] || return 255
+ CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
+ fi
+
local smptype=
if pushd usr/src/linux-*-obj/${TARGET_ARCH}; then
local smptypes="$SMPTYPES"
configure_options="--with-ipath_inf-mod --with-ehca-mod"
;;
esac
+ local K_SRC="K_SRC"
+ # ofed 1.3 had a bug in the rpm spec
+ if [ "$OFED_VERSION" = "1.3" ]; then
+ K_SRC="KSRC"
+ fi
$RPMBUILD --rebuild --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
--define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
--define "KVERSION ${LINUXRELEASE}" \
- --define "KSRC ${LINUXOBJ:-${LINUX}}" \
+ --define "$K_SRC ${LINUXOBJ:-${LINUX}}" \
--define "LIB_MOD_DIR /lib/modules/${LINUXRELEASE}/updates" \
--define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --without-srp-target-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" ${TOPDIR}/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
#build patchless lustre
patchless_build_sequence()
{
+ if [ -f $LINUX/Makefile ]; then
+ # Get the correct kernel release - I'm unsure how this can ever
+ # work otherwise, unless you're using the exact same kernel version
+ # Lustre is shipped with.
+
+ local LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
+ if [ -z "$LINUXRELEASE" ]; then
+ echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
+ RC=255
+ fi
+
+ lnxmaj=$(echo $LINUXRELEASE | cut -f1 -d-)
+ EXTRA_VERSION=$(echo $LINUXRELEASE | cut -f2 -d-)_lustre.$LUSTRE_VERSION
+ RPMSMPTYPE=" "
+ build_lustre && buildsuccess=true
+ else
#try to build from kernel-devel RPM (RHEL)
LINUX=
TARGET_ARCH=
[ -d SOURCES ] || mkdir SOURCES
# first build kernel-ib
- if [ -n "$OFED_VERSION" ]; then
+ if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
$rpmfound && build_kernel_ib
fi
( $rpmfound ) && build_lustre && buildsuccess=true && find_linux_source_rpm
+ fi
if $buildsuccess; then
[ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELRPM" ] && \
cp "$KERNELSOURCERPM" RPMS/${TARGET_ARCH}/
KERNELCOMPILEDIR="$LINUX"
if $storeforreuse; then
- store_for_reuse || echo "Cannot store for feature reuse"
+ store_for_reuse || echo "Cannot store for future reuse"
fi
return
reusedkernelsourcerpm=$(ls ${curdir}/${REUSEDKERNELMASKnew}.rpm | head -1 )
[ -f "$reusedkernelsourcerpm" ] || continue
+ # don't need to check for kernel-ib RPM reuse here because sles9 is not supported
+ # by OFED >= 1.3.0 and this function appears to only be used for sles9
+
[ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
- reuse_kernel_rpm "$reusedkernelsourcerpm" && build_linux nofullmake copyrpmkernel && build_lustre && buildsuccess=true
+ reuse_kernel_rpm "$reusedkernelsourcerpm" "" && build_linux nofullmake copyrpmkernel && build_lustre && buildsuccess=true
( $buildsuccess ) || continue
if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
[ -f "$reusedkernelrpm" ] && \
for curdir in $(echo $dirsforreuse); do
local reusedkernelrpm=
local reusedkernelsourcerpm=
+ local reusedkernelibrpm=
[ -d "$curdir" ] || continue
+ [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" -a
+ ! -d "${curdir%/*}/ofa_kernel" ] && continue
local reusedkernelprefix="kernel-lustre-"
( $PATCHLESS ) && reusedkernelprefix=
[ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
reusedkernelprefix="kernel-lustre-source-"
[ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm ] && \
reusedkernelsourcerpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm | head -1 )
+ if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
+ gen_lustre_version
+ reusedkernelprefix="kernel-ib-"
+ [ -f ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm ] && \
+ reusedkernelibrpm=$(ls ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 )
+ reusedkernelibdevelrpm=$(ls ${curdir}/../${reusedkernelprefix}devel-${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 )
+ fi
if ! ( $NORPM ) && ! [ -f "$reusedkernelrpm" ]; then #kernel rpm not found. Build all
continue
fi
if ! ( $NORPM ) && ! [ -f "$reusedkernelsourcerpm" ]; then #kernel source rpm not found. Build all
continue
fi
+ if [ -n "$OFED_VERSION" ]; then
+ if [ "$OFED_VERSION" != "inkernel" ]; then
+ if ! ( $NORPM ) && [ ! -f "$reusedkernelibrpm" -o ! -f "$reusedkernelibdevelrpm"]; then #kernel-ib{,-devel} rpm not found. Build all
+ continue
+ fi
+ CONFIGURE_FLAGS="--with-o2ib=${curdir%/*}/ofa_kernel ${CONFIGURE_FLAGS}"
+ else
+ CONFIGURE_FLAGS="--with-o2ib=yes ${CONFIGURE_FLAGS}"
+ fi
+ fi
LINUX="$curdir"
build_lustre || continue
touch "$curdir/../"
touch RPMS/${TARGET_ARCH}/kernel_was_reused
[ -f "$reusedkernelsourcerpm" ] && \
cp -f "$reusedkernelsourcerpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
+ [ -f "$reusedkernelibrpm" ] && \
+ cp -f "$reusedkernelibrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
+ cp -f "$reusedkernelibdevelrpm" RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
fi
return
done
[ -r ~/.lbuildrc ] && . ~/.lbuildrc
-options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,src,stage:,tag:,target:,target-archs:,with-linux: -- "$@")
+options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,src,stage:,tag:,target:,target-archs:,with-linux:,xen -- "$@")
if [ $? != 0 ] ; then
usage 1
USE_DATESTAMP=
shift
;;
+ --xen)
+ XEN=true
+ shift
+ ;;
--)
shift
CONFIGURE_FLAGS=$@
load_target
EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
-if [ -n "$OFED_VERSION" ]; then
+if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
unpack_ofed
fi
if ! $build_success; then
build_sequence && build_success=true
if $build_success; then
- store_for_reuse || echo "Cannot store for feature reuse"
+ store_for_reuse || echo "Cannot store for future reuse"
fi
fi
fi