]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
examples:winexe: embed Samba version as exe timestamp
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 29 May 2024 22:44:24 +0000 (10:44 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 31 May 2024 01:28:06 +0000 (01:28 +0000)
It turns out the timestamp doesn't need to be real, and it isn't used,
but it might as well tell you something. So let's make it tell you what
version of Samba it came from, which could be useful for people who have
lots of old winexes lying around, the poor souls.

00000040  0e 1f ba 0e 00 b4 09 cd  21 b8 01 4c cd 21 54 68  |........!..L.!Th|
00000050  69 73 20 70 72 6f 67 72  61 6d 20 63 61 6e 6e 6f  |is program canno|
00000060  74 20 62 65 20 72 75 6e  20 69 6e 20 44 4f 53 20  |t be run in DOS |
00000070  6d 6f 64 65 2e 0d 0d 0a  24 00 00 00 00 00 00 00  |mode....$.......|
00000080  50 45 00 00 64 86 0a 00  00 15 04 00 00 00 00 00  |PE..d...........|
                                    |  |  |
                                    |  |  major  4.
                                    |  minor     21.
                                    release      0

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13213

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Fri May 31 01:28:06 UTC 2024 on atb-devel-224

examples/winexe/wscript

index a202282e76564fb8609404b38a81127d9c40a4ad..c4f13b89f01afad56cc6c16c4f54e4dba5d43915 100644 (file)
@@ -31,14 +31,21 @@ def configure(conf):
 
     source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH')
     if source_date_epoch is None:
-        # We set the timestamp to be 0, which makes the winexe build
-        # reproducible. According to
-        # https://learn.microsoft.com/en-us/windows/win32/debug/pe-format
+        # We use the version to make up the timestamp that will be
+        # embedded in winexe.exe, to keep the build reproducible.
         #
-        # > If the stamp value is 0 or 0xFFFFFFFF, it does not
-        # > represent a real or meaningful date/time stamp.
-
-        source_date_epoch = '0'
+        # This is less evil than it sounds. According to Raymond Chen in
+        # https://devblogs.microsoft.com/oldnewthing/20180103-00/?p=97705
+        # since Windows 10 the timestamp has been randomised.
+        #
+        # The purpose of the timestamp in Windows PE files seems to be
+        # to make spotting ABI changes in DLLs quicker, for which a
+        # random number is just as good as a real time. The timestamp
+        # in .exe files is not used.
+        import samba_version
+        v = samba_version.load_version(env=conf.env)
+        version = (v.MAJOR << 16) | (v.MINOR << 8) | v.RELEASE
+        source_date_epoch = str(version)
 
     conf.env.SOURCE_DATE_EPOCH = source_date_epoch
     conf.DEFINE("WINEXE_LDFLAGS",