From e3992118c870507c76684bcd756f05ad9f2dada7 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Mon, 28 Mar 2022 20:46:07 +0200 Subject: [PATCH] [configure.ac] Added --enable-reproducible and --with-source-date-epoch=TIME Example of usage: ./autogen.sh ./configure ... \ --enable-reproducible \ --with-source-date-epoch=$(git log -1 --pretty=%ct) make make -C doc html --- Makefile.config.in | 2 +- configure.ac | 10 ++++++++++ doc/tools/asciidoc/asciidoc.py | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile.config.in b/Makefile.config.in index f68c8fcfe..5b2e8ada5 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -50,7 +50,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ host = @host@ -ASCIIDOC = @PYTHON3@ $(top_srcdir)/doc/tools/asciidoc/asciidoc.py +ASCIIDOC = LANG=C LANGUAGE=en CONFIG_REPRODUCIBLE=@CONFIG_REPRODUCIBLE@ SOURCE_DATE_EPOCH=@SOURCE_DATE_EPOCH@ @PYTHON3@ $(top_srcdir)/doc/tools/asciidoc/asciidoc.py ASCIIDOC_FLAGS = --unsafe AWK = @AWK@ CATALOGS = @CATALOGS@ diff --git a/configure.ac b/configure.ac index 1321c5d3a..1791120ab 100644 --- a/configure.ac +++ b/configure.ac @@ -1600,12 +1600,22 @@ EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8], EL_ARG_DEPEND(CONFIG_COMBINE, combining, [CONFIG_UTF8:yes HAVE_WCWIDTH:yes], [Combining characters], [ --enable-combining support Unicode combining characters (experimental)]) +EL_ARG_ENABLE(CONFIG_REPRODUCIBLE, reproducible, [Reproducible builds], + [ --enable-reproducible enable reproducible build]) + AC_ARG_ENABLE(weehoofooboomookerchoo, [ Also check out the features.conf file for more information about features! ], [AC_MSG_ERROR(Are you strange, or what?)]) +SOURCE_DATE_EPOCH= +AC_ARG_WITH(source-date-epoch, [ --with-source-date-epoch=[TIME] + set source date epoch for reproducible builds], + [SOURCE_DATE_EPOCH="$withval"]) + +AC_SUBST(SOURCE_DATE_EPOCH) + # =================================================================== # Decide whether to use TRE diff --git a/doc/tools/asciidoc/asciidoc.py b/doc/tools/asciidoc/asciidoc.py index a488df5ef..f1e08fac1 100755 --- a/doc/tools/asciidoc/asciidoc.py +++ b/doc/tools/asciidoc/asciidoc.py @@ -1061,7 +1061,8 @@ class Document: self.safe = True # Default safe mode. def init_attrs(self): # Set implicit attributes. - if os.environ.get('CONFIG_REPRODUCIBLE', ''): + repro = os.environ.get('CONFIG_REPRODUCIBLE', '') + if repro and repro != 'no': d = time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) self.attributes['localdate'] = time.strftime('%d-%b-%Y',d) s = time.strftime('%H:%M:%S %z',d)