--- a/install.py Sat Oct 08 17:02:26 2016 +0200 +++ b/install.py Sat Oct 08 20:16:25 2016 +0200 @@ -30,6 +30,7 @@ import distutils.sysconfig import codecs import subprocess +import time # Define the globals. progName = None @@ -306,6 +307,43 @@ os.chmod(dst, 0o644) +def copyAppStreamFile(src, dst, marker): + """ + Modify an appstream file and write it to its destination. + + @param src source file name (string) + @param dst destination file name (string) + @param marker marker to be used (string) + """ + if os.path.exists(os.path.join("eric", "UI", "Info.py")): + # Installing from archive + from eric.UI.Info import Version + elif os.path.exists(os.path.join("UI", "Info.py")): + # Installing from source tree + from UI.Info import Version + else: + Version = "Unknown" + + if sys.version_info[0] == 2: + f = codecs.open(src, "r", "utf-8") + else: + f = open(src, "r", encoding="utf-8") + text = f.read() + f.close() + + text = text.replace("@MARKER@", marker)\ + .replace("@VERSION@", Version.split(None, 1)[0])\ + .replace("@DATE@", time.strftime("%Y-%m-%d")) + + if sys.version_info[0] == 2: + f = codecs.open(dst, "w", "utf-8") + else: + f = open(dst, "w", encoding="utf-8") + f.write(text) + f.close() + os.chmod(dst, 0o644) + + def wrapperName(dname, wfile): """ Create the platform specific name for the wrapper script. @@ -819,7 +857,7 @@ os.path.join(distDir, "usr/share/metainfo")) if not os.path.exists(dst): os.makedirs(dst) - copyDesktopFile( + copyAppStreamFile( os.path.join(sourceDir, "eric6.appdata.xml"), os.path.join(dst, "eric6" + marker + ".appdata.xml"), marker) @@ -832,12 +870,12 @@ "/usr/share/applications/eric6" + marker + ".desktop", marker) if os.path.exists("/usr/share/metainfo"): - copyDesktopFile( + copyAppStreamFile( os.path.join(sourceDir, "eric6.appdata.xml"), "/usr/share/metainfo/eric6" + marker + ".appdata.xml", marker) elif os.path.exists("/usr/share/appdata"): - copyDesktopFile( + copyAppStreamFile( os.path.join(sourceDir, "eric6.appdata.xml"), "/usr/share/appdata/eric6" + marker + ".appdata.xml", marker)