From 71d2ea0fde17ecde0bf237f486d4bafb5d54fe3f Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Tue, 19 Apr 2016 18:18:41 +0300 Subject: [PATCH] LU-8023 lbuild: add find-requires parameter to rpmbuild If kernel-devel unpacked in not default directory we need to pass modified version of find-requires which can find it. Test-Parameters: mdsdistro=sles11sp4 ossdistro=sles11sp4 \ clientdistro=sles11sp4 mdsfilesystemtype=ldiskfs \ mdtfilesystemtype=ldiskfs ostfilesystemtype=ldiskfs \ testgroup=review-ldiskfs Change-Id: Id30744fe596b1bf690611e9f66dd804219b20fe3 Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/19650 Reviewed-by: Bob Glossman Tested-by: Jenkins Tested-by: Andreas Dilger Reviewed-by: Minh Diep Reviewed-by: Oleg Drokin --- contrib/lbuild/lbuild | 83 +++++++++++++++++++++++++++----------------- contrib/lbuild/lbuild-rhel | 2 +- contrib/lbuild/lbuild-sles | 4 +-- contrib/lbuild/lbuild-sles10 | 10 +++--- 4 files changed, 59 insertions(+), 40 deletions(-) diff --git a/contrib/lbuild/lbuild b/contrib/lbuild/lbuild index 9d6a600..322057e 100755 --- a/contrib/lbuild/lbuild +++ b/contrib/lbuild/lbuild @@ -36,7 +36,7 @@ push_exit_trap "kill -INT -$$ || true" kill_children #BUILD_GEN=5 # TT-107: don't cache the BUILD dir BUILD_GEN=6 # TT-1092: don't cache the BUILD dir, to rebuild external OFED -TOPDIR=$PWD +TOPDIR="$PWD" KERNELDIR= LINUX= @@ -103,8 +103,6 @@ LUSTRE_TESTS=true DATE=$(date) -RPMBUILD= - export CC=${CC:-gcc} # Readlink is not present on some older distributions: emulate it. @@ -333,31 +331,47 @@ check_options() { TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S") fi - RPMBUILD=$(which rpmbuild 2>/dev/null | head -1) - if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then - RPMBUILD=$(which rpm 2>/dev/null | head -1) - if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then - usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)." - fi + local RPMBUILD=$(which rpmbuild 2>/dev/null | head -n 1) + RPMBUILD=${RPMBUILD:-$(which rpm 2>/dev/null | head -n 1)} + if [ -z "$RPMBUILD" ]; then + usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)." fi + local BINDIR="$TOPDIR/bin" + if [ -d $BINDIR ]; then + rm -rf $BINDIR >/dev/null 2>&1 || true + fi + + mkdir -p $BINDIR || fatal 1 "error trying to create $BINDIR" + export PATH=$BINDIR:$PATH + + cat >${BINDIR}/rpmbuild </dev/null && export DISTCC RPM_BUILD_NCPUS if which "$CCACHE" &>/dev/null; then - local ccache=$(which "$CCACHE") - local bindir="$TOPDIR/bin" + local ccache=$(which "$CCACHE" 2>/dev/null | head -n 1) - if [ ! -d $bindir ]; then - mkdir -p $bindir || fatal 1 "error trying to create $bindir" - else - rm ${bindir}/* > /dev/null 2>&1 || true - fi - ln -s "$ccache" ${bindir}/ccache - ln -s "$ccache" ${bindir}/cc - ln -s "$ccache" ${bindir}/$CC - export PATH=$bindir:$PATH - export CCACHE && export CC="ccache $CC" + ln -s "$ccache" ${BINDIR}/ccache + ln -s "$ccache" ${BINDIR}/cc + ln -s "$ccache" ${BINDIR}/$CC + + export CCACHE + export CC="ccache $CC" # zero the cache so we can see how effective we are being with it echo -n "ccache " ccache -z @@ -370,7 +384,6 @@ check_options() { fi return 0 - } # compare two versions $1 and $2. if $1 < $2, return 0 otherwise return 1. @@ -836,17 +849,24 @@ build_lustre() { # Only zfs Lustre DKMS Server is supported build_lustre_dkms() { + local build_args="" + local name_prefix="lustre" local ver=$(sed -n -e 's/^LUSTRE_VERSION = //p' LUSTRE-VERSION-FILE) + echo "Building Lustre DKMS RPMs for: $BUILD_ARCHS..." - ./configure --enable-dist || return 255 + ./configure --enable-dist || fatal 1 "Error in DKMS configure." if $PATCHLESS; then - $RPMBUILD --define="_topdir $TOPDIR" --without servers -bs lustre-dkms.spec || return 255 - $RPMBUILD --rebuild --define="_topdir $TOPDIR" --without servers $TOPDIR/SRPMS/lustre-client-dkms-$ver-*.src.rpm || return 255 - else - $RPMBUILD --define="_topdir $TOPDIR" -bs lustre-dkms.spec || return 255 - $RPMBUILD --rebuild --define="_topdir $TOPDIR" $TOPDIR/SRPMS/lustre-dkms-$ver-*.src.rpm || return 255 + build_args="--without servers" + name_prefix="lustre-client" fi + + rpmbuild --define "_topdir $TOPDIR" $build_args -bs lustre-dkms.spec || + fatal 1 "Error building DKMS .src.rpm for $BUILD_ARCHS." + rpmbuild --define "_topdir $TOPDIR" $build_args \ + --rebuild $TOPDIR/SRPMS/$name_prefix-dkms-$ver-*.src.rpm || + fatal 1 "Error building DKMS .rpm for $BUILD_ARCHS." + return 0 } @@ -935,7 +955,7 @@ build_spl_zfs() { # Manually build rpms for spec in $speclist; do echo "Building RPMs from $pkg/$specdir/$spec" - if ! $RPMBUILD $rpmb $pkg/$specdir/$spec \ + if ! rpmbuild $rpmb $pkg/$specdir/$spec \ --nodeps -v \ --define "require_kdir ${LINUX}" \ ${LINUXOBJ:+--define "require_kobj ${LINUXOBJ}"} \ @@ -1172,8 +1192,7 @@ EOF if compare_version $OFED_VERSION 3.0; then local OFA_KERNEL_RELEASE=$(echo -n ${linuxrelease} | sed -e 's/-/_/g') fi - if ! $RPMBUILD $BUILD_TYPE --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \ - ${FIND_REQUIRES:+--define "__find_requires $FIND_REQUIRES"} \ + if ! rpmbuild $BUILD_TYPE --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \ --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \ --define "KVERSION ${linuxrelease}" \ --define "$K_SRC ${linux}" \ @@ -1566,7 +1585,7 @@ build_with_srpm() { # infrastructure files so that find-requires can find our unpacked # kernel-devel artifacts cp $RPM_HELPERS_DIR/{symset-table,find-requires{,.ksyms}} . - FIND_REQUIRES="$(pwd)/find-requires" + export FIND_REQUIRES="$(pwd)/find-requires" chmod 755 {symset-table,find-requires{,.ksyms}} local tmp="$(pwd)" tmp="${tmp//\//\\/}" diff --git a/contrib/lbuild/lbuild-rhel b/contrib/lbuild/lbuild-rhel index 0015042..8f20270 100644 --- a/contrib/lbuild/lbuild-rhel +++ b/contrib/lbuild/lbuild-rhel @@ -102,7 +102,7 @@ prepare_and_build_srpm() { rpmbuildopt="$rpmbuildopt $(get_rpmbuildopts)" # now build it - if ! eval $RPMBUILD $rpmbuildopt $targets --with baseonly \ + if ! eval rpmbuild $rpmbuildopt $targets --with baseonly \ --define \"_topdir $TOPDIR\" \ --define \"buildid $buildid\" \ --define \"_tmppath $TMPDIR\" \ diff --git a/contrib/lbuild/lbuild-sles b/contrib/lbuild/lbuild-sles index eba78f5..435e88b 100644 --- a/contrib/lbuild/lbuild-sles +++ b/contrib/lbuild/lbuild-sles @@ -44,7 +44,7 @@ prepare_and_build_srpm() { # landing. #if false; then # now build it - if ! $RPMBUILD $rpmbuildopt $targets \ + if ! rpmbuild $rpmbuildopt $targets \ --define "_topdir $TOPDIR" \ $TOPDIR/SOURCES/kernel-$RPMSMPTYPE.spec 2>&1; then fatal 1 "Failed to build kernel RPM" @@ -52,7 +52,7 @@ prepare_and_build_srpm() { #fi # for SLES, we also need to build the kernel-source rpm - if ! $RPMBUILD $rpmbuildopt $targets \ + if ! rpmbuild $rpmbuildopt $targets \ --define "_topdir $TOPDIR" \ $TOPDIR/SOURCES/kernel-source.spec 2>&1; then fatal 1 "Failed to build kernel source RPM" diff --git a/contrib/lbuild/lbuild-sles10 b/contrib/lbuild/lbuild-sles10 index a1a2964..2d3a04f 100644 --- a/contrib/lbuild/lbuild-sles10 +++ b/contrib/lbuild/lbuild-sles10 @@ -176,11 +176,11 @@ EOF for arch in $BUILD_ARCHS; do targets="--target $(resolve_arch $arch $PATCHLESS) $targets" done - if ! $RPMBUILD --rebuild --nodeps $targets \ - --define "symsetsdir ${TOPDIR}/reused/boot" \ - --define "kobjdir ${LINUXOBJ%/*/*}" \ - --define "_tmppath /var/tmp" \ - --define "_topdir ${TOPDIR}" \ + if ! rpmbuild --rebuild --nodeps $targets \ + --define "symsetsdir ${TOPDIR}/reused/boot" \ + --define "kobjdir ${LINUXOBJ%/*/*}" \ + --define "_tmppath /var/tmp" \ + --define "_topdir ${TOPDIR}" \ ${SOURCE} 2>&1; then rm ~/.rpmmacros if [ -n "$tmpfile" ]; then -- 1.8.3.1