packaging: Catch error in packaging script and fail the build (#2649)

This is to fix the regression added in #2433. In this fix
we're going to fail the build early if --use-timestamp is
provided and working directory is *not* clean. And also
fail the build if something in the script has returned
non-zero value.
This commit is contained in:
Khosrow Moossavi 2018-07-13 07:17:34 -04:00 committed by Rohit Yadav
parent 2936cb3b41
commit 4a5fab0573

View File

@ -16,7 +16,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
#set -e set -e
# #
# This script builds Debian packages for CloudStack and does # This script builds Debian packages for CloudStack and does
@ -100,8 +100,7 @@ while [ -n "$1" ]; do
esac esac
done done
DCH=$(which dch) if [ -z "$(which dch)" ] ; then
if [ -z "$DCH" ] ; then
echo -e "dch not found, please install devscripts at first. \nDEB Build Failed" echo -e "dch not found, please install devscripts at first. \nDEB Build Failed"
exit 1 exit 1
fi fi
@ -110,6 +109,17 @@ NOW="$(date +%s)"
PWD=$(cd $(dirname "$0") && pwd -P) PWD=$(cd $(dirname "$0") && pwd -P)
cd $PWD/../ cd $PWD/../
# Fail early if working directory is NOT clean and --use-timestamp was provided
if [ "$USE_TIMESTAMP" == "true" ]; then
if [ -n "$(cd $PWD; git status -s)" ]; then
echo "Erro: You have uncommitted changes and asked for --use-timestamp to be used."
echo " --use-timestamp flag is going to temporarily change POM versions and"
echo " revert them at the end of build, and there's no way we can do partial"
echo " revert. Please commit your changes first or omit --use-timestamp flag."
exit 1
fi
fi
VERSION=$(head -n1 debian/changelog |awk -F [\(\)] '{print $2}') VERSION=$(head -n1 debian/changelog |awk -F [\(\)] '{print $2}')
DISTCODE=$(lsb_release -sc) DISTCODE=$(lsb_release -sc)
@ -148,4 +158,6 @@ dpkg-buildpackage -uc -us -b
/bin/mv /tmp/changelog.orig debian/changelog /bin/mv /tmp/changelog.orig debian/changelog
(cd $PWD; git reset --hard) if [ "$USE_TIMESTAMP" == "true" ]; then
(cd $PWD; git reset --hard)
fi