diff mbox series

[bug#70380,v3,1/4] maint: Cater for running `make dist' from tarball.

Message ID 9dd6e4436bcc0639cbbae2d468e5bc3760d73aa3.1713340673.git.janneke@gnu.org
State New
Headers show
Series Reproducible `make dist' tarball: Avoid override stamp-N warnings. | expand

Commit Message

Janneke Nieuwenhuizen April 17, 2024, 9:53 a.m. UTC
* Makefile.am (in_git_p): New variable.  Use it to disable Autotools'
cache consistency assert and removal when bulding from tarball.
(dist): Depend on doc-pot-update again when building from tarball.
(dist-hook): Remove dependencies on gen-ChangeLog and gen-AUTHORS when
building from tarball.
(gen-ChangeLog, gen-AUTHORS): Remove guarding for building from tarball.
Use set -e to avoid silently failing.
(gen-tarball-version): Use $(SOURCE_DATE_EPOCH) instead of re-generating it
using git; this also works running from a tarball.

Change-Id: I9ebdd28a70837f6a4db610c4816bb283d176e2d9
---
 Makefile.am | 61 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 36 insertions(+), 25 deletions(-)

Comments

pelzflorian (Florian Pelz) April 17, 2024, 3:37 p.m. UTC | #1
Hello Jan.  Thank you for fixing “make dist” from a tarball, which
admittedly is far-fetched.  However, “make” from a tarball is not
actually fixed / catered for and is essential.

[100%] GUILEC   guix/scripts/discover.go
[100%] GUILEC   guix/scripts/offload.go
  HELP2MAN doc/guix-daemon.1
make[2]: *** No rule to make target 'etc/git/pre-push', needed by '.git/hooks/pre-push'.  Stop.
make[2]: Leaving directory '/home/florian/guix-1.3.0.58013-5dfeb'
make[1]: *** [Makefile:6304: all-recursive] Error 1
make[1]: Leaving directory '/home/florian/guix-1.3.0.58013-5dfeb'
make: *** [Makefile:4371: all] Error 2

I suppose it is not actually your fault, but since you know how to fix
it, would you fix it?

Note that the non-fatal “./bootstrap” errors from tarball (sh: line 1:
build-aux/git-version-gen: No such file or directory ) are not fixed
either, but they are not fatal.

Janneke Nieuwenhuizen <janneke@gnu.org> writes:
> +dist: doc-pot-update
> +$(warning Not using Git, tarball will likely be irreproducible!)

I get this warning when running “make” from a tarball, not only “make
dist”.  However (!) “make dist” from the same (rebuilt reproducibly from
the git repo with your patches) tarball on another machine is in my case
perfectly reproducible, so could you just drop the warning?


Thank you for making Guix more secure.

Regards,
Florian
Janneke Nieuwenhuizen April 17, 2024, 7:02 p.m. UTC | #2
pelzflorian (Florian Pelz) writes:

Hello Florian,

> Hello Jan.  Thank you for fixing “make dist” from a tarball, which
> admittedly is far-fetched.  However, “make” from a tarball is not
> actually fixed / catered for and is essential.

Ouch, how did I miss that?

> [100%] GUILEC   guix/scripts/discover.go
> [100%] GUILEC   guix/scripts/offload.go
>   HELP2MAN doc/guix-daemon.1
> make[2]: *** No rule to make target 'etc/git/pre-push', needed by '.git/hooks/pre-push'.  Stop.
> make[2]: Leaving directory '/home/florian/guix-1.3.0.58013-5dfeb'
> make[1]: *** [Makefile:6304: all-recursive] Error 1
> make[1]: Leaving directory '/home/florian/guix-1.3.0.58013-5dfeb'
> make: *** [Makefile:4371: all] Error 2
>
> I suppose it is not actually your fault, but since you know how to fix
> it, would you fix it?

Ah, indeed.  It was broken almost a year ago.  Your suggestion makes
much sense to me, so I'm including a new patch in V4 to address this.

It required moving in_git_p from GNU make to to configure.ac and
introducing it earlier.

> Note that the non-fatal “./bootstrap” errors from tarball (sh: line 1:
> build-aux/git-version-gen: No such file or directory ) are not fixed
> either, but they are not fatal.

Yes, I don't know what to do about it.  Looks like an Autotools bug to
me.

> Janneke Nieuwenhuizen <janneke@gnu.org> writes:
>> +dist: doc-pot-update
>> +$(warning Not using Git, tarball will likely be irreproducible!)
>
> I get this warning when running “make” from a tarball, not only “make
> dist”.

Oops, fixed in V4.

> However (!) “make dist” from the same (rebuilt reproducibly from
> the git repo with your patches) tarball on another machine is in my case
> perfectly reproducible, so could you just drop the warning?

Hmm.  You're probably rightt.  I tried touching files, run update-po,
but reproducibility seems pretty resilient to such changes.  I've chosen
to keep it anyway just to discourage maintainers from doing such a
thing.

> Thank you for making Guix more secure.

Most happy to.  Thanks for your reviews!

Greetings,
Janneke
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 147767ece4..39cf4b4b17 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -953,9 +953,24 @@  guix-binary.%.tar.xz:
 	  guix` ;					\
 	cp "$$tarball" "$@.tmp" ; mv "$@.tmp" "$@"
 
+# The `dist' target has other dependencies when building from Git
+# to assert and achieve reproducibility.  Indented to get past Automake.
+in_git_p = $(shell test -e .git && echo true)
+ ifeq ($(in_git_p),true)
+
+# The dependency on dist-doc-pot-update is to clean possibly stale doc and po
+# files and only then generate the .pot files, which are not checked in.
+dist: dist-doc-pot-update
+dist-doc-pot-update: auto-clean
+	$(MAKE) guile$(EXEEXT)
+	$(MAKE) -C po/guix all
+	$(MAKE) -C po/packages all
+	$(MAKE) doc-pot-update
+
+dist-hook: gen-ChangeLog gen-AUTHORS
 
 # Assert that Autotools cache is up to date with Git, by checking
-# PACKAGE_VERSION against HEAD.  Indented to get past Automake.
+# PACKAGE_VERSION against HEAD.
  ifeq ($(MAKECMDGOALS),dist)
  git_version = $(shell build-aux/git-version-gen .tarball-version)
  ifneq ($(PACKAGE_VERSION),$(git_version))
@@ -967,20 +982,18 @@  guix-binary.%.tar.xz:
  $(error Cannot create reproducible tarball)
  else
  $(warning Tarball will be irreproducible; distdir will not get removed!)
- endif
- endif
- endif
+ endif # !GUIX_ALLOW_IRREPRODUCIBLE_TARBALL
+ endif # PACKAGE_VERSION != git_version
+ endif # MAKECMDGOALS dist
 
-# The dependency on dist-doc-pot-update is to clean possibly stale doc and po
-# files and only then generate the .pot files, which are not checked in.
-dist: dist-doc-pot-update
-dist-doc-pot-update: auto-clean
-	$(MAKE) guile$(EXEEXT)
-	$(MAKE) -C po/guix all
-	$(MAKE) -C po/packages all
-	$(MAKE) doc-pot-update
+ else # !in_git_p
 
-dist-hook: gen-ChangeLog gen-AUTHORS gen-tarball-version
+dist: doc-pot-update
+$(warning Not using Git, tarball will likely be irreproducible!)
+
+ endif # !in_git_p
+
+dist-hook: gen-tarball-version
 dist-hook: assert-no-store-file-names
 
 distcheck-hook: assert-binaries-available assert-final-inputs-self-contained
@@ -992,27 +1005,25 @@  $(top_srcdir)/.version: config.status
 
 gen-tarball-version:
 	echo $(VERSION) > "$(distdir)/.tarball-version"
-	git show HEAD --format=%ct --no-patch > $(distdir)/.tarball-timestamp
+	echo $(SOURCE_DATE_EPOCH) > $(distdir)/.tarball-timestamp
 
 gen-ChangeLog:
-	$(AM_V_GEN)if test -e .git; then		\
-	  export LC_ALL=en_US.UTF-8;			\
-	  export TZ=UTC0;				\
-	  $(top_srcdir)/build-aux/gitlog-to-changelog	\
-	    > $(distdir)/ChangeLog.tmp;			\
-	  rm -f $(distdir)/ChangeLog;			\
-	  mv $(distdir)/ChangeLog.tmp $(distdir)/ChangeLog;	\
-	fi
+	$(AM_V_GEN)set -e;					\
+	  export LC_ALL=en_US.UTF-8;				\
+	  export TZ=UTC0;					\
+	  $(top_srcdir)/build-aux/gitlog-to-changelog		\
+	    > $(distdir)/ChangeLog.tmp;				\
+	  rm -f $(distdir)/ChangeLog;				\
+	  mv $(distdir)/ChangeLog.tmp $(distdir)/ChangeLog;
 
 gen-AUTHORS:
-	$(AM_V_GEN)if test -e .git; then			\
+	$(AM_V_GEN)set -e;					\
 	  rm -f "$(distdir)/AUTHORS";				\
 	  export LC_ALL=en_US.UTF-8;				\
 	  export TZ=UTC0;					\
 	  $(top_builddir)/pre-inst-env "$(GUILE)"		\
 	    "$(top_srcdir)/build-aux/generate-authors.scm"	\
-	    "$(top_srcdir)" "$(distdir)/AUTHORS";		\
-	fi
+	    "$(top_srcdir)" "$(distdir)/AUTHORS";
 
 # Like 'dist', but regenerate 'configure' so we get an up-to-date
 # 'PACKAGE_VERSION' string.  (In Gnulib, 'GNUmakefile' has a special trick to