Last-Update: 2016-03-13
Forwarded: not-needed
Author: Dmitry Smirnov <onlyjob@member.fsf.org>
Reviewed-By: Reiner Herrmann <reiner@reiner-h.de>
Description: customise build info
 * get build date/time from changelog.
 * get revision from "svn-version" file.
 * inject package version as "changes".
 * reduce determinism (reproducible build).

--- a/add_build_info.py
+++ b/add_build_info.py
@@ -202,9 +202,9 @@
         return "Microsoft Windows"
     if sys.platform.find("bsd")>=0:
         return "BSD"
     if sys.platform.find("linux")>=0 and hasattr(platform, "linux_distribution"):
-        return "Linux %s" % (" ".join(platform.linux_distribution()))
+        return "%s" % (" ".join(platform.linux_distribution()))
     return sys.platform
 
 
 BUILD_INFO_FILE = "./xpra/build_info.py"
@@ -216,12 +216,13 @@
             import getpass
             set_prop(props, "BUILT_BY", getpass.getuser())
         except:
             set_prop(props, "BUILT_BY", os.environ.get("USER"))
-        set_prop(props, "BUILT_ON", socket.gethostname())
-        set_prop(props, "BUILD_DATE", datetime.date.today().isoformat())
-        set_prop(props, "BUILD_TIME", datetime.datetime.now().strftime("%H:%M"))
-        set_prop(props, "BUILD_CPU", get_cpuinfo())
+        set_prop(props, "BUILT_BY", "Debian")
+        set_prop(props, "BUILT_ON", "Debian")
+        set_prop(props, "BUILD_DATE", subprocess.Popen("date -u --date=\"$(dpkg-parsechangelog -SDate)\" +%F", stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).stdout.read()[:-1])
+        set_prop(props, "BUILD_TIME", subprocess.Popen("date -u --date=\"$(dpkg-parsechangelog -SDate)\" +%R", stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).stdout.read()[:-1])
+        set_prop(props, "BUILD_CPU", "Generic CPU")
         set_prop(props, "BUILD_BIT", platform.architecture()[0])
         set_prop(props, "BUILD_OS", get_platform_name())
         try:
             from Cython import __version__ as cython_version
@@ -268,9 +269,9 @@
                 "REVISION" : "unknown",
                 "LOCAL_MODIFICATIONS" : "unknown"
             }
     #find revision:
-    proc = subprocess.Popen("svnversion -n ..", stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+    proc = subprocess.Popen("cat svn-version", stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
     (out, _) = proc.communicate()
     if proc.returncode!=0:
         print("'svnversion -n' failed with return code %s" % proc.returncode)
         return  props
@@ -295,9 +296,9 @@
     rev = int(rev_str)
     props["REVISION"] = rev
     #find number of local files modified:
     changes = 0
-    proc = subprocess.Popen("svn status", stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+    proc = subprocess.Popen("echo 0", stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
     (out, _) = proc.communicate()
     if proc.poll()!=0:
         print("could not get status of local files")
         return  props
@@ -327,9 +328,10 @@
         if ignore:
             continue
         changes += 1
         print("WARNING: found modified file: %s" % filename)
-    props["LOCAL_MODIFICATIONS"] = changes
+    props["LOCAL_MODIFICATIONS"] = subprocess.Popen("dpkg-parsechangelog -SVersion", stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).stdout.read()[:-1]
+
     return props
 
 SRC_INFO_FILE = "./xpra/src_info.py"
 def record_src_info():
