[ipxe-devel] [PATCH] reproducible timestamp

Neil Roza neil at rtr.ai
Mon May 11 14:02:56 UTC 2020

Hello ipxe-devel,

While I work on a reproducible build-id, there's no reason this patch for a
reproducible timestamp needs to wait for it. Hence, the attached (and below
inlined) patch diff allows a reproducible `BUILD_TIMESTAMP` when the
following criteria are satisfied:

* `git` command is available
* the ipxe source tree is a git checkout
* the git checkout is "clean" (no diff between working tree and index)

If the aforementioned are satisfied, then the `BUILD_TIMESTAMP` is assigned
the Unix timestamp of the HEAD commit. Otherwise, the `BUILD_TIMESTAMP` is
assigned the Unix timestamp of "now"; i.e., heretofore legacy behavior.

Inline diff follows...

diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index 1dd14794..126a082a 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -1168,9 +1168,14 @@ blib : $(BLIB)
 BUILD_ID_CMD := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'

+# assumes first element in MAKEFILE_LIST is src/Makefile:
+IPXE_DIR := $(abspath $(dir $(abspath $(firstword $(MAKEFILE_LIST))))/..)
 # Build timestamp
-BUILD_TIMESTAMP := $(shell date +%s)
+BUILD_TIMESTAMP := $(shell git -C $(IPXE_DIR) diff-files --quiet \
+  && git -C $(IPXE_DIR) show -s --format=%ct HEAD \
+  || date +%s)

 # Build version
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20200511/4d53126e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reproducible-timestamp.diff
Type: text/x-patch
Size: 634 bytes
Desc: not available
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20200511/4d53126e/attachment.bin>

More information about the ipxe-devel mailing list