$OpenBSD: patch-installer_core_install_py,v 1.21 2015/02/05 17:34:33 ajacoutot Exp $
--- installer/core_install.py.orig	Thu Jan 29 13:20:24 2015
+++ installer/core_install.py	Thu Feb  5 16:58:33 2015
@@ -110,7 +110,7 @@ HPLIP_LIST=['*.py','*.pyc', 'base', 'copier','data','i
 
 PLUGIN_LIST=['fax/plugins/','prnt/plugins/','scan/plugins/']
 
-PLUGIN_STATE =['/var/lib/hp/hplip.state']
+PLUGIN_STATE =['/var/db/hp/hplip.state']
 
 
 # end
@@ -218,7 +218,7 @@ class CoreInstall(object):
         self.endian = utils.LITTLE_ENDIAN
         self.distro, self.distro_name, self.distro_version = DISTRO_UNKNOWN, '', DISTRO_VER_UNKNOWN
         self.distro_version_supported = False
-        self.install_location = '/usr'
+        self.install_location = '${PREFIX}'
         self.hplip_present = False
         self.have_dependencies = {}
         self.native_cups = True
@@ -328,7 +328,7 @@ class CoreInstall(object):
             'cups-devel':       (True,  ['base'], CUPS_DEV_STR, self.check_cups_devel, DEPENDENCY_COMPILE_TIME,'-','cups-config --version', GENERALDEP),
             'cups-image':       (True,  ['base'], CUPS_IMG_STR, self.check_cups_image, DEPENDENCY_COMPILE_TIME,'-','cups-config --version', GENERALDEP),
             'gcc' :             (True,  ['base'], GCC_STR, self.check_gcc, DEPENDENCY_COMPILE_TIME, '-','gcc --version',COMPILEDEP),
-            'make' :            (True,  ['base'], MAKE_STR, self.check_make, DEPENDENCY_COMPILE_TIME,'3.0','make --version',COMPILEDEP),
+            'make' :            (True,  ['base'], MAKE_STR, self.check_make, DEPENDENCY_COMPILE_TIME,'-','-',COMPILEDEP),
             'libpthread' :      (True,  ['base'], THREAD_STR, self.check_libpthread, DEPENDENCY_RUN_AND_COMPILE_TIME, '-','FUNC#get_libpthread_version', GENERALDEP),
             'gs':               (True,  ['base'], GS_STR, self.check_gs, DEPENDENCY_RUN_TIME, '7.05','gs --version', EXTERNALDEP),
             'libusb':           (True,  ['base'], USB_STR, self.check_libusb, DEPENDENCY_RUN_AND_COMPILE_TIME, '-','FUNC#get_libusb_version', GENERALDEP),
@@ -359,13 +359,13 @@ class CoreInstall(object):
         }
         
         python2_dep = {
-            'python2X':         (True,  ['base'], PYTHON_STR, self.check_python, DEPENDENCY_RUN_AND_COMPILE_TIME,'2.2','python --version',GENERALDEP),
+            'python2X':         (True,  ['base'], PYTHON_STR, self.check_python, DEPENDENCY_RUN_AND_COMPILE_TIME,'2.2','${MODPY_BIN} --version',GENERALDEP),
             'python-notify' :   (False, ['gui_qt4'], PYNTF_STR, self.check_pynotify, DEPENDENCY_RUN_TIME,'-','python-notify --version',GENERALDEP), # Optional for libnotify style popups from hp-systray
             'pyqt4-dbus' :      (True,  ['gui_qt4'], QT4DBUS_STR, self.check_pyqt4_dbus, DEPENDENCY_RUN_TIME,'4.0','FUNC#get_pyQt4_version', GENERALDEP),
             'pyqt4':            (True,  ['gui_qt4'], QT4_STR, self.check_pyqt4, DEPENDENCY_RUN_TIME,'4.0','FUNC#get_pyQt4_version', GENERALDEP), # PyQt 4.x )
             'python-dbus':      (True,  ['fax'], PYDBUS_STR, self.check_python_dbus, DEPENDENCY_RUN_TIME,'0.80.0','FUNC#get_python_dbus_ver', GENERALDEP),
             'python-xml'  :     (True,  ['base'], PYXML_STR, self.check_python_xml, DEPENDENCY_RUN_TIME,'-','FUNC#get_python_xml_version',GENERALDEP),
-            'python-devel' :    (True,  ['base'], PY_DEV_STR, self.check_python_devel, DEPENDENCY_COMPILE_TIME,'2.2','python --version',GENERALDEP),
+            'python-devel' :    (True,  ['base'], PY_DEV_STR, self.check_python_devel, DEPENDENCY_COMPILE_TIME,'2.2','${MODPY_BIN} --version',GENERALDEP),
             'pil':              (False, ['scan'], PIL_STR, self.check_pil, DEPENDENCY_RUN_TIME,'-','FUNC#get_pil_version',GENERALDEP),
             # Optional fax packages
             'reportlab':        (False, ['fax'], REPORTLAB_STR, self.check_reportlab, DEPENDENCY_RUN_TIME,'2.0','FUNC#get_reportlab_version',GENERALDEP),
@@ -838,7 +838,7 @@ class CoreInstall(object):
 
 
     def check_make(self):
-        return check_tool('make --version', 3.0)
+        return True
 
 
     def check_libusb(self):
@@ -847,14 +847,14 @@ class CoreInstall(object):
             if not check_lib('libusb'):
                 return False
             if self.distro_name != "rhel":
-                return len(locate_file_contains("usb.h", '/usr/include', 'usb_init'))
+                return len(locate_file_contains("usb.h", '${LOCALBASE}/include', 'usb_init'))
             else:
                 return True
         else:
             if not check_lib('libusb-1.0'):
                 return False
             if self.distro_name != "rhel":
-                return len(locate_file_contains("libusb.h", '/usr/include/libusb-1.0', 'libusb_init'))
+                return len(locate_file_contains("libusb.h", '${LOCALBASE}/include/libusb-1.0', 'libusb_init'))
             else:
                 return True
 
@@ -864,11 +864,10 @@ class CoreInstall(object):
 
 
     def check_libcrypto(self):
-        return check_lib("libcrypto") and check_file("crypto.h")
+        return True
 
-
     def check_libpthread(self):
-        return check_lib("libpthread") and check_file("pthread.h")
+        return True
 
 
     def check_libnetsnmp(self):
@@ -920,7 +919,7 @@ class CoreInstall(object):
 
 
     def check_sane_devel(self):
-        return len(locate_file_contains("sane.h", '/usr/include', 'extern SANE_Status sane_init'))
+        return len(locate_file_contains("sane.h", '${LOCALBASE}/include', 'extern SANE_Status sane_init'))
 
 
     def check_xsane(self):
@@ -1031,9 +1030,8 @@ class CoreInstall(object):
 
 
     def check_dbus(self):
-        log.debug("Checking for dbus running and header files present (dbus-devel)...")
-        return check_ps(['dbus-daemon'])  and \
-            len(locate_file_contains("dbus-message.h", '/usr/include', 'dbus_message_new_signal'))
+        log.debug("Checking for dbus header files...")
+        return check_file("dbus-message.h", "${LOCALBASE}/include")
 
 
     def check_cups_devel(self):
@@ -1051,12 +1049,12 @@ class CoreInstall(object):
 
 
     def check_cups_image(self):
-      return check_file("raster.h", "/usr/include/cups")
+      return check_file("raster.h", "${LOCALBASE}/include/cups")
 
 
     def check_hplip(self):
         log.debug("Checking for HPLIP...")
-        return locate_files('hplip.conf', '/etc/hp')
+        return locate_files('hplip.conf', '${SYSCONFDIR}/hp')
 
 
     def check_libtool(self):
@@ -1076,9 +1074,9 @@ class CoreInstall(object):
     def check_cupsddk(self):
         log.debug("Checking for cups-ddk...")
         # TODO: Compute these paths some way or another...
-        #return check_tool("/usr/lib/cups/driver/drv list") and os.path.exists("/usr/share/cupsddk/include/media.defs")
-        return (check_file('drv', "/usr/lib/cups/driver") or check_file('drv', "/usr/lib64/cups/driver")) and \
-            check_file('media.defs', "/usr/share/cupsddk/include")
+        #return check_tool("${LOCALBASE}/libexec/cups/driver/drv list") and os.path.exists("${LOCALBASE}/share/cupsddk/include/media.defs")
+        return (check_file('drv', "${LOCALBASE}/libexec/cups/driver") or check_file('drv', "/usr/lib64/cups/driver")) and \
+            check_file('media.defs', "${LOCALBASE}/share/cupsddk/include")
 
 
     def check_policykit(self):
@@ -1128,7 +1126,7 @@ class CoreInstall(object):
 
     def check_hpaio(self):
         found = False
-        for path in ['/etc/sane.d/dll.conf','/etc/sane.d/dll.d/hpaio', '/etc/sane.d/dll.d/hplip']:
+        for path in ['${SYSCONFDIR}/sane.d/dll.conf','/etc/sane.d/dll.d/hpaio', '/etc/sane.d/dll.d/hplip']:
             log.debug("'Checking for hpaio' in '%s'..." % path)
             try:
                 f = open(path, 'r')
@@ -1157,12 +1155,12 @@ class CoreInstall(object):
         if pat.match(home_dir) is not None:
             usrlib_dir= pat.match(home_dir).group(1) + "lib/"
             if os.path.exists(usrlib_dir+'sane/libsane-hpaio.so.1'):
-                log.debug("'Updating hpaio' in '/etc/sane.d/dll.conf'...")
+                log.debug("'Updating hpaio' in '${SYSCONFDIR}/sane.d/dll.conf'...")
                 try:
-                    f = open('/etc/sane.d/dll.conf', 'r')
+                    f = open('${SYSCONFDIR}/sane.d/dll.conf', 'r')
                 except IOError:
-                    log.error("'/etc/sane.d/dll.conf' not found. Creating dll.conf file")
-                    cmd = self.passwordObj.getAuthCmd()%'touch /etc/sane.d/dll.conf'
+                    log.error("'${SYSCONFDIR}/sane.d/dll.conf' not found. Creating dll.conf file")
+                    cmd = self.passwordObj.getAuthCmd()%'touch ${SYSCONFDIR}/sane.d/dll.conf'
                     log.debug("cmd=%s"%cmd)
                     utils.run(cmd, self.passwordObj)
                 else:
@@ -1175,19 +1173,19 @@ class CoreInstall(object):
                     f.close()
 
                 if not found:
-                    st = os.stat('/etc/sane.d/dll.conf')
-                    cmd= self.passwordObj.getAuthCmd()%'chmod 777 /etc/sane.d/dll.conf'
+                    st = os.stat('${SYSCONFDIR}/sane.d/dll.conf')
+                    cmd= self.passwordObj.getAuthCmd()%'chmod 777 ${SYSCONFDIR}/sane.d/dll.conf'
                     log.debug("cmd=%s"%cmd)
                     utils.run(cmd, self.passwordObj)
                     try:
-                        f = open('/etc/sane.d/dll.conf', 'a+')
+                        f = open('${SYSCONFDIR}/sane.d/dll.conf', 'a+')
                     except IOError:
-                        log.error("'/etc/sane.d/dll.conf' not found. Creating dll.conf file")
+                        log.error("'${SYSCONFDIR}/sane.d/dll.conf' not found. Creating dll.conf file")
                     else:
                         f.write('hpaio')
                         f.close()
                     actv_permissions = st.st_mode &0o777
-                    cmd = 'chmod %o /etc/sane.d/dll.conf'%actv_permissions
+                    cmd = 'chmod %o ${SYSCONFDIR}/sane.d/dll.conf'%actv_permissions
                     cmd= self.passwordObj.getAuthCmd()%cmd
                     log.debug("cmd=%s"%cmd)
                     utils.run(cmd, self.passwordObj)
@@ -1580,11 +1578,14 @@ class CoreInstall(object):
 
 
     def check_wget(self):
-        if utils.which("wget"):
-            return True
+        if sys.platform.startswith('linux'):
+            if utils.which("wget"):
+                return True
+            else:
+                log.debug("wget is not installed")
+                return False
         else:
-            log.debug("wget is not installed")
-            return False
+            return True
 
     def check_avahi_utils(self):
         if utils.which("avahi-browse"):
@@ -1667,7 +1668,7 @@ class CoreInstall(object):
     def pre_build(self,distro_ver=None):
         cmds = []
         if self.get_distro_ver_data('fix_ppd_symlink', False,distro_ver):
-            cmds.append(self.passwordObj.getAuthCmd() % 'python ./installer/fix_symlink.py')
+            cmds.append(self.passwordObj.getAuthCmd() % '${MODPY_BIN} ./installer/fix_symlink.py')
 
         return cmds
 
