294 if marker: |
295 if marker: |
295 t_marker = " ({0})".format(PythonTextMarkers[marker]) |
296 t_marker = " ({0})".format(PythonTextMarkers[marker]) |
296 else: |
297 else: |
297 t_marker = "" |
298 t_marker = "" |
298 text = text.replace("@PY_MARKER@", t_marker) |
299 text = text.replace("@PY_MARKER@", t_marker) |
|
300 |
|
301 if sys.version_info[0] == 2: |
|
302 f = codecs.open(dst, "w", "utf-8") |
|
303 else: |
|
304 f = open(dst, "w", encoding="utf-8") |
|
305 f.write(text) |
|
306 f.close() |
|
307 os.chmod(dst, 0o644) |
|
308 |
|
309 |
|
310 def copyAppStreamFile(src, dst, marker): |
|
311 """ |
|
312 Modify an appstream file and write it to its destination. |
|
313 |
|
314 @param src source file name (string) |
|
315 @param dst destination file name (string) |
|
316 @param marker marker to be used (string) |
|
317 """ |
|
318 if os.path.exists(os.path.join("eric", "UI", "Info.py")): |
|
319 # Installing from archive |
|
320 from eric.UI.Info import Version |
|
321 elif os.path.exists(os.path.join("UI", "Info.py")): |
|
322 # Installing from source tree |
|
323 from UI.Info import Version |
|
324 else: |
|
325 Version = "Unknown" |
|
326 |
|
327 if sys.version_info[0] == 2: |
|
328 f = codecs.open(src, "r", "utf-8") |
|
329 else: |
|
330 f = open(src, "r", encoding="utf-8") |
|
331 text = f.read() |
|
332 f.close() |
|
333 |
|
334 text = text.replace("@MARKER@", marker)\ |
|
335 .replace("@VERSION@", Version.split(None, 1)[0])\ |
|
336 .replace("@DATE@", time.strftime("%Y-%m-%d")) |
299 |
337 |
300 if sys.version_info[0] == 2: |
338 if sys.version_info[0] == 2: |
301 f = codecs.open(dst, "w", "utf-8") |
339 f = codecs.open(dst, "w", "utf-8") |
302 else: |
340 else: |
303 f = open(dst, "w", encoding="utf-8") |
341 f = open(dst, "w", encoding="utf-8") |
817 marker) |
855 marker) |
818 dst = os.path.normpath( |
856 dst = os.path.normpath( |
819 os.path.join(distDir, "usr/share/metainfo")) |
857 os.path.join(distDir, "usr/share/metainfo")) |
820 if not os.path.exists(dst): |
858 if not os.path.exists(dst): |
821 os.makedirs(dst) |
859 os.makedirs(dst) |
822 copyDesktopFile( |
860 copyAppStreamFile( |
823 os.path.join(sourceDir, "eric6.appdata.xml"), |
861 os.path.join(sourceDir, "eric6.appdata.xml"), |
824 os.path.join(dst, "eric6" + marker + ".appdata.xml"), |
862 os.path.join(dst, "eric6" + marker + ".appdata.xml"), |
825 marker) |
863 marker) |
826 elif os.getuid() == 0: |
864 elif os.getuid() == 0: |
827 shutilCopy(os.path.join( |
865 shutilCopy(os.path.join( |
830 copyDesktopFile( |
868 copyDesktopFile( |
831 os.path.join(sourceDir, "eric6.desktop"), |
869 os.path.join(sourceDir, "eric6.desktop"), |
832 "/usr/share/applications/eric6" + marker + ".desktop", |
870 "/usr/share/applications/eric6" + marker + ".desktop", |
833 marker) |
871 marker) |
834 if os.path.exists("/usr/share/metainfo"): |
872 if os.path.exists("/usr/share/metainfo"): |
835 copyDesktopFile( |
873 copyAppStreamFile( |
836 os.path.join(sourceDir, "eric6.appdata.xml"), |
874 os.path.join(sourceDir, "eric6.appdata.xml"), |
837 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
875 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
838 marker) |
876 marker) |
839 elif os.path.exists("/usr/share/appdata"): |
877 elif os.path.exists("/usr/share/appdata"): |
840 copyDesktopFile( |
878 copyAppStreamFile( |
841 os.path.join(sourceDir, "eric6.appdata.xml"), |
879 os.path.join(sourceDir, "eric6.appdata.xml"), |
842 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
880 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
843 marker) |
881 marker) |
844 shutilCopy(os.path.join( |
882 shutilCopy(os.path.join( |
845 sourceDir, "icons", "default", "ericWeb48.png"), |
883 sourceDir, "icons", "default", "ericWeb48.png"), |