From a46a8b905add40b043b6f23e40b41a65d2cd03f6 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 3 Apr 2024 13:41:25 +0300 Subject: [PATCH 1/8] Switch from xz to zst compression for official artifacts I've always preferred ZSTD do XZ anyway, but the default Ubuntu runner GitHub Actions used to use was so old that it did not have a sufficiently new autotools release to have ZSTD support. Hence XZ was always a compromise to get better compression without compatibility problems. Times have changed, the upstream `xz-utils` project has been backdoored, and ZSTD is available in Ubuntu LTS releases so we don't have a problem auto-generating releases any more. As-yet no evidence has surfaced that XZ compressed artifacts are compromised, but since there are no blockers anyway switching seems like a good plan to me. --- .github/workflows/release.yml | 2 +- configure.ac | 2 +- doc/INSTALL.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45e6bfe3..cf45cf38 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,8 +41,8 @@ jobs: prerelease: ${{ env.PRERELEASE }} body_path: changelog-HEAD files: | + vcsh-${{ env.VERSION }}.tar.zst vcsh-${{ env.VERSION }}.zip - vcsh-${{ env.VERSION }}.tar.xz deploy-standalone: runs-on: ubuntu-latest diff --git a/configure.ac b/configure.ac index e86649cb..b9b1d24c 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ([2.69]) AC_INIT([vcsh], [m4_esyscmd(build-aux/git-version-gen .tarball-version)]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([build-aux]) -AM_INIT_AUTOMAKE([foreign tar-pax dist-xz dist-zip no-dist-gzip color-tests]) +AM_INIT_AUTOMAKE([foreign tar-pax dist-zstd dist-zip no-dist-gzip color-tests]) AM_SILENT_RULES([yes]) AM_CONDITIONAL([IS_SDIST], diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 6d067688..4be9cd0f 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -81,7 +81,7 @@ $ pkg install vcsh First you’ll want a copy of the source code. The easiest to use place to get this is the [latest release](https://github.com/RichiH/vcsh/releases/latest) posted on GitHub. -The souree distribution will have a name such as `vcsh-2.0.0.tar.xz`. +The souree distribution will have a name such as `vcsh-2.0.0.tar.zst`. Note under each release GitHub also show two “Source code” links that will download a snapshot of the repository; this is **not** the file you want (unless you want to jump through extra hoops). The official source release packages with the release version in the file names are the ones you want. From 61aac7de1d9166fa3a4236ddb62400e0eafae5d1 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 3 Apr 2024 13:47:54 +0300 Subject: [PATCH 2/8] Generate checksums for release artifacts in CI One of the major complains surrounding the recent XZ fiasco is that auto-tools generated source files include so much obtuse code that they are difficult to audit. Also it isn't immediately apparent what sources they have been generated from. In our case we're generating the source dist files in CI anyway and automatically attaching them to releases, but GH does not make it possible to verify this. They could just as well be reposted later by a malicious maintainer. This is not a magic bullet to fix all that, but it should help. The CI environment can be verified by looking at the workflow file and the other Git sources so we're not using a modified version of autotools or anything like that. Checksums are now being generated after making the distribution tarballs, and *echoed to the output log* so it is possible to verify that the files generated in CI are actually still the ones attached to the release. The checksums file is also posted to the release. --- .github/workflows/build.yml | 1 + .github/workflows/release.yml | 5 ++++- Makefile.am | 1 + build-aux/ax_dist_checksums.m4 | 6 ++++++ build-aux/dist_checksums.mk | 17 +++++++++++++++++ configure.ac | 3 ++- 6 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 build-aux/ax_dist_checksums.m4 create mode 100644 build-aux/dist_checksums.mk diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ee9a5b4..965d87d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,7 @@ jobs: ./configure --with-standalone --bindir=/ make DESTDIR=. install-exec echo VERSION=$(cat .version) >> $GITHUB_ENV + sha256sum vcsh-standalone.sh - name: Post standalone script artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf45cf38..8da056b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,6 +43,7 @@ jobs: files: | vcsh-${{ env.VERSION }}.tar.zst vcsh-${{ env.VERSION }}.zip + vcsh-${{ env.VERSION }}.sha256.txt deploy-standalone: runs-on: ubuntu-latest @@ -56,9 +57,11 @@ jobs: ./bootstrap.sh ./configure --with-standalone --bindir=/ make DESTDIR=. install-exec + sha256sum vcsh-standalone.sh | tee vcsh-standalone.sha256.txt - name: Add standalone deployment to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ github.token }} - file: vcsh-standalone.sh tag: ${{ github.ref }} + file_glob: true + file: vcsh-standalone.{sh,sha256.txt} diff --git a/Makefile.am b/Makefile.am index 87e69aaa..c4e1fb82 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,6 +24,7 @@ BUILT_SOURCES = CLEANFILES = $(dist_man_MANS) $(bin_SCRIPTS) include $(top_srcdir)/build-aux/git_version.mk +include $(top_srcdir)/build-aux/dist_checksums.mk include $(top_srcdir)/build-aux/shell_completion_dirs.mk if !IS_SDIST diff --git a/build-aux/ax_dist_checksums.m4 b/build-aux/ax_dist_checksums.m4 new file mode 100644 index 00000000..5df751c9 --- /dev/null +++ b/build-aux/ax_dist_checksums.m4 @@ -0,0 +1,6 @@ +AC_DEFUN([AX_DIST_CHECKSUMS], [ + + AX_PROGVAR([sha256sum]) + AX_PROGVAR([tee]) + +]) diff --git a/build-aux/dist_checksums.mk b/build-aux/dist_checksums.mk new file mode 100644 index 00000000..2e8dc2c8 --- /dev/null +++ b/build-aux/dist_checksums.mk @@ -0,0 +1,17 @@ +# Output both a file that can be attatched to releases and also write STDOUT +# for the sake of CI build logs so they can be audited as matching what is +# eventually posted. The list of files checksummed is a glob (even though we +# know an exact pattern) to avoid errors for formats not generated. +checksum_dist = \ + shopt -s nullglob ; \ + $(SHA256SUM) $(distdir)*.{tar.{gz,bz2,lz,xz,zst},zip} |\ + $(TEE) $(distdir).sha256.txt + +# Since the checksums file isn't an artifact produced by the default source dist +# creation process, we have to clean it up ourselves so distcheck can see that +# everything round-tripped cleanly. +distclean-local: + rm -f $(distdir).sha256.txt + +# Append checksum operation to function that runs after compressing dist archives +am__post_remove_distdir = $(am__remove_distdir); $(checksum_dist) diff --git a/configure.ac b/configure.ac index b9b1d24c..3825494a 100644 --- a/configure.ac +++ b/configure.ac @@ -28,9 +28,10 @@ AC_ARG_WITH([standalone], ], []) -# These three macros must be run after processing our standalone setup because +# These macros must be run after processing our standalone setup because # they all expect the program name transformation setup to be complete. AX_GIT_VERSION +AX_DIST_CHECKSUMS AX_SHELL_COMPLETION_DIRS AX_TRANSFORM_PACKAGE_NAME From dfe711e9ba51424aa2cd1d39710978b19cc6cbd4 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 4 Apr 2024 16:48:27 +0300 Subject: [PATCH 3/8] Use more GNU/Autotools idiomatic names and methods We're extending GNU/Autotools with our own macros. This is allowed and even expected, but there are certainly more and less idiomatic ways to do so. This normalizes all our extended bits to be as idiomatic as possible to make auditing easier. * Filename prefixes are more representative of their source: especially we are not hijacking the ax_ prefix which usually references something from autotools-archive that could be compared with a known source. All files starting with ax_ could be removed from this repository and the project still build provided autotools-archive is available on the host system. We're still vendoring them because it is not as broadly available as autotools, but these bits don't need to be audited as part of this project. I used que_ as a prefix for custom macros to make them easy to find and because I've authored them and share identical extensions across a number of other projects. The configure macros and correstponding makefile fragments have matching prefixes so they sort together. * The AMINCLUDE system is leveraged instead of making the maintainer hand-rol includes for each fragment. This is actually probably slightly *harder* to grok, but again the macros used are standardized in autoconf-archive.) I think the more idiomatic usage has the payoff of not sounding any more alarms than we need to. The gotcha was that we do still want to inline them, which means a bit of extra bootstrapping. The macro include system also has the advantage of a single place to enable/disable a component of the build instead of needing to comment out both the configure.ac macro(s) and the matching Makefile.am include(s) separately. --- .gitignore | 1 + Makefile.am | 19 +++++++++---- bootstrap.sh | 10 +++++++ build-aux/ax_dist_checksums.m4 | 6 ----- build-aux/ax_git_version.m4 | 9 ------- ...ist_checksums.mk => que_dist_checksums.am} | 2 ++ build-aux/que_dist_checksums.m4 | 13 +++++++++ .../{git_version.mk => que_git_version.am} | 1 - build-aux/que_git_version.m4 | 23 ++++++++++++++++ build-aux/{ax_progvar.m4 => que_progvar.m4} | 2 +- ...n_dirs.mk => que_shell_completion_dirs.am} | 6 ----- ...n_dirs.m4 => que_shell_completion_dirs.m4} | 11 ++++++-- ..._name.m4 => que_transform_package_name.m4} | 2 +- configure.ac | 27 +++++++++---------- 14 files changed, 86 insertions(+), 46 deletions(-) delete mode 100644 build-aux/ax_dist_checksums.m4 delete mode 100644 build-aux/ax_git_version.m4 rename build-aux/{dist_checksums.mk => que_dist_checksums.am} (97%) create mode 100644 build-aux/que_dist_checksums.m4 rename build-aux/{git_version.mk => que_git_version.am} (95%) create mode 100644 build-aux/que_git_version.m4 rename build-aux/{ax_progvar.m4 => que_progvar.m4} (87%) rename build-aux/{shell_completion_dirs.mk => que_shell_completion_dirs.am} (67%) rename build-aux/{ax_shell_completion_dirs.m4 => que_shell_completion_dirs.m4} (87%) rename build-aux/{ax_transform_package_name.m4 => que_transform_package_name.m4} (93%) diff --git a/.gitignore b/.gitignore index 2562f6ab..df1f1210 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,6 @@ completions/vcsh config.log config.status configure +aminclude.am /vcsh vcsh-* diff --git a/Makefile.am b/Makefile.am index c4e1fb82..031bc8fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,13 +23,22 @@ EXTRA_DIST += t/000-tear-env.t t/001-setup-env.t t/100-init.t t/300-add.t t/950- BUILT_SOURCES = CLEANFILES = $(dist_man_MANS) $(bin_SCRIPTS) -include $(top_srcdir)/build-aux/git_version.mk -include $(top_srcdir)/build-aux/dist_checksums.mk -include $(top_srcdir)/build-aux/shell_completion_dirs.mk +# A classical use of the autoconf-archive include macro would expand +# INC_AMINCLUDE here, but the perl script that inlines include statements +# runs before the automake that organizes logic and performs substitution. +# Consequentially with a substitution here it becomes impossible to use +# automake conditionals and substitutions in the included Makefile fragments. +# By entering the expanded value directly we are ready in time for the inlining +# functionality and hence can use conditionals in included makefile fragments. +include $(top_srcdir)/aminclude.am + +DISTCLEANFILES = @AMINCLUDE@ + +if !SOURCE_IS_DIST -if !IS_SDIST doc/vcsh.1: doc/vcsh.1.ronn $(RONN) < $< > $@ + endif $(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.bash @@ -41,7 +50,7 @@ $(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.zsh install $< $@ if ENABLE_TESTS -_CHECKDEPS = prove +_CHECKDEPS = $(PROVE) endif check-local: $(_CHECKDEPS) diff --git a/bootstrap.sh b/bootstrap.sh index 0d8d2841..94f6b762 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -21,4 +21,14 @@ else ./build-aux/git-version-gen .tarball-version > .version fi +# Autoreconf uses a perl script to inline includes from Makefile.am into +# Makefile.in before ./configure is ever run even once ... which typically means +# AX_AUTOMAKE_MACROS forfeit access to substitutions or conditional logic +# because they enter the picture after those steps. We're intentially using the +# expanded value of @INC_AMINCLUDE@ directly so the include will be inlined. To +# bootstrap we must pre-seed an empty file to avoid a 'file not found' error on +# first run. Subsequently running ./configure will generate the correct content +# based on the configuration flags and also get re-inline into Makefile.in. +touch aminclude.am + autoreconf --install diff --git a/build-aux/ax_dist_checksums.m4 b/build-aux/ax_dist_checksums.m4 deleted file mode 100644 index 5df751c9..00000000 --- a/build-aux/ax_dist_checksums.m4 +++ /dev/null @@ -1,6 +0,0 @@ -AC_DEFUN([AX_DIST_CHECKSUMS], [ - - AX_PROGVAR([sha256sum]) - AX_PROGVAR([tee]) - -]) diff --git a/build-aux/ax_git_version.m4 b/build-aux/ax_git_version.m4 deleted file mode 100644 index b5980783..00000000 --- a/build-aux/ax_git_version.m4 +++ /dev/null @@ -1,9 +0,0 @@ -AC_DEFUN([AX_GIT_VERSION], [ - - AC_PROG_AWK - AC_PROG_GREP - AX_PROGVAR([cmp]) - - AX_TRANSFORM_PACKAGE_NAME - -]) diff --git a/build-aux/dist_checksums.mk b/build-aux/que_dist_checksums.am similarity index 97% rename from build-aux/dist_checksums.mk rename to build-aux/que_dist_checksums.am index 2e8dc2c8..0e63f281 100644 --- a/build-aux/dist_checksums.mk +++ b/build-aux/que_dist_checksums.am @@ -15,3 +15,5 @@ distclean-local: # Append checksum operation to function that runs after compressing dist archives am__post_remove_distdir = $(am__remove_distdir); $(checksum_dist) + +# vim: ft=automake diff --git a/build-aux/que_dist_checksums.m4 b/build-aux/que_dist_checksums.m4 new file mode 100644 index 00000000..5206b372 --- /dev/null +++ b/build-aux/que_dist_checksums.m4 @@ -0,0 +1,13 @@ +AC_DEFUN_ONCE([QUE_DIST_CHECKSUMS], [ + + QUE_PROGVAR([sha256sum]) + QUE_PROGVAR([tee]) + + QUE_TRANSFORM_PACKAGE_NAME + + AC_REQUIRE([AX_AM_MACROS]) + AX_ADD_AM_MACRO([dnl +$(cat build-aux/que_dist_checksums.am) +])dnl + +]) diff --git a/build-aux/git_version.mk b/build-aux/que_git_version.am similarity index 95% rename from build-aux/git_version.mk rename to build-aux/que_git_version.am index 58e16119..6b9e8098 100644 --- a/build-aux/git_version.mk +++ b/build-aux/que_git_version.am @@ -1,6 +1,5 @@ .SECONDEXPANSION: -# EXTRA_@PACKAGE_VAR@_SOURCES += .version EXTRA_DIST += build-aux/git-version-gen BUILT_SOURCES += .version CLEANFILES += .version .version-prev diff --git a/build-aux/que_git_version.m4 b/build-aux/que_git_version.m4 new file mode 100644 index 00000000..7174a56f --- /dev/null +++ b/build-aux/que_git_version.m4 @@ -0,0 +1,23 @@ +AC_DEFUN_ONCE([QUE_GIT_VERSION], [ + + AC_PROG_AWK + AC_PROG_GREP + QUE_PROGVAR([cmp]) + + QUE_TRANSFORM_PACKAGE_NAME + + AM_CONDITIONAL([SOURCE_IS_GIT], + [test -d .git]) + + AM_CONDITIONAL([SOURCE_IS_DIST], + [test -f .tarball-version]) + + AM_CONDITIONAL([SOURCE_IS_ARCHIVE], + [test ! -d .git -a ! -f .tarball-version]) + + AC_REQUIRE([AX_AM_MACROS]) + AX_ADD_AM_MACRO([dnl +$(cat build-aux/que_git_version.am) +])dnl + +]) diff --git a/build-aux/ax_progvar.m4 b/build-aux/que_progvar.m4 similarity index 87% rename from build-aux/ax_progvar.m4 rename to build-aux/que_progvar.m4 index e584ed4a..20d1288b 100644 --- a/build-aux/ax_progvar.m4 +++ b/build-aux/que_progvar.m4 @@ -1,4 +1,4 @@ -AC_DEFUN([AX_PROGVAR], [ +AC_DEFUN([QUE_PROGVAR], [ test -n "$m4_toupper($1)" || { AC_PATH_PROG(m4_toupper($1), m4_default($2,$1)) } test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required]) ]) diff --git a/build-aux/shell_completion_dirs.mk b/build-aux/que_shell_completion_dirs.am similarity index 67% rename from build-aux/shell_completion_dirs.mk rename to build-aux/que_shell_completion_dirs.am index 1f52ea7c..354a0b19 100644 --- a/build-aux/shell_completion_dirs.mk +++ b/build-aux/que_shell_completion_dirs.am @@ -6,12 +6,6 @@ nodist_bashcompletion_DATA = $(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME) CLEANFILES += $(nodist_bashcompletion_DATA) endif -# if ENABLE_FISH_COMPLETION -# fishcompletiondir = $(FISH_COMPLETION_DIR) -# nodist_fishcompletion_DATA = $(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME).fish -# CLEANFILES += $(nodist_fishcompletion_DATA) -# endif - if ENABLE_ZSH_COMPLETION zshcompletiondir = $(ZSH_COMPLETION_DIR) nodist_zshcompletion_DATA = $(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME) diff --git a/build-aux/ax_shell_completion_dirs.m4 b/build-aux/que_shell_completion_dirs.m4 similarity index 87% rename from build-aux/ax_shell_completion_dirs.m4 rename to build-aux/que_shell_completion_dirs.m4 index 2f455be0..6ceed855 100644 --- a/build-aux/ax_shell_completion_dirs.m4 +++ b/build-aux/que_shell_completion_dirs.m4 @@ -1,6 +1,8 @@ -AC_DEFUN_ONCE([AX_SHELL_COMPLETION_DIRS], [ +AC_DEFUN_ONCE([QUE_SHELL_COMPLETION_DIRS], [ - AX_TRANSFORM_PACKAGE_NAME + QUE_TRANSFORM_PACKAGE_NAME + + AC_PROG_SED AC_ARG_WITH([bash-completion-dir], AS_HELP_STRING([--with-bash-completion-dir[=PATH]], @@ -30,4 +32,9 @@ AC_DEFUN_ONCE([AX_SHELL_COMPLETION_DIRS], [ [ZSH_COMPLETION_DIR="$with_zsh_completion_dir"]) AC_SUBST([ZSH_COMPLETION_DIR]) + AC_REQUIRE([AX_AM_MACROS]) + AX_ADD_AM_MACRO([dnl +$(cat build-aux/que_shell_completion_dirs.am) +])dnl + ]) diff --git a/build-aux/ax_transform_package_name.m4 b/build-aux/que_transform_package_name.m4 similarity index 93% rename from build-aux/ax_transform_package_name.m4 rename to build-aux/que_transform_package_name.m4 index ff53dd93..ee1e8972 100644 --- a/build-aux/ax_transform_package_name.m4 +++ b/build-aux/que_transform_package_name.m4 @@ -3,7 +3,7 @@ # This isn't convenient to use if we're just renaming the top level package, so # we go ahead and *do* the transformation and save for use as a substitution. -AC_DEFUN_ONCE([AX_TRANSFORM_PACKAGE_NAME], [ +AC_DEFUN_ONCE([QUE_TRANSFORM_PACKAGE_NAME], [ AC_PROG_SED diff --git a/configure.ac b/configure.ac index 3825494a..b8166edd 100644 --- a/configure.ac +++ b/configure.ac @@ -5,9 +5,6 @@ AC_CONFIG_MACRO_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign tar-pax dist-zstd dist-zip no-dist-gzip color-tests]) AM_SILENT_RULES([yes]) -AM_CONDITIONAL([IS_SDIST], - [test ! -e .gitignore]) - AC_ARG_WITH([standalone], AS_HELP_STRING([--with-standalone], [Use configuration presets for a standalone script deployment @<:@default=no@:>@]), @@ -28,19 +25,20 @@ AC_ARG_WITH([standalone], ], []) +QUE_TRANSFORM_PACKAGE_NAME + # These macros must be run after processing our standalone setup because # they all expect the program name transformation setup to be complete. -AX_GIT_VERSION -AX_DIST_CHECKSUMS -AX_SHELL_COMPLETION_DIRS -AX_TRANSFORM_PACKAGE_NAME +QUE_GIT_VERSION +QUE_SHELL_COMPLETION_DIRS +QUE_DIST_CHECKSUMS AC_PROG_GREP AC_PROG_SED -AX_PROGVAR([comm]) -AX_PROGVAR([git]) -AX_PROGVAR([wc]) +QUE_PROGVAR([comm]) +QUE_PROGVAR([git]) +QUE_PROGVAR([wc]) AC_ARG_WITH([deployment], AS_HELP_STRING([--with-deployment], @@ -57,13 +55,12 @@ AC_ARG_WITH([man-page], AM_CONDITIONAL([ENABLE_MAN_PAGE], [test x"$with_man_page" != x"no"]) -AM_COND_IF([IS_SDIST], - [], +AM_COND_IF([SOURCE_IS_GIT], [AM_COND_IF([ENABLE_MAN_PAGE], - [AX_PROGVAR([ronn])]) + [QUE_PROGVAR([ronn])]) ]) -AM_COND_IF([IS_SDIST], +AM_COND_IF([SOURCE_IS_GIT], m4_define([TESTDEF], [yes]), m4_define([TESTDEF], [no])) AC_ARG_ENABLE([tests], @@ -75,7 +72,7 @@ AM_CONDITIONAL([ENABLE_TESTS], [test x"$enable_tests" != x"no"]) AM_COND_IF([ENABLE_TESTS], [ - AX_PROGVAR([prove]) + QUE_PROGVAR([prove]) AX_PROG_PERL_MODULES(Shell::Command, [], AC_MSG_ERROR(Perl module required for testing not found)) AX_PROG_PERL_MODULES(Test::Most, [], From b22fa10df6d158cd5fbfbec45a40c71eccb35124 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 4 Apr 2024 16:48:27 +0300 Subject: [PATCH 4/8] Include macros from autoconf-archive (pristine) Reverting this commit should remove the macro code. The project would still be buildable on any system with autoconf-archive, but since that is considerably less than systems with autoconf which is our actual target, we're vendoring a copy of them here. These files should be bit-for-bit the same as what appears in current macro archives. --- build-aux/ax_add_am_macro.m4 | 29 ++++++++++++++++++++++ build-aux/ax_am_macros.m4 | 44 ++++++++++++++++++++++++++++++++++ build-aux/ax_append_to_file.m4 | 27 +++++++++++++++++++++ build-aux/ax_file_escapes.m4 | 30 +++++++++++++++++++++++ build-aux/ax_print_to_file.m4 | 27 +++++++++++++++++++++ 5 files changed, 157 insertions(+) create mode 100644 build-aux/ax_add_am_macro.m4 create mode 100644 build-aux/ax_am_macros.m4 create mode 100644 build-aux/ax_append_to_file.m4 create mode 100644 build-aux/ax_file_escapes.m4 create mode 100644 build-aux/ax_print_to_file.m4 diff --git a/build-aux/ax_add_am_macro.m4 b/build-aux/ax_add_am_macro.m4 new file mode 100644 index 00000000..3962002b --- /dev/null +++ b/build-aux/ax_add_am_macro.m4 @@ -0,0 +1,29 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_add_am_macro.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_ADD_AM_MACRO([RULE]) +# +# DESCRIPTION +# +# Adds the specified rule to $AMINCLUDE. This macro will only work +# properly with implementations of Make which allow include statements. +# See also AX_ADD_AM_MACRO_STATIC. +# +# LICENSE +# +# Copyright (c) 2009 Tom Howard +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 10 + +AC_DEFUN([AX_ADD_AM_MACRO],[ + AC_REQUIRE([AX_AM_MACROS]) + AX_APPEND_TO_FILE([$AMINCLUDE],[$1]) +]) diff --git a/build-aux/ax_am_macros.m4 b/build-aux/ax_am_macros.m4 new file mode 100644 index 00000000..36c3ab6a --- /dev/null +++ b/build-aux/ax_am_macros.m4 @@ -0,0 +1,44 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_am_macros.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_AM_MACROS +# +# DESCRIPTION +# +# Adds support for macros that create Make rules. You must manually add +# the following line +# +# @INC_AMINCLUDE@ +# +# to your Makefile.in (or Makefile.am if you use Automake) files. +# +# LICENSE +# +# Copyright (c) 2009 Tom Howard +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 11 + +AC_DEFUN([AX_AM_MACROS], +[ +AC_MSG_NOTICE([adding automake macro support]) +AMINCLUDE="aminclude.am" +AC_SUBST(AMINCLUDE) +AC_MSG_NOTICE([creating $AMINCLUDE]) +AMINCLUDE_TIME=`LC_ALL=C date` +AX_PRINT_TO_FILE([$AMINCLUDE],[[ +# generated automatically by configure from AX_AUTOMAKE_MACROS +# on $AMINCLUDE_TIME + +]]) + +INC_AMINCLUDE="include \$(top_builddir)/$AMINCLUDE" +AC_SUBST(INC_AMINCLUDE) +]) diff --git a/build-aux/ax_append_to_file.m4 b/build-aux/ax_append_to_file.m4 new file mode 100644 index 00000000..fca57083 --- /dev/null +++ b/build-aux/ax_append_to_file.m4 @@ -0,0 +1,27 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_append_to_file.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_TO_FILE([FILE],[DATA]) +# +# DESCRIPTION +# +# Appends the specified data to the specified file. +# +# LICENSE +# +# Copyright (c) 2008 Tom Howard +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 9 + +AC_DEFUN([AX_APPEND_TO_FILE],[ +AC_REQUIRE([AX_FILE_ESCAPES]) +printf "%s" "$2" >> "$1" +]) diff --git a/build-aux/ax_file_escapes.m4 b/build-aux/ax_file_escapes.m4 new file mode 100644 index 00000000..a86fdc32 --- /dev/null +++ b/build-aux/ax_file_escapes.m4 @@ -0,0 +1,30 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_FILE_ESCAPES +# +# DESCRIPTION +# +# Writes the specified data to the specified file. +# +# LICENSE +# +# Copyright (c) 2008 Tom Howard +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AC_DEFUN([AX_FILE_ESCAPES],[ +AX_DOLLAR="\$" +AX_SRB="\\135" +AX_SLB="\\133" +AX_BS="\\\\" +AX_DQ="\"" +]) diff --git a/build-aux/ax_print_to_file.m4 b/build-aux/ax_print_to_file.m4 new file mode 100644 index 00000000..8aa71120 --- /dev/null +++ b/build-aux/ax_print_to_file.m4 @@ -0,0 +1,27 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_print_to_file.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PRINT_TO_FILE([FILE],[DATA]) +# +# DESCRIPTION +# +# Writes the specified data to the specified file. +# +# LICENSE +# +# Copyright (c) 2008 Tom Howard +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AC_DEFUN([AX_PRINT_TO_FILE],[ +AC_REQUIRE([AX_FILE_ESCAPES]) +printf "$2" > "$1" +]) From a546e21134acd3f35e7c17f814f47d40c0a29e97 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 6 Apr 2024 14:28:58 +0300 Subject: [PATCH 5/8] Refresh contributors file --- CONTRIBUTORS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 8cd4d5f3..329b3ec6 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -37,12 +37,16 @@ Harendra Kumar James Davidson Jeff Fein-Worton Jochen Keil +John Karahalis +John Whitley Jonathan Sternberg Julien Lecomte Kevin Lyda leycec +Lyderic Landry Markus Martin martin f. krafft +Martin Kühl Mathias Svensson mek-apelsin Mert Dirik From 3332abb8420efbf231f4e1735f21d6684c3cd7f2 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 6 Apr 2024 23:05:39 +0300 Subject: [PATCH 6/8] Add macro file for configure time developer mode flag --- build-aux/que_developer_mode.m4 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 build-aux/que_developer_mode.m4 diff --git a/build-aux/que_developer_mode.m4 b/build-aux/que_developer_mode.m4 new file mode 100644 index 00000000..18bd29fe --- /dev/null +++ b/build-aux/que_developer_mode.m4 @@ -0,0 +1,19 @@ +# Like AM_MAINTAINER_MODE, but doesn't touch automake internals and so +# can be used freely to control access to project specific developer +# tooling without breaking autotools if disabled. +AC_DEFUN([QUE_DEVELOPER_MODE], [ + m4_case(m4_default([$1], [disable]), + [enable], [m4_define([_que_developer_def], [disable])], + [disable], [m4_define([_que_developer_def], [enable])], + [m4_define([_que_developer_def], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_DEVELOPER_MODE: $1])]) + AC_MSG_CHECKING([whether to enable developer-specific portions of Makefiles]) + AC_ARG_ENABLE([developer-mode], + [AS_HELP_STRING([--]_que_developer_def[-developer-mode], + _que_developer_def[ dependencies and make targets only useful for developers])], + [USE_DEVELOPER_MODE=$enableval], + [USE_DEVELOPER_MODE=]m4_if(_que_developer_def, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_DEVELOPER_MODE]) + AM_CONDITIONAL([DEVELOPER_MODE], [test $USE_DEVELOPER_MODE = yes]) + +]) From 541e700c337600dcf79b8ec4a382ee5cb66896eb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 6 Apr 2024 23:05:39 +0300 Subject: [PATCH 7/8] Gate check tooling like linters behind developer mode flag --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- Makefile.am | 20 +++++++++++++++++--- build-aux/que_dist_checksums.m4 | 13 ++++++++----- build-aux/que_git_version.m4 | 13 +++++++------ configure.ac | 1 + 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 965d87d6..d567897a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: - name: Configure run: | ./bootstrap.sh - ./configure + ./configure --enable-developer-mode - name: Run tests run: | make check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8da056b2..c2e02750 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV echo "${GITHUB_REF#refs/*/v}" > .tarball-version ./bootstrap.sh - ./configure + ./configure --enable-developer-mode - name: Generate release-specific changelog run: | echo "PRERELEASE=${{ contains(env.VERSION, '-alpha') || contains(env.VERSION, '-beta') || contains(env.VERSION, '-rc') }}" >> $GITHUB_ENV diff --git a/Makefile.am b/Makefile.am index 031bc8fc..8e209fb1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,5 @@ ACLOCAL_AMFLAGS = -I build-aux +AM_DISTCHECK_CONFIGURE_FLAGS = --enable-developer-mode .ONESHELL: .SECONDARY: @@ -68,17 +69,28 @@ prove: .PHONY: test test: prove -.PHONY: lint +PHONY_DEVELOPER_TARGETS = lint lint-editor-config lint-shellheck +.PHONY: $(PHONY_DEVELOPER_TARGETS) + +if DEVELOPER_MODE + lint: lint-editor-config lint-shellcheck -.PHONY: lint-editor-config lint-editor-config: ec -.PHONY: lint-shellheck lint-shellcheck: $(PACKAGE_NAME) shellcheck $< +else !DEVELOPER_MODE + +$(PHONY_DEVELOPER_TARGETS): + @: $(error "Please reconfigure using --enable-developer-mode to use developer tooling") + +endif !DEVELOPER_MODE + +if SOURCE_IS_GIT + CONTRIBUTORS: exec > $@ echo 'Alphabetical list of names of everyone who ever committed to this repository.' @@ -88,3 +100,5 @@ CONTRIBUTORS: changelog-HEAD: changelog sed -nEe '2d;s/^\t//p;/^$$/q;' $< > $@ + +endif SOURCE_IS_GIT diff --git a/build-aux/que_dist_checksums.m4 b/build-aux/que_dist_checksums.m4 index 5206b372..6848cdcc 100644 --- a/build-aux/que_dist_checksums.m4 +++ b/build-aux/que_dist_checksums.m4 @@ -1,13 +1,16 @@ AC_DEFUN_ONCE([QUE_DIST_CHECKSUMS], [ - QUE_PROGVAR([sha256sum]) - QUE_PROGVAR([tee]) + AM_COND_IF([DEVELOPER_MODE], [ - QUE_TRANSFORM_PACKAGE_NAME + QUE_PROGVAR([sha256sum]) + QUE_PROGVAR([tee]) - AC_REQUIRE([AX_AM_MACROS]) - AX_ADD_AM_MACRO([dnl + QUE_TRANSFORM_PACKAGE_NAME + + AC_REQUIRE([AX_AM_MACROS]) + AX_ADD_AM_MACRO([dnl $(cat build-aux/que_dist_checksums.am) ])dnl + ]) ]) diff --git a/build-aux/que_git_version.m4 b/build-aux/que_git_version.m4 index 7174a56f..56e7f18b 100644 --- a/build-aux/que_git_version.m4 +++ b/build-aux/que_git_version.m4 @@ -1,11 +1,5 @@ AC_DEFUN_ONCE([QUE_GIT_VERSION], [ - AC_PROG_AWK - AC_PROG_GREP - QUE_PROGVAR([cmp]) - - QUE_TRANSFORM_PACKAGE_NAME - AM_CONDITIONAL([SOURCE_IS_GIT], [test -d .git]) @@ -15,6 +9,13 @@ AC_DEFUN_ONCE([QUE_GIT_VERSION], [ AM_CONDITIONAL([SOURCE_IS_ARCHIVE], [test ! -d .git -a ! -f .tarball-version]) + AC_PROG_AWK + AC_PROG_GREP + + QUE_TRANSFORM_PACKAGE_NAME + + AM_COND_IF([SOURCE_IS_DIST], [], [QUE_PROGVAR([cmp])]) + AC_REQUIRE([AX_AM_MACROS]) AX_ADD_AM_MACRO([dnl $(cat build-aux/que_git_version.am) diff --git a/configure.ac b/configure.ac index b8166edd..928033aa 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ AC_ARG_WITH([standalone], []) QUE_TRANSFORM_PACKAGE_NAME +QUE_DEVELOPER_MODE # These macros must be run after processing our standalone setup because # they all expect the program name transformation setup to be complete. From d8b3af9cc72c262d1a384187cf74b3b60be951bc Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 7 Apr 2024 00:51:50 +0300 Subject: [PATCH 8/8] Add intermediate artifact to Git ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index df1f1210..db46c3d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vcsh.1 +doc/vcsh.1.ronn *.patch *.swp .swp