From 93a613f6ccd20e2c60bf32c102b12458e47bcf9b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 13 Nov 2022 11:35:43 -0500 Subject: Add example site_init.py to propagate SOURCE_DATE_EPOCH from users shell environment to support reproducible builds. This is replacement logic for PR #4239 --- README.rst | 8 ++++++++ packaging/etc/README.txt | 0 packaging/etc/reproducible_install.sh | 19 +++++++++++++++++++ packaging/etc/reproducible_site_init.py | 23 +++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 packaging/etc/README.txt create mode 100644 packaging/etc/reproducible_install.sh create mode 100644 packaging/etc/reproducible_site_init.py diff --git a/README.rst b/README.rst index 1cc390d..bf34fd1 100755 --- a/README.rst +++ b/README.rst @@ -258,6 +258,14 @@ software, or hardware) to support continued work on the project. Information is available at https://www.scons.org/donate.html or the GitHub Sponsors button on https://github.com/scons/scons. +Reproducible Builds +=================== +In order to suppor those users who which to produce reproducible builds +(https://reproducible-builds.org/specs/source-date-epoch/) we're now including +logic to force SCons to propagate SOURCE_DATE_EPOCH from your shell environment for +all SCons builds to support reproducible builds we're now providing an example +site_init.py and a script to install it in your ~/.scons. See packaging/etc/README.txt +for more info For More Information ==================== diff --git a/packaging/etc/README.txt b/packaging/etc/README.txt new file mode 100644 index 0000000..e69de29 diff --git a/packaging/etc/reproducible_install.sh b/packaging/etc/reproducible_install.sh new file mode 100644 index 0000000..2eb6ad1 --- /dev/null +++ b/packaging/etc/reproducible_install.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e +set -x + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +mkdir -p ~/.site_scons + +if [ ! -f "~/.site_scons/site_init.py" ] +then + echo "File ~/.site_scons/site_init.py does not exist" + echo "We will add one which supports reproducible builds" + cp ${SCRIPT_DIR}/site_init.py ~/.site_scons/site_init.py +else + echo "File ~/.site_scons/site_init.py already exists" + echo "We will not overwrite it. Please copy the content" + echo "from ${SCRIPT_DIR}/site_init.py" +fi diff --git a/packaging/etc/reproducible_site_init.py b/packaging/etc/reproducible_site_init.py new file mode 100644 index 0000000..e4672a1 --- /dev/null +++ b/packaging/etc/reproducible_site_init.py @@ -0,0 +1,23 @@ +""" +Use this file as your ~/.site_scons/scons_init.py to enable reprodicble builds as described at +https://reproducible-builds.org/specs/source-date-epoch/ +""" + +import os +import SCons.Environment + +old_init = SCons.Environment.Base.__init__ + + +def new_init(self, **kw): + """ + This logic will add SOURCE_DATE_EPOCH to the execution environment used to run + all the build commands. + """ + print("In my custom init") + old_init(self, **kw) + if 'SOURCE_DATE_EPOCH' in os.environ: + self._dict['ENV']['SOURCE_DATE_EPOCH'] = os.environ['SOURCE_DATE_EPOCH'] + + +SCons.Environment.Base.__init__ = new_init -- cgit v0.12