Skip to content

Commit 4a5fab0

Browse files
khos2owrohityadavcloud
authored andcommitted
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.
1 parent 2936cb3 commit 4a5fab0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

packaging/build-deb.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818

19-
#set -e
19+
set -e
2020

2121
#
2222
# This script builds Debian packages for CloudStack and does
@@ -100,8 +100,7 @@ while [ -n "$1" ]; do
100100
esac
101101
done
102102

103-
DCH=$(which dch)
104-
if [ -z "$DCH" ] ; then
103+
if [ -z "$(which dch)" ] ; then
105104
echo -e "dch not found, please install devscripts at first. \nDEB Build Failed"
106105
exit 1
107106
fi
@@ -110,6 +109,17 @@ NOW="$(date +%s)"
110109
PWD=$(cd $(dirname "$0") && pwd -P)
111110
cd $PWD/../
112111

112+
# Fail early if working directory is NOT clean and --use-timestamp was provided
113+
if [ "$USE_TIMESTAMP" == "true" ]; then
114+
if [ -n "$(cd $PWD; git status -s)" ]; then
115+
echo "Erro: You have uncommitted changes and asked for --use-timestamp to be used."
116+
echo " --use-timestamp flag is going to temporarily change POM versions and"
117+
echo " revert them at the end of build, and there's no way we can do partial"
118+
echo " revert. Please commit your changes first or omit --use-timestamp flag."
119+
exit 1
120+
fi
121+
fi
122+
113123
VERSION=$(head -n1 debian/changelog |awk -F [\(\)] '{print $2}')
114124
DISTCODE=$(lsb_release -sc)
115125

@@ -148,4 +158,6 @@ dpkg-buildpackage -uc -us -b
148158

149159
/bin/mv /tmp/changelog.orig debian/changelog
150160

151-
(cd $PWD; git reset --hard)
161+
if [ "$USE_TIMESTAMP" == "true" ]; then
162+
(cd $PWD; git reset --hard)
163+
fi

0 commit comments

Comments
 (0)