install.py

branch
5_5_x
changeset 3932
a909b9212f59
parent 3900
8c12501b6b48
child 3941
f8a9af3d8b56
diff -r 2968e0bfcaea -r a909b9212f59 install.py
--- a/install.py	Tue Nov 18 19:03:48 2014 +0100
+++ b/install.py	Wed Nov 19 18:53:41 2014 +0100
@@ -217,6 +217,26 @@
     f.close()
 
 
+def copyDesktopFile(src, dst, marker):
+    """
+    Modify a desktop 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)
+    """
+    f = open(src, "r")
+    text = f.read()
+    f.close()
+    
+    text = text.replace("@MARKER@", marker)
+    
+    f = open(dst, "w")
+    f.write(text)
+    f.close()
+    os.chmod(dst, 0o644)
+
+
 def wrapperName(dname, wfile):
     """
     Create the platform specific name for the wrapper script.
@@ -407,10 +427,17 @@
     # Remove the menu entry for Linux systems
     if sys.platform.startswith("linux") and os.getuid() == 0:
         for name in ["/usr/share/pixmaps/eric.png",
-                     "/usr/share/applications/eric5.desktop",
-                     "/usr/share/appdata/eric5.appdata.xml",
-                     "/usr/share/pixmaps/ericWeb.png",
-                     "/usr/share/applications/eric5_webbrowser.desktop"]:
+                     "/usr/share/pixmaps/ericWeb.png"]:
+            if os.path.exists(name):
+                os.remove(name)
+        if includePythonVariant:
+            marker = PythonMarkers[sys.version_info.major]
+        else:
+            marker = ""
+        for name in ["/usr/share/applications/eric5" + marker + ".desktop",
+                     "/usr/share/appdata/eric5" + marker + ".appdata.xml",
+                     "/usr/share/applications/eric5_webbrowser" + marker + 
+                     ".desktop"]:
             if os.path.exists(name):
                 os.remove(name)
     
@@ -487,7 +514,7 @@
                         os.remove(apiname)
                 for apiname in glob.glob(
                         os.path.join(apidir, progLanguage.lower(), "*.bas")):
-                    if os.path.basename(apiname) != "eric6.bas":
+                    if os.path.basename(apiname) != "eric5.bas":
                         os.remove(apiname)
         except AttributeError:
             pass
@@ -536,6 +563,7 @@
     @return result code (integer)
     """
     global distDir, doCleanup, cfg, progLanguages, sourceDir, configName
+    global includePythonVariant
     
     # Create the platform specific wrappers.
     wnames = []
@@ -704,6 +732,11 @@
     
     # create menu entry for Linux systems
     if sys.platform.startswith("linux"):
+        if includePythonVariant:
+            marker = PythonMarkers[sys.version_info.major]
+        else:
+            marker = ""
+    
         if distDir:
             dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps"))
             if not os.path.exists(dst):
@@ -718,31 +751,42 @@
                 os.path.join(distDir, "usr/share/applications"))
             if not os.path.exists(dst):
                 os.makedirs(dst)
-            shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst)
-            shutilCopy(os.path.join(sourceDir, "eric5_webbrowser.desktop"),
-                       dst)
+            copyDesktopFile(os.path.join(sourceDir, "eric5.desktop"),
+                            os.path.join(dst, "eric5" + marker + ".desktop"),
+                            marker)
+            copyDesktopFile(
+                os.path.join(sourceDir, "eric5_webbrowser.desktop"),
+                os.path.join(dst, "eric5_webbrowser" + marker + ".desktop"),
+                marker)
             dst = os.path.normpath(
                 os.path.join(distDir, "usr/share/appdata"))
             if not os.path.exists(dst):
                 os.makedirs(dst)
-            shutilCopy(os.path.join(sourceDir, "eric5.appdata.xml"), dst)
+            copyDesktopFile(
+                os.path.join(sourceDir, "eric5.appdata.xml"),
+                os.path.join(dst, "eric5" + marker + ".appdata.xml"),
+                marker)
         elif os.getuid() == 0:
             shutilCopy(os.path.join(
                 sourceDir, "icons", "default", "eric.png"),
                 "/usr/share/pixmaps/eric.png")
-            shutilCopy(os.path.join(
-                sourceDir, "eric5.desktop"),
-                "/usr/share/applications")
+            copyDesktopFile(
+                os.path.join(sourceDir, "eric5.desktop"),
+                "/usr/share/applications/eric5" + marker + ".desktop",
+                marker)
             if os.path.exists("/usr/share/appdata"):
-                shutilCopy(os.path.join(
-                    sourceDir, "eric5.appdata.xml"),
-                    "/usr/share/appdata")
+                copyDesktopFile(
+                    os.path.join(sourceDir, "eric5.appdata.xml"),
+                    "/usr/share/appdata/eric5" + marker + ".appdata.xml",
+                    marker)
             shutilCopy(os.path.join(
                 sourceDir, "icons", "default", "ericWeb48.png"),
                 "/usr/share/pixmaps/ericWeb.png")
-            shutilCopy(os.path.join(
-                sourceDir, "eric5_webbrowser.desktop"),
-                "/usr/share/applications")
+            copyDesktopFile(
+                os.path.join(sourceDir, "eric5_webbrowser.desktop"),
+                "/usr/share/applications/eric5_webbrowser" + marker +
+                ".desktop",
+                marker)
     
     # Create a Mac application bundle
     if sys.platform == "darwin":

eric ide

mercurial