Skip to content

Commit

Permalink
Merge pull request #6997 from yarikoptic/enh-reprobuild
Browse files Browse the repository at this point in the history
Make the manpages build reproducible via datalad.source.epoch (to be used in Debian packaging)
  • Loading branch information
yarikoptic committed Sep 1, 2022
2 parents 6a21dab + ce8540c commit 5767ee4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/docbuild.yml
Expand Up @@ -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
8 changes: 6 additions & 2 deletions _datalad_build_support/formatters.py
Expand Up @@ -7,7 +7,9 @@

import argparse
import datetime
import os
import re
import time
from textwrap import wrap


Expand All @@ -25,7 +27,7 @@ def __init__(self,
authors=None,
version=None
):

from datalad import cfg
super(ManPageFormatter, self).__init__(
prog,
indent_increment=indent_increment,
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions 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))
14 changes: 14 additions & 0 deletions datalad/interface/common_cfg.py
Expand Up @@ -17,13 +17,15 @@
from os import environ
from os.path import expanduser
from os.path import join as opj
import time

from platformdirs import AppDirs

from datalad.support.constraints import (
EnsureBool,
EnsureChoice,
EnsureInt,
EnsureFloat,
EnsureListOf,
EnsureNone,
EnsureStr,
Expand Down Expand Up @@ -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', {
Expand Down

0 comments on commit 5767ee4

Please sign in to comment.