Author: Danny Milosavljevic <dannym@friendly-machines.com>
Date: Mon Jun  9 01:19:28 PM CEST 2025
Subject: Make mono 2.4.2.3 reprodubile.

diff -ru orig/mono-1.9.1-checkout/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs mono-1.9.1-checkout/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
--- orig/mono-1.9.1-checkout/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs	2025-06-09 11:58:58.679365113 +0200
+++ mono-1.9.1-checkout/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs	2025-06-09 19:10:46.839764717 +0200
@@ -80,7 +80,7 @@
 			this.assembly = this.assemblyb = assb;
 			this.transient = transient;
 			// to keep mcs fast we do not want CryptoConfig wo be involved to create the RNG
-			guid = Guid.FastNewGuidArray ();
+			guid = new byte[16]; // = Guid.Empty.ToByteArray();
 			// guid = Guid.NewGuid().ToByteArray ();
 			table_idx = get_next_table_index (this, 0x00, true);
 			name_cache = new Hashtable ();
diff -ru orig/mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs
--- orig/mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs	2025-06-09 11:58:58.233978153 +0200
+++ mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs	2025-06-09 16:46:46.086454131 +0200
@@ -132,6 +132,15 @@
 
 		public static uint TimeDateStampFromEpoch ()
 		{
+			string sourceDateEpoch = Environment.GetEnvironmentVariable("SOURCE_DATE_EPOCH");
+			if (sourceDateEpoch != null && sourceDateEpoch != "") {
+				try {
+					return uint.Parse(sourceDateEpoch);
+				} catch {
+					// fallthrough
+				}
+			}
+			
 			return (uint) DateTime.UtcNow.Subtract (
 				new DateTime (1970, 1, 1)).TotalSeconds;
 		}
diff -ru orig/mono-1.9.1-checkout/mono/metadata/reflection.c mono-1.9.1-checkout/mono/metadata/reflection.c
--- orig/mono-1.9.1-checkout/mono/metadata/reflection.c	2025-06-09 11:58:58.903462701 +0200
+++ mono-1.9.1-checkout/mono/metadata/reflection.c	2025-06-09 18:44:58.063693593 +0200
@@ -4851,7 +4851,7 @@
 	
 	header->coff.coff_machine = GUINT16_FROM_LE (assemblyb->machine);
 	header->coff.coff_sections = GUINT16_FROM_LE (nsections);
-	header->coff.coff_time = GUINT32_FROM_LE (time (NULL));
+	header->coff.coff_time = GUINT32_FROM_LE (getenv("SOURCE_DATE_EPOCH") ? atoi(getenv("SOURCE_DATE_EPOCH")) : time (NULL));
 	header->coff.coff_opt_header_size = GUINT16_FROM_LE (sizeof (MonoDotNetHeader) - sizeof (MonoCOFFHeader) - 4);
 	if (assemblyb->pekind == 1) {
 		/* it's a dll */
--- orig/mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs	2025-06-09 12:02:28.730111085 +0200
+++ mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs	2025-07-06 22:58:49.428864166 +0200
@@ -157,7 +157,7 @@
 			m_asm = asm;
 			m_main = main;
 #if !CF_1_0
-			m_mvid = Guid.NewGuid ();
+			m_mvid = new Guid ("00000000-0000-0000-0000-000000000000");
 #endif
 			if (reader != null) {
 				m_image = reader.Image;
--- orig/mono-1.9.1-checkout/mcs/tools/linker/Mono.Linker.Steps/RegenerateGuidStep.cs	2025-06-09 12:02:29.661239244 +0200
+++ mono-1.9.1-checkout/mcs/tools/linker/Mono.Linker.Steps/RegenerateGuidStep.cs	2025-07-06 23:24:40.832000925 +0200
@@ -42,7 +42,7 @@
 
 		static void RegenerateGuid (AssemblyDefinition asm)
 		{
-			asm.MainModule.Mvid = Guid.NewGuid ();
+			asm.MainModule.Mvid = new Guid ("00000000-0000-0000-0000-000000000000");
 		}
 	}
 }
 --- orig/mono-1.9.1-checkout/mcs/class/PEAPI/Metadata.cs	2025-06-09 12:02:28.806649345 +0200
+++ mono-1.9.1-checkout/mcs/class/PEAPI/Metadata.cs	2025-07-06 23:27:43.307602709 +0200
@@ -2689,7 +2689,7 @@
 
 		internal Module(string name, MetaData md) : base(name,md)       
 		{
-			mvid = Guid.NewGuid();
+			mvid = new Guid ("00000000-0000-0000-0000-000000000000"); // not actually used
 			mvidIx = md.AddToGUIDHeap(mvid);
 			tabIx = MDTable.Module;
 		}
--- orig/mono-1.9.1-checkout/mcs/tools/monodoc/Monodoc/provider.cs	2025-06-09 12:02:29.686320502 +0200
+++ mono-1.9.1-checkout/mcs/tools/monodoc/Monodoc/provider.cs	2025-07-07 00:16:31.017632290 +0200
@@ -638,6 +638,10 @@
 	void PackStream (Stream s, string entry_name, string realPath)
 	{
 		ZipEntry entry = new ZipEntry (entry_name);
+		string epoch = Environment.GetEnvironmentVariable("SOURCE_DATE_EPOCH");
+		if (epoch != null && epoch != "") {
+			entry.DateTime = new DateTime(1970, 1, 1).AddSeconds(long.Parse(epoch));
+		}
 				
 		if (realPath != null)
 			entry.ExtraData = ConvertToArray (realPath);
@@ -653,6 +657,11 @@
 	public void PackXml (string fname, XmlDocument doc, string real_path)
 	{ 
 		ZipEntry entry = new ZipEntry (fname); 
+		string epoch = Environment.GetEnvironmentVariable("SOURCE_DATE_EPOCH");
+		if (epoch != null && epoch != "") {
+			entry.DateTime = new DateTime(1970, 1, 1).AddSeconds(long.Parse(epoch));
+		}
+
 		if (real_path != null) 
 			entry.ExtraData = ConvertToArray(real_path);
