forked from linuxmint/mintupdate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_desktop_files
executable file
·83 lines (67 loc) · 2.73 KB
/
generate_desktop_files
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/python3
DOMAIN = "mintupdate"
PATH = "/usr/share/locale"
import os, gettext
from mintcommon import additionalfiles
import subprocess
os.environ['LANGUAGE'] = "en_US.UTF-8"
gettext.install(DOMAIN, PATH)
prefix = "[Desktop Entry]\n"
suffix = """Exec=mintupdate
Icon=mintupdate
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Application;System;Settings;XFCE;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;
StartupNotify=false
NotShowIn=KDE;
"""
name = _("Update Manager")
comment = _("Show and install available updates")
additionalfiles.generate(DOMAIN, PATH, "usr/share/applications/mintupdate.desktop", prefix, "Update Manager", "Show and install available updates", suffix)
suffix = """Exec=mintupdate
Icon=mintupdate
Terminal=false
Type=Application
Encoding=UTF-8
Categories=System;
StartupNotify=false
OnlyShowIn=KDE;
"""
additionalfiles.generate(DOMAIN, PATH, "usr/share/applications/mintupdate-kde.desktop", prefix, "Update Manager", "Show and install available updates", suffix, genericName="Show and install available updates")
prefix= """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>Linux Mint</vendor>
<vendor_url>https://linuxmint.com/</vendor_url>
<action id="com.linuxmint.updates.automation">
<icon_name>mintupdate</icon_name>
"""
suffix = """
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/mintupdate-automation</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">false</annotate>
</action>
</policyconfig>
"""
additionalfiles.generate_polkit_policy(DOMAIN, PATH, "usr/share/polkit-1/actions/com.linuxmint.updates.policy", prefix, "Update Manager", suffix)
locales = []
cur_dir = os.getcwd()
os.chdir("/usr/share/locale")
lines = subprocess.getoutput("find */LC_MESSAGES/mintupdate.mo")
for line in lines.split("\n"):
line = line.strip().split("/")[0]
locales.append(line)
os.chdir(cur_dir)
for locale in locales:
os.system("mkdir -p usr/share/help/%s/mintupdate/" % locale)
os.system("msgunfmt /usr/share/locale/%s/LC_MESSAGES/mintupdate.mo > /tmp/%s.po" % (locale, locale))
for page in ["index", "kernels", "mintupdate-cli", "snapshots", "regressions", "updates"]:
os.system("xml2po -p /tmp/%(locale)s.po -o usr/share/help/%(locale)s/mintupdate/%(page)s.page usr/share/help/C/mintupdate/%(page)s.page" % {'locale': locale, 'page':page})
os.system("cp usr/share/help/C/mintupdate/legal.xml usr/share/help/%s/mintupdate/" % locale)