Skip to content

Commit

Permalink
Makefile.am: update ChangeLog recipe to be a no-op if the existing fi…
Browse files Browse the repository at this point in the history
…le is newer than .git/HEAD [networkupstools/nut-website#52]

    if test -e .git/HEAD && ( rm -f "`find "$@" -not -newer .git/HEAD`" || true ) 2>/dev/null && ls -la .git/HEAD "$@" 2>/dev/null ; then SKIP ; else WORK ; fi

Hopefully this takes care of corner cases:

* No .git/HEAD => WORK (may be unsuccessfully, maybe not - e.g. Git submodules referring to parent)
* `rm` fails, maybe `find` returns empty => DON'T CARE, go to LS
* `ls` fails (one of target files is absent - e.g. ChangeLog removed or never was there) => WORK

Only if the ChangeLog is still there after the attempt on its life, SKIP and keep it

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed May 10, 2024
1 parent 4a6e1d4 commit cc47966
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,19 @@ else
WITH_PDF_NONASCII_TITLES_ENVVAR = WITH_PDF_NONASCII_TITLES=no
endif

# Be sure to not confuse with a DIST'ed file (and so try to overwrite it):
# Be sure to not confuse with a DIST'ed file (and so try to overwrite it);
# do however avoid re-generating it if already made on a previous pass and
# the Git HEAD pointer did not change since then (subsequent generation of
# the huge PDF/HTML files can cost dearly):
$(abs_top_builddir)/ChangeLog: tools/gitlog2changelog.py dummy-stamp
@cd $(abs_top_srcdir) && \
if test -e .git ; then \
CHANGELOG_FILE="$@" $(WITH_PDF_NONASCII_TITLES_ENVVAR) $(abs_top_builddir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || \
{ printf "gitlog2changelog.py failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; } ; \
if test -e .git/HEAD && ( rm -f "`find "$@" -not -newer .git/HEAD`" || true ) 2>/dev/null && ls -la .git/HEAD "$@" 2>/dev/null ; then \
echo "Using still-valid ChangeLog file generated earlier from same revision of Git source metadata" >&2 ; \
else \
CHANGELOG_FILE="$@" $(WITH_PDF_NONASCII_TITLES_ENVVAR) $(abs_top_builddir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || \
{ printf "gitlog2changelog.py failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; } ; \
fi ; \
else \
if test x"$(abs_top_srcdir)" != x"$(abs_top_builddir)" -a -s ./ChangeLog ; then \
echo "Using distributed ChangeLog file from sources" >&2 ; \
Expand Down

0 comments on commit cc47966

Please sign in to comment.