scripts/install.py

branch
eric7
changeset 10513
805a0450862d
parent 10503
6a37b6ac3928
child 10517
aecd5a8c958c
--- a/scripts/install.py	Fri Jan 19 09:36:51 2024 +0100
+++ b/scripts/install.py	Fri Jan 19 09:37:53 2024 +0100
@@ -937,52 +937,54 @@
     dataSourceDir = os.path.join(eric7SourceDir, "data", "linux")
 
     if distDir:
+        # create directories first
+        for directory in (
+            os.path.normpath(os.path.join(distDir, name))
+            for name in (
+                "usr/share/icons",
+                "usr/share/icons/hicolor/48x48/apps",
+                "usr/share/applications",
+                "usr/share/metainfo",
+                "usr/share/appdata",
+            )
+        ):
+            if not os.path.exists(directory):
+                os.makedirs(directory)
+
         dst = os.path.normpath(os.path.join(distDir, "usr/share/icons"))
-        if not os.path.exists(dst):
-            os.makedirs(dst)
-        shutilCopy(
-            os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"),
-            os.path.join(dst, "eric.png"),
-        )
-        shutilCopy(
-            os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
-            os.path.join(dst, "ericWeb.png"),
-        )
+        for icon in ("eric_icon.png", "ericWeb48_icon.png"):
+            shutilCopy(
+                os.path.join(eric7SourceDir, "pixmaps", icon),
+                os.path.join(dst, icon.replace("_icon", "").replace("48", "")),
+            )
 
         dst = os.path.normpath(
             os.path.join(distDir, "usr/share/icons/hicolor/48x48/apps")
         )
-        if not os.path.exists(dst):
-            os.makedirs(dst)
-        shutilCopy(
-            os.path.join(eric7SourceDir, "pixmaps", "eric48_icon.png"),
-            os.path.join(dst, "eric.png"),
-        )
-        shutilCopy(
-            os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
-            os.path.join(dst, "ericWeb.png"),
-        )
+        for icon in ("eric48_icon.png", "ericWeb48_icon.png"):
+            shutilCopy(
+                os.path.join(eric7SourceDir, "pixmaps", icon),
+                os.path.join(dst, icon.replace("48_icon", "")),
+            )
 
         dst = os.path.normpath(os.path.join(distDir, "usr/share/applications"))
-        if not os.path.exists(dst):
-            os.makedirs(dst)
-        copyDesktopFile(
-            os.path.join(dataSourceDir, "eric7_ide.desktop.in"),
-            os.path.join(dst, "eric7_ide.desktop"),
-        )
-        copyDesktopFile(
-            os.path.join(dataSourceDir, "eric7_browser.desktop.in"),
-            os.path.join(dst, "eric7_browser.desktop"),
-        )
+        for desktop in ("eric7_ide", "eric7_browser"):
+            copyDesktopFile(
+                os.path.join(dataSourceDir, desktop + ".desktop.in"),
+                os.path.join(dst, desktop + ".desktop")
+            )
 
-        dst = os.path.normpath(os.path.join(distDir, "usr/share/metainfo"))
-        if not os.path.exists(dst):
-            os.makedirs(dst)
-        copyAppStreamFile(
-            os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
-            os.path.join(dst, "eric7.appdata.xml"),
-        )
+        for dst in (
+            os.path.normpath(os.path.join(distDir, "usr/share/metainfo")),
+            os.path.normpath(os.path.join(distDir, "usr/share/appdata")),
+        ):
+            copyAppStreamFile(
+                os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
+                os.path.join(dst, "eric7.appdata.xml"),
+            )
+
     elif os.getuid() == 0:
+        # eric meta data
         shutilCopy(
             os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"),
             "/usr/share/icons/eric.png",
@@ -1005,6 +1007,8 @@
                 os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
                 "/usr/share/appdata/eric7.appdata.xml",
             )
+
+        # eric web browser meta data
         shutilCopy(
             os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
             "/usr/share/icons/ericWeb.png",
@@ -1017,6 +1021,7 @@
             os.path.join(dataSourceDir, "eric7_browser.desktop.in"),
             "/usr/share/applications/eric7_browser.desktop",
         )
+
     elif os.getuid() >= 1000:
         # it is assumed, that user ids start at 1000
         localPath = os.path.join(os.path.expanduser("~"), ".local", "share")
@@ -1033,7 +1038,9 @@
         ]:
             if not os.path.isdir(directory):
                 os.makedirs(directory)
+
         # now copy the files
+        # eric meta data
         shutilCopy(
             os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"),
             os.path.join(localPath, "icons", "eric.png"),
@@ -1054,6 +1061,7 @@
             os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
             os.path.join(localPath, "appdata", "eric7.appdata.xml"),
         )
+        # eric web browser meta data
         shutilCopy(
             os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
             os.path.join(localPath, "icons", "ericWeb.png"),

eric ide

mercurial