This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=a9ad552d765ac1dbae3cb1d3b05fe4ecd8302baa

commit a9ad552d765ac1dbae3cb1d3b05fe4ecd8302baa
Author: Guillem Jover <[email protected]>
AuthorDate: Mon Jun 29 12:18:34 2020 +0200

    build: Improve error diagnosis for configure version fetching script
    
    Check for git being present and error out otherwise explaining why. And
    improve the fallback error message to mention that this is neither a git
    checkout nor a distribution tarball.
    
    Prompted-by: Norbert Preining <[email protected]>
---
 debian/changelog |  3 +++
 get-version      | 15 ++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9db1f3939..ddfe4f273 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,9 @@ dpkg (1.20.3) UNRELEASED; urgency=medium
       Reported by Mattia Rizzolo <[email protected]>.
   * Code internals:
     - libdpkg: Print a notice if we cannot write to the log file.
+  * Build system:
+    - Improve error diagnosis for configure version fetching script.
+      Prompted by Norbert Preining <[email protected]>.
 
   [ Updated programs translations ]
   * German (Sven Joachim).
diff --git a/get-version b/get-version
index 8b596ffd4..e714be17c 100755
--- a/get-version
+++ b/get-version
@@ -2,7 +2,7 @@
 #
 # get-version
 #
-# Copyright © 2009, 2013-2014 Guillem Jover <[email protected]>
+# Copyright © 2009, 2013-2015, 2018, 2020 Guillem Jover <[email protected]>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,10 +18,20 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #
 
+error()
+{
+  echo "get-version: error: $*" 1>&2
+  exit 1
+}
+
 if [ -f .dist-version ]; then
   # Get the version from the file distributed in the tarball.
   version=$(cat .dist-version)
 elif [ -d .git ] || [ -f .git ]; then
+  if ! command -v git >/dev/null; then
+    error "cannot get project version, git checkout but git program not found"
+  fi
+
   # Get the version from the git repository. Since tags cannot contain colons
   # or tildes, we use percent and underscore instead. Reverse that switch here.
   version=$(git describe --abbrev=4 HEAD 2>/dev/null | tr %_ :~)
@@ -33,8 +43,7 @@ elif [ -d .git ] || [ -f .git ]; then
     version="$version-dirty"
   fi
 else
-  echo "error: cannot get project version." 1>&2
-  exit 1
+  error "cannot get project version, not a git checkout nor a distribution 
tarball."
 fi
 
 # Use printf to avoid the trailing new line that m4_esyscmd would not handle.

-- 
Dpkg.Org's dpkg

Reply via email to