]> git.draconx.ca Git - slotifier.git/commitdiff
Generate ChangeLog from git at packaging time.
authorNick Bowler <nbowler@draconx.ca>
Sat, 13 Feb 2021 18:02:48 +0000 (13:02 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 13 Feb 2021 18:02:48 +0000 (13:02 -0500)
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.

.gitignore
ChangeLog [new file with mode: 0644]
Makefile.am
gnulib
m4/gnulib-cache.m4

index 843454983aac2dd054c5774e4d9859575d106bc0..37cda957957dba9f3fdf470a7f5857e43090f936 100644 (file)
@@ -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 (file)
index 0000000..4e0b7e7
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1 @@
+Stub changelog, see the git history for changes.
index 963a5fbadd482a5fce3cbc5f5aada62d421bf344..35666c6ecf5473beb5dda7e031235f03547c7236 100644 (file)
@@ -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 233419c39c6d13d84439b95766328a238ffb6518..0b38e1d69f03d3977d7ae7926c1efeb461a8a971 160000 (submodule)
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 233419c39c6d13d84439b95766328a238ffb6518
+Subproject commit 0b38e1d69f03d3977d7ae7926c1efeb461a8a971
index 1e35bf9ee8cf13ea6db3d34a1f330f20c6fb83e2..ad7a83202d18725d9008aa3738a640880018764e 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
+# along with this file.  If not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License,
 # this file may be distributed as part of a program that
 
 
 # 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