rhtyd closed pull request #2649: Catch error in Debian packaging script and 
fail the build
URL: https://github.com/apache/cloudstack/pull/2649
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/packaging/build-deb.sh b/packaging/build-deb.sh
index 52a168a95ba..e8c178350c7 100755
--- a/packaging/build-deb.sh
+++ b/packaging/build-deb.sh
@@ -16,7 +16,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-#set -e
+set -e
 
 #
 # This script builds Debian packages for CloudStack and does
@@ -100,8 +100,7 @@ while [ -n "$1" ]; do
     esac
 done
 
-DCH=$(which dch)
-if [ -z "$DCH" ] ; then
+if [ -z "$(which dch)" ] ; then
     echo -e "dch not found, please install devscripts at first. \nDEB Build 
Failed"
     exit 1
 fi
@@ -110,6 +109,17 @@ NOW="$(date +%s)"
 PWD=$(cd $(dirname "$0") && pwd -P)
 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}')
 DISTCODE=$(lsb_release -sc)
 
@@ -148,4 +158,6 @@ dpkg-buildpackage -uc -us -b
 
 /bin/mv /tmp/changelog.orig debian/changelog
 
-(cd $PWD; git reset --hard)
+if [ "$USE_TIMESTAMP" == "true" ]; then
+    (cd $PWD; git reset --hard)
+fi


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to