Bruno Haible via Gnulib discussion list <bug-gnulib@gnu.org> writes: > Simon Josefsson wrote on 2024-12-12: >> +TAR_OPTIONS += --mode=go+u,go-w --mtime=$(abs_top_srcdir)/NEWS >> >> and to Makefile.am: >> >> +dist-hook: mtime-NEWS-to-git-HEAD >> +.PHONY: mtime-NEWS-to-git-HEAD >> +mtime-NEWS-to-git-HEAD: >> + $(AM_V_GEN)if test -e $(srcdir)/.git \ >> + && command -v git > /dev/null; then \ >> + touch -m -d @"$$(git log -1 --format=%ct)" $(srcdir)/NEWS; \ >> + fi >> >> This is an ugly hack (for several reasons), but it has sustained some >> testing > > I don't find this ugly at all. More than that, it generalizes to built files. ... > Anything that I might have overlooked?
It works, although some of the reason I initially found it ugly: 1) This is a dist-hook that modify something outside of distdir, which isn't what a dist-hook is supposed to do. 2) The mtime is set via TAR_OPTIONS from cfg.mk which has the somewhat weird effect that all tarballs created during 'make' gets the same TAR_OPTIONS handling. Consider if your build script or self-tests creates tarballs. So you probably have to explicitly say 'env TAR_OPTIONS= tar ...' if you want to do something with tar from within the package. This is probably a bug in the package anyway, but I found it a bit weird. 3) It assumes that the mtime of the tarball ought to be set to the commit time of NEWS file, which is only guaranteed to be the latest commit of the repository at release time. Please use this version that handles srcdir!=builddir better: GIT_NEWS_MTIME_CMD = git -C $(srcdir) log -1 --format=%ct dist-hook: mtime-NEWS-to-git-HEAD .PHONY: mtime-NEWS-to-git-HEAD mtime-NEWS-to-git-HEAD: $(AM_V_GEN)if test -e $(srcdir)/.git \ && command -v git > /dev/null; then \ touch -m -d @"$$($(GIT_NEWS_MTIME_CMD))" $(srcdir)/NEWS; \ fi I'm going to release libidn with this shortly, so if you spot any problem please bring it up. I'm not sure I follow what you actually plan to do wrt multiple files X1, X2, ... Xn. Can you give some code example? Maybe I understand that better... /Simon
signature.asc
Description: PGP signature