}
+build_lipe() {
+ local source="$1"
+ local lustre_install_root
+ local lustre_rpm=''
+ local name
+
+ # Find the lustre rpm
+ for rpm in ${source}/*.rpm; do
+ name=$(rpm --query --queryformat '%{NAME}\n' --package "$rpm")
+ if [[ "$name" == "lustre-devel" ]]; then
+ lustre_rpm="$rpm"
+ break
+ fi
+ done
+
+ if [[ "$lustre_rpm" == "" ]]; then
+ echo "cannot find lustre RPM" >&2
+ return 255
+ fi
+
+ # Extract headers and liblustreapi.so from lustre RPM for build.
+ lustre_install_root=$(mktemp -d ${TOPDIR}/root.XXXXXXXX)
+ pushd $lustre_install_root > /dev/null
+ rpm2cpio $lustre_rpm | cpio -idv
+ popd > /dev/null
+
+ # since lipe is not included in 'make dist', we have to assume two places
+ # user copy lipe to current directory
+ # lipe exist in one uppper directory
+ if [[ -d ${TOPDIR}/../lipe ]]; then
+ pushd ${TOPDIR}/../lipe > /dev/null
+ elif [[ -d {TOPDIR}/lipe ]]; then
+ pushd ${TOPDIR}/lipe > /dev/null
+ else
+ fatal 1 "Can not find lipe source"
+ fi
+
+ sh autogen.sh
+
+ CPPFLAGS="\
+ -I${lustre_install_root}/usr/include/linux/lnet \
+ -I${lustre_install_root}/usr/include/linux/lustre \
+ -I${lustre_install_root}/usr/include/lustre \
+ -I${lustre_install_root}/usr/include \
+ " \
+ LDFLAGS="\
+ -L${lustre_install_root}/usr/lib64 \
+ " \
+ ./configure || fatal 1 "Error in configure lipe."
+
+ make rpms || fatal 1 "Error building rpms for lipe"
+ mv -f build/RPMS/${TARGET_ARCH}/lipe*.rpm $TOPDIR/RPMS/${TARGET_ARCH}/
+ popd > /dev/null
+}
+
build_lustre() {
local linux="$1"
local linuxobj="$2"
mv -f lustre-*.src.rpm $TOPDIR/SRPMS/
popd >/dev/null
+
+ if [ $PATCHLESS == false ] && ! build_lipe $TOPDIR/RPMS/${TARGET_ARCH}; then
+ return 255
+ fi
if type -p cleanup_rpmmacros; then
cleanup_rpmmacros
fi