[tor-commits] [tor-browser-bundle/master] Add pyc-timestamp.sh to stomp .pyc timestamps.
mikeperry at torproject.org
mikeperry at torproject.org
Tue Jan 21 04:47:04 UTC 2014
commit 45fcec44287881aff273c9a5eb366e7ceb2a97f8
Author: David Fifield <david at bamsoftware.com>
Date: Mon Dec 2 04:00:10 2013 +0000
Add pyc-timestamp.sh to stomp .pyc timestamps.
---
gitian/build-helpers/pyc-timestamp.sh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/gitian/build-helpers/pyc-timestamp.sh b/gitian/build-helpers/pyc-timestamp.sh
new file mode 100755
index 0000000..e092268
--- /dev/null
+++ b/gitian/build-helpers/pyc-timestamp.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Usage: pyc-timestamp.sh "2001-01-01" FILENAMES...
+# Overwrite (in place) the timestamp in .pyc Python bytecode files.
+#
+# http://hg.python.org/cpython/file/2.7/Lib/py_compile.py#l123
+# http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html
+# http://benno.id.au/blog/2013/01/15/python-determinism
+
+TIMESPEC="$1"
+shift
+
+hex=$(printf 0x%08x $(date +%s --date="$TIMESPEC"))
+# Write little-endian.
+esc=$(printf "\\\\x%02x\\\\x%02x\\\\x%02x\\\\x%02x" $(($hex&0xff)) $((($hex>>8)&0xff)) $((($hex>>16)&0xff)) $((($hex>>24)&0xff)))
+for filename in "$@"; do
+ echo $filename
+ echo -n -e "$esc" | dd of="$filename" bs=1 seek=4 conv=notrunc
+done
More information about the tor-commits
mailing list