$OpenBSD: patch-installer_core_install_py,v 1.27 2016/05/05 08:25:31 ajacoutot Exp $
--- installer/core_install.py.orig	Wed May  4 07:23:15 2016
+++ installer/core_install.py	Thu May  5 10:06:53 2016
@@ -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
@@ -228,7 +228,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
@@ -342,7 +342,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),
@@ -373,7 +373,7 @@ 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_qt5', '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 )
@@ -381,7 +381,7 @@ class CoreInstall(object):
             'pyqt5':            (True,  ['gui_qt5'], QT5_STR, self.check_pyqt5, DEPENDENCY_RUN_TIME,'5.0','FUNC#get_pyQt5_version', GENERALDEP), # PyQt 5.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),
@@ -881,7 +881,7 @@ class CoreInstall(object):
 
 
     def check_make(self):
-        return check_tool('make --version', 3.0)
+        return True
 
 
     def check_libusb(self):
@@ -890,14 +890,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
 
@@ -907,11 +907,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):
@@ -957,7 +956,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):
@@ -1035,7 +1034,7 @@ class CoreInstall(object):
 
 
     def check_python_devel(self):
-        dir_list = glob.glob('/usr/include/python%d*'%sys.version_info[0])
+        dir_list = glob.glob('${LOCALBASE}/include/python%d*'%sys.version_info[0])
         Found = False
         for p in dir_list:
               if check_file('Python.h',dir=p):
@@ -1089,9 +1088,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):
@@ -1109,12 +1107,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):
@@ -1134,7 +1132,7 @@ class CoreInstall(object):
     def check_cupsddk(self):
         log.debug("Checking for cups-ddk...")
         # TODO: Compute these paths some way or another...
-        return check_file('media.defs', "/usr/share/cups/ppdc/")
+        return check_file('media.defs', "${LOCALBASE}/share/cups/ppdc/")
 
 
 
@@ -1185,7 +1183,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')
@@ -1214,12 +1212,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:
@@ -1232,19 +1230,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)
@@ -1667,11 +1665,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"):
@@ -1757,7 +1758,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
 
