From 1a35671e9afe98f4c353ef2e8952777d2e21c170 Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Wed, 31 Aug 2022 09:25:03 -0400 Subject: [PATCH 1/3] Make the build reproducible (on Debian) via SOURCE_DATE_EPOCH for dates in manpages I think it is worth adding to our codebase to avoid posssible conflicts in the patch and also to facilitate similar reproducibility in other distributions where so would be desired. Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010318 --- _datalad_build_support/formatters.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_datalad_build_support/formatters.py b/_datalad_build_support/formatters.py index 56f5bc8146..73f6678e0a 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 @@ -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( + int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) + ).strftime('%Y\\-%m\\-%d') self._ext_sections = ext_sections self._version = version From 130db430fdd4fea0300cbe00f7567c31d4dd9b24 Mon Sep 17 00:00:00 2001 From: DataLad Bot Date: Wed, 31 Aug 2022 14:28:54 +0000 Subject: [PATCH 2/3] [skip ci] Autogenerate changelog.d snippet for pull request --- changelog.d/pr-6997.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog.d/pr-6997.md diff --git a/changelog.d/pr-6997.md b/changelog.d/pr-6997.md new file mode 100644 index 0000000000..b99b2b613b --- /dev/null +++ b/changelog.d/pr-6997.md @@ -0,0 +1,5 @@ +### Internal + +- Make the build reproducible (on Debian) via SOURCE_DATE_EPOCH for dates in + manpages. [PR #6997](https://github.com/datalad/datalad/pull/6997) (by + [@yarikoptic](https://github.com/yarikoptic)) From ce8540c29b3fc008c47d2f9d184fdac91daf2815 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 1 Sep 2022 11:23:15 -0400 Subject: [PATCH 3/3] RF: SOURCE_DATE_EPOCH -> datalad.source.epoch config --- .github/workflows/docbuild.yml | 8 ++++++++ _datalad_build_support/formatters.py | 4 ++-- changelog.d/pr-6997.md | 5 +++-- datalad/interface/common_cfg.py | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) 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 73f6678e0a..dcca697f44 100644 --- a/_datalad_build_support/formatters.py +++ b/_datalad_build_support/formatters.py @@ -27,7 +27,7 @@ def __init__(self, authors=None, version=None ): - + from datalad import cfg super(ManPageFormatter, self).__init__( prog, indent_increment=indent_increment, @@ -37,7 +37,7 @@ def __init__(self, self._prog = prog self._section = 1 self._today = datetime.datetime.utcfromtimestamp( - int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) + 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 index b99b2b613b..0b6f88694f 100644 --- a/changelog.d/pr-6997.md +++ b/changelog.d/pr-6997.md @@ -1,5 +1,6 @@ ### Internal -- Make the build reproducible (on Debian) via SOURCE_DATE_EPOCH for dates in - manpages. [PR #6997](https://github.com/datalad/datalad/pull/6997) (by +- 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', {