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") |
825 marker) |
863 marker) |
826 dst = os.path.normpath( |
864 dst = os.path.normpath( |
827 os.path.join(distDir, "usr/share/metainfo")) |
865 os.path.join(distDir, "usr/share/metainfo")) |
828 if not os.path.exists(dst): |
866 if not os.path.exists(dst): |
829 os.makedirs(dst) |
867 os.makedirs(dst) |
830 copyDesktopFile( |
868 copyAppStreamFile( |
831 os.path.join(sourceDir, "eric6.appdata.xml"), |
869 os.path.join(sourceDir, "eric6.appdata.xml"), |
832 os.path.join(dst, "eric6" + marker + ".appdata.xml"), |
870 os.path.join(dst, "eric6" + marker + ".appdata.xml"), |
833 marker) |
871 marker) |
834 elif os.getuid() == 0: |
872 elif os.getuid() == 0: |
835 shutilCopy(os.path.join( |
873 shutilCopy(os.path.join( |
838 copyDesktopFile( |
876 copyDesktopFile( |
839 os.path.join(sourceDir, "eric6.desktop"), |
877 os.path.join(sourceDir, "eric6.desktop"), |
840 "/usr/share/applications/eric6" + marker + ".desktop", |
878 "/usr/share/applications/eric6" + marker + ".desktop", |
841 marker) |
879 marker) |
842 if os.path.exists("/usr/share/metainfo"): |
880 if os.path.exists("/usr/share/metainfo"): |
843 copyDesktopFile( |
881 copyAppStreamFile( |
844 os.path.join(sourceDir, "eric6.appdata.xml"), |
882 os.path.join(sourceDir, "eric6.appdata.xml"), |
845 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
883 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
846 marker) |
884 marker) |
847 elif os.path.exists("/usr/share/appdata"): |
885 elif os.path.exists("/usr/share/appdata"): |
848 copyDesktopFile( |
886 copyAppStreamFile( |
849 os.path.join(sourceDir, "eric6.appdata.xml"), |
887 os.path.join(sourceDir, "eric6.appdata.xml"), |
850 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
888 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
851 marker) |
889 marker) |
852 shutilCopy(os.path.join( |
890 shutilCopy(os.path.join( |
853 sourceDir, "icons", "default", "ericWeb48.png"), |
891 sourceDir, "icons", "default", "ericWeb48.png"), |