xpra icon
Bug tracker and wiki

Ticket #2062: reproducible.patch

File reproducible.patch, 3.3 KB (added by Bernhard M. Wiedemann, 23 months ago)
  • add_build_info.py

    Author: Bernhard M. Wiedemann <bwiedemann suse de>
    Date: 2018-11-25
    
    Allow to override build date with SOURCE_DATE_EPOCH
    in order to make builds reproducible.
    See https://reproducible-builds.org/ for why this is good
    and https://reproducible-builds.org/specs/source-date-epoch/
    for the definition of this variable.
    
    Also drop varying BUILT_BY and BUILT_ON
    
    Without this patch, xpra packages varied for every build.
    
    This patch was done while working on reproducible builds for openSUSE.
    old new  
    66# later version. See the file COPYING for details.
    77
    88import datetime
     9import os
    910import subprocess
    1011import socket
     12import time
    1113import platform
    1214import os.path
    1315import re
    def record_build_info(is_build=True): 
    222224    global BUILD_INFO_FILE
    223225    props = get_properties(BUILD_INFO_FILE)
    224226    if is_build:
    225         try:
    226             import getpass
    227             set_prop(props, "BUILT_BY", getpass.getuser())
    228         except:
    229             set_prop(props, "BUILT_BY", os.environ.get("USER"))
    230         set_prop(props, "BUILT_ON", socket.gethostname())
    231         set_prop(props, "BUILD_DATE", datetime.date.today().isoformat())
    232         set_prop(props, "BUILD_TIME", datetime.datetime.now().strftime("%H:%M"))
     227        build_date = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
     228        set_prop(props, "BUILD_DATE", build_date.date().isoformat())
     229        set_prop(props, "BUILD_TIME", build_date.strftime("%H:%M"))
    233230        set_prop(props, "BUILD_MACHINE", get_machineinfo())
    234231        set_prop(props, "BUILD_CPU", get_cpuinfo())
    235232        set_prop(props, "BUILD_BIT", platform.architecture()[0])
  • xpra/scripts/config.py

    old new def get_build_info(): 
    221221    except Exception as e:
    222222        warn("Error: could not find the source information: %s" % e)
    223223    try:
    224         from xpra.build_info import BUILT_BY, BUILT_ON, BUILD_DATE, BUILD_TIME, BUILD_BIT, CYTHON_VERSION, COMPILER_VERSION    #@UnresolvedImport
     224        from xpra.build_info import BUILD_DATE, BUILD_TIME, BUILD_BIT, CYTHON_VERSION, COMPILER_VERSION    #@UnresolvedImport
    225225        if BUILD_BIT:
    226226            info.insert(0, "")
    227227            info.insert(0, BUILD_BIT)
    228         info.append("built on %s by %s" % (BUILT_ON, BUILT_BY))
    229228        if BUILD_DATE and BUILD_TIME:
    230229            info.append("%s %s" % (BUILD_DATE, BUILD_TIME))
    231230        if CYTHON_VERSION!="unknown" or COMPILER_VERSION!="unknown":
  • xpra/version_util.py

    old new def get_version_info_full(): 
    102102        for k,bk in {
    103103                    "date"                 : "BUILD_DATE",
    104104                    "time"                 : "BUILD_TIME",
    105                     "by"                   : "BUILT_ON",
    106105                    "bit"                  : "BUILD_BIT",
    107106                    "cpu"                  : "BUILD_CPU",
    108107                    "compiler"             : "COMPILER_VERSION",