[ -z "$dist" ] && echo no dist && exit 1
echo dist $dist
-vers=$(./version.sh)
-chacra_ref="$BRANCH"
-
-chacra_endpoint="diamond/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}"
-chacra_check_url="${chacra_endpoint}/${ARCH}/diamond-${vers}-0.${DIST}.${ARCH}.rpm"
-
+chacra_endpoint="diamond/${BRANCH}/${SHA1}/${DISTRO}/${RELEASE}"
+chacra_check_url="${chacra_endpoint}/${ARCH}/diamond-${VERSION}-0.${DIST}.${ARCH}.rpm"
if [ "$THROWAWAY" = false ] ; then
# this exists in scripts/build_utils.sh
env
echo "*****"
-# Create the spec file and install the dependencies
-sed -e "s/@VERSION@/${vers}/g" < diamond.spec.in > diamond.spec
-yum-builddep -y diamond.spec
+# Install the dependencies
+sudo yum-builddep -y dist/diamond.spec
# Create the source rpm
echo "Building SRPM"
-rpmbuild \
- --define "_sourcedir $PWD/dist" \
- --define "_specdir $PWD" \
- --define "_builddir $PWD" \
- --define "_srcrpmdir $PWD" \
- --define "_rpmdir $PWD" \
+rpmbuild \
+ --define "_sourcedir ./dist" \
+ --define "_specdir ." \
+ --define "_builddir ." \
+ --define "_srcrpmdir ." \
+ --define "_rpmdir ." \
--define "dist .any" \
--define "fedora 21" \
--define "rhel 7" \
- --nodeps -bs diamond.spec
+ --nodeps -bs dist/diamond.spec
SRPM=$(readlink -f *.src.rpm)
-
# Build the binaries
echo "Building RPMs"
sudo mock -r epel-${RELEASE}-${ARCH} --resultdir=./dist/rpm/"%(dist)s"/"%(target_arch)s"/ ${SRPM}
-
# Make sure we execute at the top level directory
cd "$WORKSPACE"
echo "Building version $(git describe) Branch $BRANCH"
+# Make sure the dist directory is clean
rm -rf dist
+mkdir -p dist
+# Install any setup-time deps
if [ -x install-deps.sh ]; then
echo "Ensuring dependencies are installed"
./install-deps.sh
fi
+# Make sure the repo is clean
echo "Cleaning up the repo"
git clean -fxd
echo "Building source distribution"
python setup.py sdist
+
+# Prepare the spec file for build
+sed -e "s/@VERSION@/${vers}/g" < diamond.spec.in > dist/diamond.spec
+
+# Save these so that we can later inject them into the build script
+cat > dist/sha1 << EOF
+SHA1=${GIT_COMMIT}
+EOF
+
+cat > dist/branch << EOF
+BRANCH=${BRANCH}
+EOF
+
+cat > dist/version << EOF
+VERSION=$(./version.sh)
+EOF