Make the generated man page reproducible

This commit is contained in:
Chih-Hsuan Yen 2021-01-17 17:20:10 +08:00
parent 491a71add7
commit 91daf5ad4d
No known key found for this signature in database
GPG Key ID: 0453A6CA23C56315
1 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@
import time import time
import locale import locale
import os
import sys import sys
try: try:
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
@ -50,6 +51,12 @@ class MyTranslator(manpage.Translator):
self._docinfo['subtitle'] = 'New version checker for software releases' self._docinfo['subtitle'] = 'New version checker for software releases'
self._docinfo['title_upper'] = 'nvchecker'.upper() self._docinfo['title_upper'] = 'nvchecker'.upper()
self._docinfo['manual_section'] = '1' self._docinfo['manual_section'] = '1'
# Make the generated man page reproducible. Based on the patch from
# https://sourceforge.net/p/docutils/patches/132/#5333
source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH')
if source_date_epoch:
self._docinfo['date'] = time.strftime('%Y-%m-%d', time.gmtime(int(source_date_epoch)))
else:
self._docinfo['date'] = time.strftime('%Y-%m-%d') self._docinfo['date'] = time.strftime('%Y-%m-%d')
self._docinfo['version'] = nvchecker.__version__ self._docinfo['version'] = nvchecker.__version__
raise raise