summarylogtreecommitdiffstats
path: root/add_apt_checking.patch
blob: 5e0544d4fcee38f9104e9c925be54c254febab75 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
diff --git a/usr/lib/linuxmint/mintlocale/install_remove.py b/usr/lib/linuxmint/mintlocale/install_remove.py
index 205bd5b..00e2e2d 100755
--- a/usr/lib/linuxmint/mintlocale/install_remove.py
+++ b/usr/lib/linuxmint/mintlocale/install_remove.py
@@ -2,12 +2,10 @@
 
 import os
 import gettext
-import apt_pkg
 import subprocess
 import tempfile
 import locale
 import codecs
-import mintcommon
 
 import gi
 gi.require_version('Gtk', '3.0')
@@ -15,6 +13,13 @@
 from gi.repository import GdkX11
 from gi.repository import Gtk, GdkPixbuf, XApp
 
+# Used to detect Debian derivatives (we don't want to show APT features in other distros)
+IS_DEBIAN = os.path.exists("/etc/debian_version")
+
+if IS_DEBIAN:
+    import apt_pkg
+    import mintcommon
+
 # i18n
 APP = 'mintlocale'
 LOCALE_DIR = "/usr/share/linuxmint/locale"
@@ -98,7 +103,9 @@ def __init__(self):
 
         self.build_lang_list()
 
-        self.apt = mintcommon.APT(self.window)
+
+        if IS_DEBIAN:
+            self.apt = mintcommon.APT(self.window)
 
     def split_locale(self, locale_code):
         if "_" in locale_code:
@@ -244,22 +251,25 @@ def select_language(self, treeview, data=None):
 
     def button_install_clicked(self, button):
         if self.selected_language_packs is not None:
-            if self.cache_updated:
-                self.apt.set_finished_callback(self.on_install_finished)
-                self.apt.set_cancelled_callback(self.on_install_finished)
-                self.apt.install_packages(self.selected_language_packs)
-            else:
-                self.apt.set_finished_callback(self.on_update_finished)
-                self.apt.update_cache()
-
-    def on_update_finished(self, transaction=None, exit_state=None):
-        self.cache_updated = True
-        self.apt.set_finished_callback(self.on_install_finished)
-        self.apt.set_cancelled_callback(self.on_install_finished)
-        self.apt.install_packages(self.selected_language_packs)
-
-    def on_install_finished(self, transaction=None, exit_state=None):
-        self.build_lang_list()
+            if IS_DEBIAN:
+                if self.cache_updated:
+                    self.apt.set_finished_callback(self.on_install_finished)
+                    self.apt.set_cancelled_callback(self.on_install_finished)
+                    self.apt.install_packages(self.selected_language_packs)
+                else:
+                    self.apt.set_finished_callback(self.on_update_finished)
+                    self.apt.update_cache()
+
+    if IS_DEBIAN:
+        def on_update_finished(self, transaction=None, exit_state=None):
+            self.cache_updated = True
+            self.apt.set_finished_callback(self.on_install_finished)
+            self.apt.set_cancelled_callback(self.on_install_finished)
+            self.apt.install_packages(self.selected_language_packs)
+
+    if IS_DEBIAN:
+        def on_install_finished(self, transaction=None, exit_state=None):
+            self.build_lang_list()
 
     def button_add_clicked(self, button):
         os.system("/usr/lib/linuxmint/mintlocale/add.py")
@@ -284,8 +294,9 @@ def button_remove_clicked(self, button):
                             print(pkgname)
 
             if len(installed_packs) > 0:
-                self.apt.set_finished_callback(self.on_install_finished)
-                self.apt.remove_packages(installed_packs)
+                if IS_DEBIAN:
+                    self.apt.set_finished_callback(self.on_install_finished)
+                    self.apt.remove_packages(installed_packs)
 
         self.build_lang_list()
 
diff --git a/usr/lib/linuxmint/mintlocale/mintlocale.py b/usr/lib/linuxmint/mintlocale/mintlocale.py
index cd75f75..87e0c47 100755
--- a/usr/lib/linuxmint/mintlocale/mintlocale.py
+++ b/usr/lib/linuxmint/mintlocale/mintlocale.py
@@ -8,7 +8,6 @@
 import tempfile
 import subprocess
 import codecs
-import mintcommon
 
 try:
     import _thread as thread
@@ -33,6 +32,7 @@
 
 if IS_DEBIAN:
     import apt
+    import mintcommon
 
 # i18n
 APP = 'mintlocale'
@@ -64,7 +64,8 @@ def __init__(self, codename, name, methods, app):
         self.app = app
         self.packages = []
         self.missing_packages = []
-        self.apt = mintcommon.APT(self.app.window)
+        if IS_DEBIAN:
+            self.apt = mintcommon.APT(self.app.window)
 
         self.label = Gtk.Label()
         self.label.set_markup(name)
@@ -107,13 +108,14 @@ def __init__(self, codename, name, methods, app):
     def install(self, widget):
         if len(self.missing_packages) > 0:
             self.app.lock_input_methods()
-            if self.app.cache_updated:
-                self.apt.set_finished_callback(self.on_install_finished)
-                self.apt.set_cancelled_callback(self.on_install_finished)
-                self.apt.install_packages(self.missing_packages)
-            else:
-                self.apt.set_finished_callback(self.on_update_finished)
-                self.apt.update_cache()
+            if IS_DEBIAN:
+                if self.app.cache_updated:
+                    self.apt.set_finished_callback(self.on_install_finished)
+                    self.apt.set_cancelled_callback(self.on_install_finished)
+                    self.apt.install_packages(self.missing_packages)
+                else:
+                    self.apt.set_finished_callback(self.on_update_finished)
+                    self.apt.update_cache()
 
     def on_update_finished(self, transaction=None, exit_state=None):
         self.app.cache_updated = True