Ticket #42776: patch-installer_core-install.py

File patch-installer_core-install.py, 13.4 KB (added by okmacports@…, 10 years ago)
Line 
1--- ./installer/core_install.py.orig    2014-03-10 14:51:37.000000000 +0100
2+++ ./installer/core_install.py 2014-03-10 14:56:40.000000000 +0100
3@@ -103,7 +103,7 @@
4 
5 HPLIP_EXT_LIST = ['cupsext.so', 'cupsext.la', 'scanext.so', 'scanext.la', 'hpmudext.so', 'hpmudext.la', 'pcardext.so', 'pcardext.la']
6 
7-FILES_LIST=[ '/usr/share/cups/drv/hp/','/usr/local/share/ppd/HP/','/usr/local/share/cups/drv/hp/' ,'/usr/share/applications/hplip.desktop', '/etc/xdg/autostart/hplip-systray.desktop', '/etc/hp/hplip.conf', '/usr/share/doc/hplip-*','/usr/lib/systemd/system/hplip-printer*.service']
8+FILES_LIST=[ '@PREFIX@/share/cups/drv/hp/','@PREFIX@/local/share/ppd/HP/','@PREFIX@/local/share/cups/drv/hp/' ,'@PREFIX@/share/applications/hplip.desktop', '@PREFIX@/etc/xdg/autostart/hplip-systray.desktop', '@PREFIX@/etc/hp/hplip.conf', '@PREFIX@/share/doc/hplip-*','@PREFIX@/lib/systemd/system/hplip-printer*.service']
9 
10 RULES_LIST=['56-hpmud.rules','56-hpmud_sysfs.rules', '40-hplip.rules', '56-hpmud_support.rules', '56-hpmud_support_sysfs.rules','55-hpmud.rules','55-hpmud_sysfs.rules','56-hpmud_add_printer.rules','56-hpmud_add_printer_sysfs.rules', '86-hpmud-hp_*.rules', '86-hpmud_plugin.rules', '86-hpmud_plugin_sysfs.rules']
11 
12@@ -176,7 +176,7 @@
13         self.endian = utils.LITTLE_ENDIAN
14         self.distro, self.distro_name, self.distro_version = DISTRO_UNKNOWN, '', DISTRO_VER_UNKNOWN
15         self.distro_version_supported = False
16-        self.install_location = '/usr'
17+        self.install_location = '@PREFIX@'
18         self.hplip_present = False
19         self.have_dependencies = {}
20         self.native_cups = True
21@@ -520,9 +520,9 @@
22 
23         if not found:
24             try:
25-                name = file('/etc/issue', 'r').read().lower().strip()
26+                name = file('@PREFIX@/etc/issue', 'r').read().lower().strip()
27             except IOError:
28-                # Some O/Ss don't have /etc/issue (Mac)
29+                # Some O/Ss don't have @PREFIX@/etc/issue (Mac)
30                 self.distro, self.distro_version = DISTRO_UNKNOWN, '0.0'
31             else:
32                 if name.find("redhatenterprise") > -1:
33@@ -562,7 +562,7 @@
34                             self.distro_version = m
35                             break
36 
37-                    log.debug("/etc/issue: %s %s" % (name, self.distro_version))
38+                    log.debug("@PREFIX@/etc/issue: %s %s" % (name, self.distro_version))
39 
40         log.debug("distro=%d, distro_version=%s" % (self.distro, self.distro_version))
41 
42@@ -759,14 +759,14 @@
43             if not check_lib('libusb'):
44                 return False
45             if self.distro_name != "rhel":
46-                return len(locate_file_contains("usb.h", '/usr/include', 'usb_init'))
47+                return len(locate_file_contains("usb.h", '@PREFIX@/include', 'usb_init'))
48             else:
49                 return True
50         else:
51             if not check_lib('libusb-1.0'):
52                 return False
53             if self.distro_name != "rhel":
54-                return len(locate_file_contains("libusb.h", '/usr/include/libusb-1.0', 'libusb_init'))
55+                return len(locate_file_contains("libusb.h", '@PREFIX@/include/libusb-1.0', 'libusb_init'))
56             else:
57                 return True
58 
59@@ -780,7 +780,8 @@
60 
61 
62     def check_libpthread(self):
63-        return check_lib("libpthread") and check_file("pthread.h")
64+#        return check_lib("libpthread") and check_file("pthread.h")
65+        return True #built-in for Darwin
66 
67 
68     def check_libnetsnmp(self):
69@@ -832,7 +833,7 @@
70 
71 
72     def check_sane_devel(self):
73-        return len(locate_file_contains("sane.h", '/usr/include', 'extern SANE_Status sane_init'))
74+        return len(locate_file_contains("sane.h", '@PREFIX@/include', 'extern SANE_Status sane_init'))
75 
76 
77     def check_xsane(self):
78@@ -889,7 +890,7 @@
79 
80 
81     def check_python_devel(self):
82-        return check_file('Python.h')
83+        return check_file('Python.h','@PYTHON_PREFIX@')
84 
85 
86     def check_pynotify(self):
87@@ -935,14 +936,16 @@
88     def check_dbus(self):
89         log.debug("Checking for dbus running and header files present (dbus-devel)...")
90         return check_ps(['dbus-daemon'])  and \
91-            len(locate_file_contains("dbus-message.h", '/usr/include', 'dbus_message_new_signal'))
92+            len(locate_file_contains("dbus-message.h", '@PREFIX@/include', 'dbus_message_new_signal'))
93 
94 
95     def check_cups_devel(self):
96+        return True
97         return check_file('cups.h') and bool(utils.which('lpr'))
98 
99 
100     def check_cups(self):
101+        return True
102         status, output = utils.run('lpstat -r', self.passwordObj)
103         if status > 0 or 'not running' in output:
104             log.debug("CUPS is not running. %s"%output)
105@@ -953,17 +956,18 @@
106 
107 
108     def check_cups_image(self):
109-      return check_file("raster.h", "/usr/include/cups")
110+      return check_file("raster.h", "@PREFIX@/include/cups")
111 
112 
113     def check_hplip(self):
114         log.debug("Checking for HPLIP...")
115-        return locate_files('hplip.conf', '/etc/hp')
116+        return locate_files('hplip.conf', '@PREFIX@/etc/hp')
117 
118 
119     def check_libtool(self):
120         log.debug("Checking for libtool...")
121-        return check_tool('libtool --version')
122+#        return check_tool('libtool --version')
123+        return check_tool('libtool -V')
124 
125 
126     def check_pil(self):
127@@ -978,18 +982,18 @@
128     def check_cupsddk(self):
129         log.debug("Checking for cups-ddk...")
130         # TODO: Compute these paths some way or another...
131-        #return check_tool("/usr/lib/cups/driver/drv list") and os.path.exists("/usr/share/cupsddk/include/media.defs")
132-        return (check_file('drv', "/usr/lib/cups/driver") or check_file('drv', "/usr/lib64/cups/driver")) and \
133-            check_file('media.defs', "/usr/share/cupsddk/include")
134+        #return check_tool("@PREFIX@/lib/cups/driver/drv list") and os.path.exists("@PREFIX@/share/cupsddk/include/media.defs")
135+        return (check_file('drv', "@PREFIX@/lib/cups/driver") or check_file('drv', "@PREFIX@/lib64/cups/driver")) and \
136+            check_file('media.defs', "@PREFIX@/share/cupsddk/include")
137 
138 
139     def check_policykit(self):
140         log.debug("Checking for PolicyKit...")
141-        if check_file('PolicyKit.conf', "/etc/PolicyKit") and check_file('org.gnome.PolicyKit.AuthorizationManager.service', "/usr/share/dbus-1/services"):
142+        if check_file('PolicyKit.conf', "@PREFIX@/etc/PolicyKit") and check_file('org.gnome.PolicyKit.AuthorizationManager.service', "@PREFIX@/share/dbus-1/services"):
143             return True
144-        elif check_file('50-localauthority.conf', "/etc/polkit-1/localauthority.conf.d") and check_file('org.freedesktop.PolicyKit1.service', "/usr/share/dbus-1/system-services"):
145+        elif check_file('50-localauthority.conf', "@PREFIX@/etc/polkit-1/localauthority.conf.d") and check_file('org.freedesktop.PolicyKit1.service', "@PREFIX@/share/dbus-1/system-services"):
146             return True
147-        elif check_file('org.freedesktop.PolicyKit1.conf','/etc/dbus-1/system.d'):
148+        elif check_file('org.freedesktop.PolicyKit1.conf','@PREFIX@/etc/dbus-1/system.d'):
149             return True
150         else:
151             return False
152@@ -1030,7 +1034,7 @@
153 
154     def check_hpaio(self):
155         found = False
156-        for path in ['/etc/sane.d/dll.conf','/etc/sane.d/dll.d/hpaio', '/etc/sane.d/dll.d/hplip']:
157+        for path in ['@PREFIX@/etc/sane.d/dll.conf','@PREFIX@/etc/sane.d/dll.d/hpaio', '@PREFIX@/etc/sane.d/dll.d/hplip']:
158             log.debug("'Checking for hpaio' in '%s'..." % path)
159             try:
160                 f = file(path, 'r')
161@@ -1059,13 +1063,13 @@
162         if pat.match(home_dir) is not None:
163             usrlib_dir= pat.match(home_dir).group(1) + "lib/"
164             if os.path.exists(usrlib_dir+'sane/libsane-hpaio.so.1'):
165-                log.debug("'Updating hpaio' in '/etc/sane.d/dll.conf'...")
166+                log.debug("'Updating hpaio' in '@PREFIX@/etc/sane.d/dll.conf'...")
167                 try:
168-                    f = file('/etc/sane.d/dll.conf', 'r')
169+                    f = file('@PREFIX@/etc/sane.d/dll.conf', 'r')
170                 except IOError:
171-                    log.error("'/etc/sane.d/dll.conf' not found. Creating dll.conf file")
172-#                    f = file('/etc/sane.d/dll.conf', 'a+')
173-                    cmd = self.passwordObj.getAuthCmd()%'touch /etc/sane.d/dll.conf'
174+                    log.error("'@PREFIX@/etc/sane.d/dll.conf' not found. Creating dll.conf file")
175+#                    f = file('@PREFIX@/etc/sane.d/dll.conf', 'a+')
176+                    cmd = self.passwordObj.getAuthCmd()%'touch @PREFIX@/etc/sane.d/dll.conf'
177                     log.debug("cmd=%s"%cmd)
178                     utils.run(cmd, self.passwordObj)
179                 else:
180@@ -1078,19 +1082,19 @@
181                     f.close()
182 
183                 if not found:
184-                    st = os.stat('/etc/sane.d/dll.conf')
185-                    cmd= self.passwordObj.getAuthCmd()%'chmod 777 /etc/sane.d/dll.conf'
186+                    st = os.stat('@PREFIX@/etc/sane.d/dll.conf')
187+                    cmd= self.passwordObj.getAuthCmd()%'chmod 777 @PREFIX@/etc/sane.d/dll.conf'
188                     log.debug("cmd=%s"%cmd)
189                     utils.run(cmd, self.passwordObj)
190                     try:
191-                        f = file('/etc/sane.d/dll.conf', 'a+')
192+                        f = file('@PREFIX@/etc/sane.d/dll.conf', 'a+')
193                     except IOError:
194-                        log.error("'/etc/sane.d/dll.conf' not found. Creating dll.conf file")
195+                        log.error("'@PREFIX@/etc/sane.d/dll.conf' not found. Creating dll.conf file")
196                     else:
197                         f.write('hpaio')
198                         f.close()
199                     actv_permissions = st.st_mode &0777
200-                    cmd = 'chmod %o /etc/sane.d/dll.conf'%actv_permissions
201+                    cmd = 'chmod %o @PREFIX@/etc/sane.d/dll.conf'%actv_permissions
202                     cmd= self.passwordObj.getAuthCmd()%cmd
203                     log.debug("cmd=%s"%cmd)
204                     utils.run(cmd, self.passwordObj)
205@@ -1234,12 +1238,12 @@
206         if libdir_path and self.bitness == 64:
207             configure_cmd += ' --libdir=%s' % (libdir_path)
208         elif self.bitness == 64:
209-            configure_cmd += ' --libdir=/usr/lib64'
210+            configure_cmd += ' --libdir=@PREFIX@/lib64'
211 
212         configure_cmd += ' --prefix=%s' % self.install_location
213 
214         if self.get_distro_ver_data('cups_path_with_bitness', False) and self.bitness == 64:
215-            configure_cmd += ' --with-cupsbackenddir=/usr/lib64/cups/backend --with-cupsfilterdir=/usr/lib64/cups/filter'
216+            configure_cmd += ' --with-cupsbackenddir=@PREFIX@/lib64/cups/backend --with-cupsfilterdir=@PREFIX@/lib64/cups/filter'
217 
218         if self.get_distro_ver_data('acl_rules', False):
219             configure_cmd += ' --enable-udev-acl-rules'
220@@ -1262,11 +1266,11 @@
221 
222     def configure_html(self):
223         configure_cmd = './configure'
224-        configure_cmd += ' --prefix=/usr' 
225+        configure_cmd += ' --prefix=@PREFIX@' 
226         configure_cmd += ' --with-hpppddir=%s' % self.ppd_dir
227 
228         if self.bitness == 64:
229-            configure_cmd += ' --libdir=/usr/lib64'
230+            configure_cmd += ' --libdir=@PREFIX@/lib64'
231 
232         self.ui_toolkit =  self.get_distro_ver_data('ui_toolkit') 
233         if self.ui_toolkit is not None and self.ui_toolkit == 'qt3':
234@@ -1618,7 +1622,7 @@
235         # Reload DBUS configuration if distro supports it and PolicyKit
236         # support installed
237         if self.reload_dbus and self.selected_options['policykit']:
238-            cmds.append(self.passwordObj.getAuthCmd() % "sh /etc/init.d/dbus reload")
239+            cmds.append(self.passwordObj.getAuthCmd() % "sh @PREFIX@/etc/init.d/dbus reload")
240             log.debug("Will reload DBUS configuration for PolicyKit support")
241 
242         # Kill any running hpssd.py instance from a previous install
243@@ -1837,7 +1841,7 @@
244             cnt += 1
245 
246         # removing Rules files
247-        RULES_LIST_FULL = utils.expandList(RULES_LIST, '/etc/udev/rules.d')
248+        RULES_LIST_FULL = utils.expandList(RULES_LIST, '@PREFIX@/etc/udev/rules.d')
249         for fl in RULES_LIST_FULL:
250             utils.remove(fl, self.passwordObj, checkSudo)
251 
252@@ -1846,7 +1850,7 @@
253             utils.remove(fl , self.passwordObj, checkSudo)
254 
255         # removing (unused) hplip folder from other location
256-        cmd = 'find /usr -type d -name hplip'
257+        cmd = 'find @PREFIX@ -type d -name hplip'
258         cmd = self.passwordObj.getAuthCmd() %cmd
259         status, output=utils.run(cmd, self.passwordObj, checkSudo)
260         if status == 0:
261@@ -1858,7 +1862,7 @@
262         # removing all hplip extension libraries
263         for ext_f in HPLIP_EXT_LIST:
264             if ext_f:
265-                cmd = 'find /usr -type f -name %s -delete'%ext_f
266+                cmd = 'find @PREFIX@ -type f -name %s -delete'%ext_f
267                 cmd = self.passwordObj.getAuthCmd() %cmd
268                 status,output = utils.run(cmd , self.passwordObj, checkSudo)
269                 if status != 0:
270@@ -1972,7 +1976,7 @@
271 
272     def disable_SELinux(self, mode = INTERACTIVE_MODE):       # Move to utils
273         ret_val = False
274-        SELinux_file = '/etc/selinux/config'
275+        SELinux_file = '@PREFIX@/etc/selinux/config'
276         if mode == INTERACTIVE_MODE:
277             ok,user_input =tui.enter_choice("SELinux is currently enabled in your system. Device may not work properly. Do you want to disable SELinux?(y=yes, n=no*)",['y', 'n'], 'n')
278             if ok and user_input != 'n':
279