--- engine/SCons/Platform/msys.py.orig	2015-05-06 15:26:45.478712800 +0200
+++ engine/SCons/Platform/msys.py	2015-05-06 15:33:07.915575600 +0200
@@ -38,6 +38,21 @@
 def generate(env):
     posix.generate(env)
 
+    # (copied from win32.py, for when msys2 scons is used for building mingw packages)
+    # Import things from the external environment to the construction
+    # environment's ENV.  This is a potential slippery slope, because we
+    # *don't* want to make builds dependent on the user's environment by
+    # default.  We're doing this for SystemRoot, though, because it's
+    # needed for anything that uses sockets, and seldom changes, and
+    # for SystemDrive because it's related.
+    #
+    # Weigh the impact carefully before adding other variables to this list.
+    import_env = [ 'SystemDrive', 'SystemRoot', 'TEMP', 'TMP' ]
+    for var in import_env:
+        v = os.environ.get(var)
+        if v:
+            env['ENV'][var] = v
+
     env['ENV']['PATH'] = os.getenv('PATH')
     env['SPAWN']       = (lambda sh, esc, cmd, args, env_param:
                           subprocess.call(['sh', '-c', ' '.join(args)]))
