Ceph build script improvements to prevent needless rebuilds

Problem: The file $SRC_DIR/src/.git_version is created by the
custom build script and is not cleaned upon exit.  The presence
of the new file under $SRC_DIR will trigger a rebuild on the
next iteration.

Solution: Add a cleanup of the file to cover the normal exit case.
This means $SRC_DIR/src/.git_version will not be present at the
start of the next build.

Problem: A lot of tarballs are copied into the build by the
build script, rather than being listed in the COPY_LIST.  This
breaks the md5 checksum mechanism used to determine if a rebuild
is required.  A change to a tarball will be ignored and not
trigger a rebuild.

Solution: Move the code that generates the list of input tarballs
into build_srpm.data.  The file is sourced, so COPY_LIST can
be populated dynamically.

Problem: Script returns success when rpmbuild fails.

Solution: Propogate the error code to the final exit.

Change-Id: I2e760c24ecd3ce2d237863b948863c2a876d24fa
Closes-Bug: 1830130
Co-authored-by: Shuicheng Lin <shuicheng.lin@intel.com>
Signed-off-by: Scott Little <scott.little@windriver.com>
This commit is contained in:
Scott Little 2019-05-22 16:48:06 -04:00
parent 6bd45c96dd
commit 663edb4567
2 changed files with 50 additions and 28 deletions

View File

@ -249,22 +249,16 @@ if [[ ! -f "$SPEC_PATH" ]]; then
exit 1
fi
BOOST_TAR=$(sed -n 's/^Source.*:\s*\(boost_.*\.tar\.bz2\)/\1/p' "$SPEC_PATH")
echo "ceph customization build_srpm : copy boost library ${DOWNLOADS_DIR}/${BOOST_TAR}to $SOURCE_PATH"
cp "${DOWNLOADS_DIR}/${BOOST_TAR}" "$SOURCE_PATH"
for submodule in $(sed -n 's/^Source.*:\s*\(.*\.tar\.gz\)/\1/p' "$SPEC_PATH"); do
echo "ceph customization build_srpm : copy submodule ${DOWNLOADS_DIR}/$(basename ${submodule}) $SOURCE_PATH"
cp "${DOWNLOADS_DIR}/$(basename ${submodule})" "$SOURCE_PATH"
done
RELEASE=`spec_find_tag Release "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: ceph customiztion build_srpm (${LINENO}): 'Release' not found in '$SPEC_PATH'"
fi
NAME=`spec_find_tag Name "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: ceph customization build_srpm (${LINENO}): 'Name' not found in '$SPEC_PATH'"
fi
SRPM="$NAME-$VERSION-$RELEASE.src.rpm"
SRPM_PATH="$BUILD_DIR/SRPMS/$SRPM"
@ -284,6 +278,7 @@ else
BUILD_NEEDED=1
fi
RC=0
if [ $BUILD_NEEDED -gt 0 ]; then
echo "ceph customization build_srpm : ceph spec file : $SPEC_PATH"
echo "ceph customization build_srpm : SRPM build directory : $BUILD_DIR"
@ -296,6 +291,13 @@ ls -la $SOURCE_PATH
echo "ceph customization build_srpm : start to build ceph SRPM "
rpmbuild -bs $SPEC_PATH --define="%_topdir $BUILD_DIR" --undefine=dist --define="_tis_dist .tis"
RC=$?
else
echo "SRPM build not needed"
fi
# .git_version file is generated for ceph build.
# Remove this file after srpm is generated, to avoid srpm rebuild is triggered next time.
\rm -f ${SRC_DIR}/src/.git_version
exit $RC

View File

@ -1,6 +1,26 @@
SRC_DIR="$CGCS_BASE/git/ceph"
DOWNLOADS_DIR="$CGCS_BASE/downloads"
SRC_DIR="$STX_BASE/git/ceph"
DOWNLOADS_DIR="$STX_BASE/downloads"
COPY_LIST="files/* $DISTRO/patches/*"
# Add to COPY_LIST any tarballs listed in spec
CEPH_SPEC_PATH="$PKG_BASE/$DISTRO/ceph.spec"
BOOST_TAR=$(sed -n 's/^Source.*:\s*\(boost_.*\.tar\.bz2\)/\1/p' "$CEPH_SPEC_PATH")
echo "ceph COPY_LIST, adding ${DOWNLOADS_DIR}/$BOOST_TAR"
COPY_LIST+=" ${DOWNLOADS_DIR}/$BOOST_TAR"
for submodule in $(grep 'Source[0-9]*:.*[.]tar[.]gz' "$CEPH_SPEC_PATH" | \
grep -v Source0: | \
sed 's/^Source.*:\s*\(.*\.tar\.gz\)/\1/'); do
echo "ceph COPY_LIST, adding ${DOWNLOADS_DIR}/$(basename ${submodule})"
COPY_LIST+=" ${DOWNLOADS_DIR}/$(basename ${submodule})"
done
# Before we exit, remove the .git_version file that is created by the build,
# and might be left behind by a prior aborted build.
if [ -f ${SRC_DIR}/src/.git_version ]; then
\rm ${SRC_DIR}/src/.git_version
fi
TIS_BASE_SRCREV=02899bfda814146b021136e9d8e80eba494e1126
TIS_PATCH_VER=GITREVCOUNT+1
BUILD_IS_BIG=40