From 7971dec12f82b2a1bc8a9ce7395c889e43ee6fd3 Mon Sep 17 00:00:00 2001
From: brian <brian>
Date: Sun, 27 Aug 2006 14:12:24 +0000
Subject: [PATCH] Try to avoid a race where two rpmbuilds on the same node are
 trying to stage the same rpm -- which ends up happening in the same
 directory. In order for this race avoidance to work, the caller has to supply
 a unique TMPDIR which rpmbuild will use at it's _tmpdir. Default to /var/tmp
 if not supplied.

---
 build/lbuild | 4 ++++
 build/lmake  | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/build/lbuild b/build/lbuild
index 09266e2c30..cfdc8a0b8f 100755
--- a/build/lbuild
+++ b/build/lbuild
@@ -18,6 +18,7 @@ CONFIGURE_FLAGS=
 EXTERNAL_PATCHES=
 EXTRA_VERSION=
 STAGEDIR=
+TMPDIR=${TMPDIR:-"/var/tmp"}
 
 # from target file
 KERNEL=
@@ -545,11 +546,13 @@ build_kernel()
     done
 
     $RPMBUILD $targets -bb lustre-kernel-2.4.spec \
+        --define "_tmpdir $TMPDIR" \
         --define "_topdir $TOPDIR" || \
         fatal 1 "Error building rpms for $BUILD_ARCHS."
 
     if (( $DO_SRC )) ; then
         $RPMBUILD -bs lustre-kernel-2.4.spec \
+            --define "_tmpdir $TMPDIR" \
             --define "_topdir $TOPDIR" || \
             fatal 1 "Error building .src.rpm."
     fi
@@ -575,6 +578,7 @@ build_lustre()
     ./configure "--with-linux=${LINUX}" ${CONFIGURE_FLAGS}
 
     $RPMBUILD $targets -bb build/lustre.spec \
+        --define "_tmpdir $TMPDIR" \
         --define "_topdir $TOPDIR" || \
         fatal 1 "Error building rpms for $BUILD_ARCHS."
 
diff --git a/build/lmake b/build/lmake
index 0c195c0f10..4aa15d2202 100755
--- a/build/lmake
+++ b/build/lmake
@@ -10,6 +10,7 @@ TARGET_ARCH=
 TARGET_CONFIG=
 JOBS=1
 CONFIGURE_FLAGS=
+TMPDIR=${TMPDIR:-"/var/tmp"}
 
 # commands to run
 BUILD_LUSTRE=0
@@ -492,6 +493,7 @@ build_lustre()
 	< build/lustre.spec.in \
 	> build/lustre.spec
     $RPMBUILD --target ${TARGET_ARCH} -bb build/lustre.spec \
+        --define "_tmpdir $TMPDIR" \
 	--define "_topdir $(lbuild_topdir)" || \
 	fatal 1 "Error building Lustre rpms."
     # $MAKE_J "$MAKE_CC" || fatal 1 "Error building Lustre."
-- 
GitLab