[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser-bundle/master] Add pyc-timestamp.sh to stomp .pyc timestamps.



commit 45fcec44287881aff273c9a5eb366e7ceb2a97f8
Author: David Fifield <david@xxxxxxxxxxxxxxx>
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



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits