diff --git a/.github/workflows/docbuild.yml b/.github/workflows/docbuild.yml index 3f8d9dfc05..68f8fcfe7d 100644 --- a/.github/workflows/docbuild.yml +++ b/.github/workflows/docbuild.yml @@ -26,3 +26,11 @@ jobs: - name: Build docs run: | make -C docs html doctest; + - name: Test building manpages + run: | + # with custom date + DATALAD_SOURCE_EPOCH=100000000 python setup.py build_manpage + grep '\.TH "datalad" "1" "1973' ./build/man/datalad.1 + # no custom date - should be good for the next 980 years + python setup.py build_manpage + grep '\.TH "datalad" "1" "2' ./build/man/datalad.1 diff --git a/_datalad_build_support/formatters.py b/_datalad_build_support/formatters.py index 56f5bc8146..dcca697f44 100644 --- a/_datalad_build_support/formatters.py +++ b/_datalad_build_support/formatters.py @@ -7,7 +7,9 @@ import argparse import datetime +import os import re +import time from textwrap import wrap @@ -25,7 +27,7 @@ def __init__(self, authors=None, version=None ): - + from datalad import cfg super(ManPageFormatter, self).__init__( prog, indent_increment=indent_increment, @@ -34,7 +36,9 @@ def __init__(self, self._prog = prog self._section = 1 - self._today = datetime.date.today().strftime('%Y\\-%m\\-%d') + self._today = datetime.datetime.utcfromtimestamp( + cfg.obtain('datalad.source.epoch') + ).strftime('%Y\\-%m\\-%d') self._ext_sections = ext_sections self._version = version diff --git a/changelog.d/pr-6997.md b/changelog.d/pr-6997.md new file mode 100644 index 0000000000..0b6f88694f --- /dev/null +++ b/changelog.d/pr-6997.md @@ -0,0 +1,6 @@ +### Internal + +- Introduce datalad.source.epoch configuration to make the build reproducible + (on Debian only ATM) by providing date to use in the manpages. + [PR #6997](https://github.com/datalad/datalad/pull/6997) (by + [@yarikoptic](https://github.com/yarikoptic)) diff --git a/datalad/interface/common_cfg.py b/datalad/interface/common_cfg.py index efc6528a38..dc67ac68ec 100644 --- a/datalad/interface/common_cfg.py +++ b/datalad/interface/common_cfg.py @@ -17,6 +17,7 @@ from os import environ from os.path import expanduser from os.path import join as opj +import time from platformdirs import AppDirs @@ -24,6 +25,7 @@ EnsureBool, EnsureChoice, EnsureInt, + EnsureFloat, EnsureListOf, EnsureNone, EnsureStr, @@ -709,6 +711,18 @@ def get_default_ssh(): 'type': EnsureChoice('warning', 'error', 'none'), 'default': 'warning', + }, + 'datalad.source.epoch': { + 'ui': ('question', { + 'title': 'Datetime epoch to use for dates in built materials', + 'text': "Datetime to use for reproducible builds. Originally introduced " + "for Debian packages to interface SOURCE_DATE_EPOCH described at " + "https://reproducible-builds.org/docs/source-date-epoch/ ." + "By default - current time" + }), + 'type': EnsureFloat(), + 'default': time.time(), + }, 'datalad.ssh.executable': { 'ui': ('question', {