From 967b724e75469e63a123b4123f4d02c65034a0cb Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 14 Oct 2023 15:15:41 +0300 Subject: [PATCH] build: avoid dynamic dates for reproducibility We were using dates (in documentation, (c) notices etc) based on the build-date; that makes it hard to do reproducible builds, so specify a specific date in the top-level meson file, and use that throughout. --- build-aux/version.texi.in | 1 + guile/mu-guile.texi | 2 +- man/meson.build | 13 +++---------- meson.build | 34 ++++++++++++++++++++++++++-------- mu4e/meson.build | 13 ------------- mu4e/mu4e.texi | 2 +- 6 files changed, 32 insertions(+), 33 deletions(-) diff --git a/build-aux/version.texi.in b/build-aux/version.texi.in index 77a20733..aa13babc 100644 --- a/build-aux/version.texi.in +++ b/build-aux/version.texi.in @@ -1,4 +1,5 @@ @set UPDATED @UPDATED@ @set UPDATED-MONTH @UPDATEDMONTH@ +@set UPDATED-YEAR @UPDATEDYEAR@ @set EDITION @VERSION@ @set VERSION @VERSION@ diff --git a/guile/mu-guile.texi b/guile/mu-guile.texi index ae238b20..9eae2fee 100644 --- a/guile/mu-guile.texi +++ b/guile/mu-guile.texi @@ -14,7 +14,7 @@ @include version.texi @copying -Copyright @copyright{} 2012 Dirk-Jan C. Binnema +Copyright @copyright{} 2012-@value{UPDATED-YEAR} Dirk-Jan C. Binnema @quotation Permission is granted to copy, distribute and/or modify this document diff --git a/man/meson.build b/man/meson.build index d0ae3ee7..d3242606 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,4 +1,4 @@ -## Copyright (C) 2021 Dirk-Jan C. Binnema +## Copyright (C) 2021-2023 Dirk-Jan C. Binnema ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -63,13 +63,7 @@ man_orgs=[ 'mu-view.1.org' ] -env = environment() -env.set('LANG', 'C') -yearmonth = run_command('date', '+%B %Y', check:true, capture:true, env: env) -ym=yearmonth.stdout().strip() - foreach src : man_orgs - # meson makes in tricky to use the results of e.g. configure_file # in custom_commands..., so this is admittedly a little hacky. org = join_paths(meson.current_build_dir(), src) @@ -81,15 +75,14 @@ foreach src : man_orgs # @MAN_DATE@: date of the generation (not yet supported by ox-man) conf_data = configuration_data() conf_data.set('SECTION_ID', section) - conf_data.set('MAN_DATE', ym) + conf_data.set('MAN_DATE', mu_month_year) configure_file(input: src, output:'@BASENAME@.org', configuration: conf_data) expr_tmpl = ''.join([ '(progn', ' (require \'ox-man)', - ' (org-export-to-file \'man "@0@"))', - ]) + ' (org-export-to-file \'man "@0@"))']) expr = expr_tmpl.format(org.substring(0,-4)) sectiondir = join_paths(mandir, 'man' + section) diff --git a/meson.build b/meson.build index 1054ced2..e50f7f82 100644 --- a/meson.build +++ b/meson.build @@ -24,9 +24,11 @@ project('mu', ['c', 'cpp'], 'buildtype=debugoptimized', 'warning_level=3', 'c_std=c11', - 'cpp_std=c++17' - ] - ) + 'cpp_std=c++17']) + +# hard-code the date here (for reproduciblity); we derive the dates used in e.g. +# documentation from this. +mu_date='2023-10-14' # installation paths prefixdir = get_option('prefix') @@ -42,7 +44,6 @@ else mu4e_lispdir= get_option('lispdir') / 'mu4e' endif - ################################################################################ # compilers / flags # @@ -97,6 +98,22 @@ endforeach # https://github.com/djcb/mu/issues/2347 cxx.check_header('charconv', required:true) + +################################################################################ +# derived date values (based on 'mu-date'); used in docs +date=find_program('date', required:true) +env = environment() +env.set('LANG', 'C') +mu_day_month_year = run_command(date, '-u', '+%d %B %Y', '--date', mu_date, + check:true, capture:true, + env: env).stdout().strip() +mu_month_year = run_command(date, '-u', '+%B %Y', '--date', mu_date, + check:true, capture:true, + env: env).stdout().strip() +mu_year = run_command(date, '-u', '+%Y', '--date', mu_date, + check:true, capture:true, env: env).stdout().strip() + + ################################################################################ # config.h setup # @@ -244,10 +261,11 @@ endif version_texi_data=configuration_data() version_texi_data.set('VERSION', meson.project_version()) version_texi_data.set('EDITION', meson.project_version()) -version_texi_data.set('UPDATED', - run_command('date', '+%d %B %Y', check:true).stdout().strip()) -version_texi_data.set('UPDATEDMONTH', - run_command('date', '+%B %Y', check:true).stdout().strip()) + +# derived date values +version_texi_data.set('UPDATED', mu_day_month_year) +version_texi_data.set('UPDATEDMONTH', mu_month_year) +version_texi_data.set('UPDATEDYEAR', mu_year) configure_file(input: join_paths('build-aux', 'version.texi.in'), output: 'version.texi', diff --git a/mu4e/meson.build b/mu4e/meson.build index b6dbc06b..a2a22bbd 100644 --- a/mu4e/meson.build +++ b/mu4e/meson.build @@ -126,19 +126,6 @@ install_data(mu4e_srcs, install_dir: mu4e_lispdir) install_data('mu4e-about.org', install_dir : join_paths(datadir, 'doc', 'mu')) if makeinfo.found() - - fulldate = run_command('date', '+%d %B %Y', check:true).stdout().strip() - monthdate = run_command('date', '+%B %Y', check:true).stdout().strip() - version_texi_data = configuration_data({ - 'fulldate' : fulldate, - 'monthdate' : monthdate, - 'version' : meson.project_version(), - }) - version_texi = configure_file( - input: 'version.texi.in', - output: 'version.texi', - configuration: version_texi_data) - custom_target('mu4e_info', input: 'mu4e.texi', output: 'mu4e.info', diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi index bd1e6426..96867053 100644 --- a/mu4e/mu4e.texi +++ b/mu4e/mu4e.texi @@ -12,7 +12,7 @@ @c %**end of header @copying -Copyright @copyright{} 2012-2023 Dirk-Jan C. Binnema +Copyright @copyright{} 2012-@value{UPDATED-YEAR} Dirk-Jan C. Binnema @quotation Permission is granted to copy, distribute and/or modify this document