commit:     68a3161955bad21eb9a2a865159858b0d823e6ac
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  8 11:12:21 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Feb  8 11:15:31 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=68a31619

make-tarball: ensure a release tag really represents the distributed tarball

For repeatible/verifyable releases, commit the exact content we're
zipping up as part of the release tag, and just undo unwanted changes
afterwards.

This also means we don't rebuild gnulib stuff, the version of code in
the repo now should be updated as required using autogen.sh.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 make-tarball.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 59 insertions(+), 12 deletions(-)

diff --git a/make-tarball.sh b/make-tarball.sh
index 22ab9109..75581cb0 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -16,14 +16,20 @@ if [[ $# -ne 1 ]] ; then
        die "Usage: $0 <ver>"
 fi
 
+PUSH=
 case $1 in
 snap) ver=$(date -u +%Y%m%d) ;;
 git) ver="HEAD" ;;
 *)
        ver="v$1"
-       if ! git describe --tags "${ver}" >&/dev/null ; then
-               die "Please create the tag first: git tag ${ver}"
+       if git describe --tags "${ver}" >&/dev/null ; then
+               die "Tag ${ver} already exists!"
        fi
+       PUSH=yes
+       # grab current tree credentials to commit with
+       GIT_AUTHOR_NAME=$(git config user.name)
+       GIT_AUTHOR_EMAIL=$(git config user.email)
+       SIGING_KEY=$(git config user.signingkey)
        ;;
 esac
 p="${TMPDIR:-/var/tmp}/portage-utils-${ver#v}"
@@ -35,34 +41,75 @@ rm -rf "${pb}"
 mkdir "${pb}"
 
 einfo "Checking out clean git sources ..."
-git archive "${ver}" | tar xf - -C "${p}"
+HERE=${PWD}
 pushd "${p}" >/dev/null
+git clone "${HERE}"
+pt=${p}/${HERE##*/}
+popd >/dev/null
+
+einfo "Adapting configure for release ${ver} ..."
+pushd "${pt}" >/dev/null
+sed -e "1s/2011-20[0-9][0-9]/2011-$(date +%Y)/" \
+    -e "/^AC_INIT/s:\[git\(-.*\)\?\]:[${ver#v}]:" \
+       -e "/^AM_MAINTAINER_MODE/s:\[enable\]:[disable]:" \
+       configure.ac \
+       | diff -u \
+               --label "git/configure.ac" \
+               --label "${ver#v}/configure.ac" \
+               configure.ac - \
+       | tee "${pb}/configure.diff" \
+       | patch -p1
+cat "${pb}/configure.diff"
 
-einfo "Building autotools ..."
-sed -i "/^AC_INIT/s:git:${ver#v}:" configure.ac
-sed -i "/^AM_MAINTAINER_MODE/s:(.*)$::" configure.ac
-./autogen.sh
+einfo "Rebuilding autotools ..."
+export AUTOMAKE="automake --foreign"
+v autoreconf -i -f
 rm -rf autom4te.cache
 popd >/dev/null
 
 einfo "Checking sources ..."
 pushd "${pb}" >/dev/null
-tar cf - -C "${p}" . | tar xf -
+tar cf - -C "${pt}" . | tar xf -
 v ./configure -q
 v ${MAKE} -s
 v ${MAKE} -s check
 v ${MAKE} -s DESTDIR="${PWD}"/install install
 v ./man/mkman.py
 # ensure the tar contains up-to-date manpages
-cp -a man/*.1 "${p}"/man
+cp -a man/*.1 "${pt}"/man
 popd >/dev/null
 rm -rf "${pb}"
 
+einfo "Creating release commit + tag ..."
+pushd "${pt}" >/dev/null
+git config user.name "${GIT_AUTHOR_NAME}"
+git config user.email "${GIT_AUTHOR_EMAIL}"
+git config user.signingkey "${SIGING_KEY}"
+git add -f man/*.1
+git commit --signoff -am "version bump to ${ver#v}" || die
+git tag "${ver}" || die
+popd >/dev/null
+
 einfo "Generating tarball ..."
-pushd "${p%/*}" >/dev/null
-tar --numeric-owner -cf - "${p##*/}" | xz > "${p}".tar.xz
+pushd "${pt%/*}" >/dev/null
+tar --numeric-owner -cf - "${pt##*/}" | xz > "${p}".tar.xz
 popd >/dev/null
-rm -r "${p}"
+
+einfo "Reverting for development ..."
+pushd "${pt}" >/dev/null
+sed -i \
+       -e "/^AC_INIT/s:\[${ver#v}\]:[git-post-${ver#v}]:" \
+       -e "/^AM_MAINTAINER_MODE/s:\[disable\]:[enable]:" \
+       configure.ac || die
+git rm -f man/*.1
+v autoreconf -i -f
+git commit --signoff -am "configure.ac: restoring maintainer mode"
+popd >/dev/null
+
+if [[ x${PUSH} == xyes ]] ; then
+       git pull "${pt}"
+fi
+rm -rf "${p}"
 
 echo
 einfo "All ready for distribution!"

Reply via email to