Skip to content

Commit d20fa27

Browse files
committed
Catch error in packaging script and fail the build
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 4661daa commit d20fa27

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packaging/build-deb.sh

Lines changed: 15 additions & 2 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,6 +100,17 @@ while [ -n "$1" ]; do
100100
esac
101101
done
102102

103+
# Fail early if working directory is NOT clean and --use-timestamp was provided
104+
if [ "$USE_TIMESTAMP" == "true" ]; then
105+
if [ -n "$(cd $PWD/../; git status -s)" ]; then
106+
echo "Erro: You have uncommitted changes and asked for --use-timestamp to be used."
107+
echo " --use-timestamp flag is going to temporarily change POM versions and"
108+
echo " revert them at the end of build, and there's no way we can do partial"
109+
echo " revert. Please commit your changes first or omit --use-timestamp flag."
110+
exit 1
111+
fi
112+
fi
113+
103114
DCH=$(which dch)
104115
if [ -z "$DCH" ] ; then
105116
echo -e "dch not found, please install devscripts at first. \nDEB Build Failed"
@@ -148,4 +159,6 @@ dpkg-buildpackage -uc -us -b
148159

149160
/bin/mv /tmp/changelog.orig debian/changelog
150161

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

0 commit comments

Comments
 (0)