From: Nick Bowler Date: Sat, 13 Feb 2021 18:02:48 +0000 (-0500) Subject: Generate ChangeLog from git at packaging time. X-Git-Tag: v1~5 X-Git-Url: https://git.draconx.ca/gitweb/slotifier.git/commitdiff_plain/a8de6c1960d27f9990f4ee6c8b0db1299929d1d6 Generate ChangeLog from git at packaging time. Import the gitlog-to-changelog script from gnulib and add rules to generate an up-to-date changelog from the git history, if available, when running 'make dist'. The ChangeLog is otherwise taken from srcdir as usual, so that modified versions can be prepared from a release tarball without requiring the full git history. In this scenario, the ChangeLog would have to be manually edited. In case the ChangeLog generation fails, a distcheck-hook is added to hopefully catch issues before releasing tarballs with a broken ChangeLog. --- diff --git a/.gitignore b/.gitignore index 8434549..37cda95 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /configure /depcomp /exported.sh +/gitlog-to-changelog /install-sh /lib /libtool diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..4e0b7e7 --- /dev/null +++ b/ChangeLog @@ -0,0 +1 @@ +Stub changelog, see the git history for changes. diff --git a/Makefile.am b/Makefile.am index 963a5fb..35666c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -# Copyright © 2018 Nick Bowler +# Copyright © 2018, 2021 Nick Bowler # # License WTFPL2: Do What The Fuck You Want To Public License, version 2. # This is free software: you are free to do what the fuck you want to. @@ -26,6 +26,49 @@ $(slotifier_OBJECTS): $(gnulib_headers) dist_man_MANS = doc/slotifier.1 +# When running "make dist" in a VPATH build with a read-only srcdir, Automake +# will produce a distribution with all files read-only. Moreover, the files +# are read-only in distdir when the dist hooks are run. This hook will +# manually fix up the permissions. All dist hooks that modify files in distdir +# should list unfuck-distdir as a prerequisite. +dist-hook: unfuck-distdir +unfuck-distdir: + find '$(distdir)' -type f -exec chmod u+w {} + +.PHONY: unfuck-distdir + +GITLOG_FLAGS = --format='%s%n%n%b%n' + +dist-hook: generate-changelog +generate-changelog: unfuck-distdir + -: "$${GIT_DIR=$(top_srcdir)/.git}"; \ + export GIT_DIR; test -d "$$GIT_DIR" || exit 0; \ + $(top_srcdir)/gitlog-to-changelog $(GITLOG_FLAGS) \ + >'$(distdir)/ChangeLog.gen' && \ + mv -f '$(distdir)/ChangeLog.gen' '$(distdir)/ChangeLog' + rm -f '$(distdir)/ChangeLog.gen' +.PHONY: generate-changelog + +GENERIC_V = $(GENERIC_V_@AM_V@) +GENERIC_V_ = $(GENERIC_V_@AM_DEFAULT_V@) +GENERIC_V_0 = @printf '%2.0s%$(DX_ALIGN_V)s %s\n' + +TEST_DISTRIBUTION = false +TEST_DISTRIBUTION_OR_ERROR = if $(TEST_DISTRIBUTION); \ + then echo 'Proceeding anyway...'; \ + else echo 'Run $(MAKE) TEST_DISTRIBUTION=true to ignore this failure.'; \ + false; \ + fi + +distcheck-hook: + $(GENERIC_V) : 'CHECK ' ChangeLog; \ + $(AWK) '/^Stub/ { print FILENAME ":" NR ":", $$0; exit 1 }' \ + $(distdir)/ChangeLog || { \ + echo 'ERROR: *** Packaged ChangeLog was not properly generated from git log.'; \ + echo ' *** The source version was used instead, but this appears to'; \ + echo ' *** be the stub from a git checkout. The "git" and "perl"'; \ + echo ' *** programs are required for ChangeLog generation to work.'; \ + $(TEST_DISTRIBUTION_OR_ERROR); } >&2 + # Supporting rules for gettext. include $(top_srcdir)/common/snippet/gettext.mk noinst_DATA = $(MOFILES) diff --git a/gnulib b/gnulib index 233419c..0b38e1d 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 233419c39c6d13d84439b95766328a238ffb6518 +Subproject commit 0b38e1d69f03d3977d7ae7926c1efeb461a8a971 diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 1e35bf9..ad7a832 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,7 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this file. If not, see . +# along with this file. If not, see . # # As a special exception to the GNU General Public License, # this file may be distributed as part of a program that @@ -27,13 +27,31 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk.in --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files getopt-gnu gettext hypot localcharset striconv +# gnulib-tool --import \ +# --lib=libgnu \ +# --source-base=lib \ +# --m4-base=m4 \ +# --doc-base=doc \ +# --tests-base=tests \ +# --aux-dir=. \ +# --makefile-name=gnulib.mk.in \ +# --conditional-dependencies \ +# --libtool \ +# --macro-prefix=gl \ +# --no-vc-files \ +# getopt-gnu \ +# gettext \ +# gitlog-to-changelog \ +# hypot \ +# localcharset \ +# striconv # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) gl_MODULES([ getopt-gnu gettext + gitlog-to-changelog hypot localcharset striconv