Skip to content

Commit

Permalink
Make build reproducible by implementing SOURCE_DATE_EPOCH env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
davazp committed May 2, 2018
1 parent 884f669 commit 58beddf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
3 changes: 3 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ done
shift `expr $OPTIND - 1`
OPTIND=1

# Unix timestamp of the commit we are building
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)

sbcl --load "$BASE/jscl.lisp" --eval "(jscl:bootstrap $VERBOSE)" --eval '(quit)'
31 changes: 21 additions & 10 deletions src/toplevel.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,27 @@


(defun compilation-notice ()
#.(multiple-value-bind (second minute hour date month year)
(get-decoded-time)
(declare (ignore second minute hour))
(format nil "built on ~d ~a ~d"
date
(elt #("" "January" "February" "March" "April" "May" "June"
"July" "August" "September" "October" "November"
"December")
month)
year)))
#.(let ((build-time
;; The variable SOURCE_DATE_EPOCH specifies the point in
;; time of the project. It is usually set to the unix
;; timestamp of the GIT commit being built, to make the
;; build artifact reproducible. Variable is specified at
;;
;; https://reproducible-builds.org/specs/source-date-epoch/
;;
(if (sb-posix:getenv "SOURCE_DATE_EPOCH")
(+ (parse-integer (sb-posix:getenv "SOURCE_DATE_EPOCH")) 2208988800)
(get-universal-time))))
(multiple-value-bind (second minute hour date month year)
(decode-universal-time build-time)
(declare (ignore second minute hour))
(format nil "built on ~d ~a ~d"
date
(elt #("" "January" "February" "March" "April" "May" "June"
"July" "August" "September" "October" "November"
"December")
month)
year))))

(when (and (string/= (%js-typeof |module|) "undefined")
(string= (%js-typeof |phantom|) "undefined"))
Expand Down

0 comments on commit 58beddf

Please sign in to comment.