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

guillem pushed a commit to branch main
in repository dpkg.

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

commit 54a6ad9db3da335a40fed9020195864c4a87bdc1 (HEAD -> main)
Author: Guillem Jover <[email protected]>
AuthorDate: Mon Apr 1 16:43:48 2024 +0200

    build: Add support to track release VCS commit id
    
    This adds a provenance trail from the upstream VCS commit the tarball
    was supposedly generated from, so that it can be traced by interested
    downstreams.
---
 Makefile.am                           |  2 ++
 build-aux/.gitignore                  |  1 +
 build-aux/{get-version => get-vcs-id} | 25 ++++++++++++-------------
 configure.ac                          |  2 ++
 t/shellcheck.t                        |  1 +
 5 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 18da50745..8fed921ab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -62,6 +62,7 @@ EXTRA_DIST = \
        autogen \
        build-aux/gen-changelog \
        build-aux/gen-release \
+       build-aux/get-vcs-id \
        build-aux/get-version \
        build-aux/lcov-inject \
        build-aux/run-script \
@@ -241,6 +242,7 @@ include $(top_srcdir)/build-aux/cpan.am
 # to regular files due to automake telling tar to dereference them.
 dist-hook:
        echo $(VERSION) >$(distdir)/.dist-version
+       echo $(PACKAGE_VCS_ID) >$(distdir)/.dist-vcs-id
        if [ -e .git ]; then \
          for file in `git ls-tree -r HEAD | grep ^12 | grep -v 
t/origins/default`; do \
            echo "$$file is a symlink packed as a file on the dist tar" >&2 ; \
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
index 4cbb98857..5ec0cc12d 100644
--- a/build-aux/.gitignore
+++ b/build-aux/.gitignore
@@ -2,6 +2,7 @@
 !*.am
 !gen-changelog
 !gen-release
+!get-vcs-id
 !get-version
 !lcov-inject
 !run-script
diff --git a/build-aux/get-version b/build-aux/get-vcs-id
similarity index 59%
copy from build-aux/get-version
copy to build-aux/get-vcs-id
index e714be17c..cca511a06 100755
--- a/build-aux/get-version
+++ b/build-aux/get-vcs-id
@@ -1,8 +1,8 @@
 #!/bin/sh
 #
-# get-version
+# get-vcs-id
 #
-# Copyright © 2009, 2013-2015, 2018, 2020 Guillem Jover <[email protected]>
+# Copyright © 2009-2024 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
@@ -20,31 +20,30 @@
 
 error()
 {
-  echo "get-version: error: $*" 1>&2
+  echo "get-vcs-id: error: $*" 1>&2
   exit 1
 }
 
-if [ -f .dist-version ]; then
-  # Get the version from the file distributed in the tarball.
-  version=$(cat .dist-version)
+if [ -f .dist-vcs-id ]; then
+  # Get the VCS id from the file distributed in the tarball.
+  id="$(cat .dist-vcs-id)"
 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"
+    error "cannot get project VCS id, 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 %_ :~)
+  # Get the VCS id from the git repository.
+  id="$(git rev-list -1 HEAD 2>/dev/null)"
 
   # Check if we are on a dirty checkout.
   git update-index --refresh -q >/dev/null
   dirty=$(git diff-index --name-only HEAD 2>/dev/null)
   if [ -n "$dirty" ]; then
-    version="$version-dirty"
+    id="$id-dirty"
   fi
 else
-  error "cannot get project version, not a git checkout nor a distribution 
tarball."
+  error "cannot get project VCS id, not a git checkout nor a distribution 
tarball."
 fi
 
 # Use printf to avoid the trailing new line that m4_esyscmd would not handle.
-printf "%s" "$version"
+printf "%s" "$id"
diff --git a/configure.ac b/configure.ac
index 47b7b3994..36db52e71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,6 +8,7 @@ AC_INIT([dpkg], m4_esyscmd([build-aux/get-version]),
         [https://wiki.debian.org/Teams/Dpkg])
 DPKG_DIST_IS_RELEASE
 AC_SUBST([PACKAGE_COPYRIGHT_HOLDER], ['Dpkg Developers'])
+AC_SUBST([PACKAGE_VCS_ID], m4_esyscmd([build-aux/get-vcs-id]))
 AC_SUBST([PACKAGE_VCS_TYPE], [git])
 AC_SUBST([PACKAGE_VCS_URL], [https://git.dpkg.org/git/dpkg/dpkg.git])
 AC_SUBST([PACKAGE_VCS_WEB], [https://git.dpkg.org/cgit/dpkg/dpkg.git])
@@ -274,6 +275,7 @@ cat <<CONFIG
 
 Release:
   Version . . . . . : $PACKAGE_VERSION
+  VCS id  . . . . . : $PACKAGE_VCS_ID
 
 Configuration:
   Arch attributes:
diff --git a/t/shellcheck.t b/t/shellcheck.t
index 6afc1fb69..12858ecd3 100644
--- a/t/shellcheck.t
+++ b/t/shellcheck.t
@@ -34,6 +34,7 @@ my @todofiles = qw(
 my @files = qw(
     autogen
     build-aux/gen-release
+    build-aux/get-vcs-id
     build-aux/get-version
     build-aux/run-script
     debian/dpkg.cron.daily

-- 
Dpkg.Org's dpkg

Reply via email to