$OpenBSD: patch-installer_core_install_py,v 1.33 2020/12/04 12:36:50 ajacoutot Exp $

Index: installer/core_install.py
--- installer/core_install.py.orig
+++ installer/core_install.py
@@ -114,7 +114,7 @@ HPLIP_LIST = ['*.py', '*.pyc', 'base', 'copier', 'data
 
 PLUGIN_LIST = ['fax/plugins/', 'prnt/plugins/', 'scan/plugins/']
 
-PLUGIN_STATE = ['/var/lib/hp/hplip.state']
+PLUGIN_STATE = ['/var/db/hp/hplip.state']
 
 
 # end
@@ -244,7 +244,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
@@ -366,7 +366,7 @@ class CoreInstall(object):
             'cups-devel':       (True,  ['base', 'prnt'], CUPS_DEV_STR, self.check_cups_devel, DEPENDENCY_COMPILE_TIME, '-', 'cups-config --version', GENERALDEP),
             'cups-image':       (True,  ['base', 'prnt'], CUPS_IMG_STR, self.check_cups_image, DEPENDENCY_COMPILE_TIME, '-', 'cups-config --version', GENERALDEP),
             'gcc':             (True,  ['base', 'prnt'], GCC_STR, self.check_gcc, DEPENDENCY_COMPILE_TIME, '-', 'gcc --version', COMPILEDEP),
-            'make':            (True,  ['base', 'prnt'], MAKE_STR, self.check_make, DEPENDENCY_COMPILE_TIME, '3.0', 'make --version', COMPILEDEP),
+            'make':            (True,  ['base', 'prnt'], MAKE_STR, self.check_make, DEPENDENCY_COMPILE_TIME, '-', '-', COMPILEDEP),
             'libpthread':      (True,  ['base', 'prnt'], THREAD_STR, self.check_libpthread, DEPENDENCY_RUN_AND_COMPILE_TIME, '-', 'FUNC#get_libpthread_version', GENERALDEP),
             'gs':               (True,  ['base', 'prnt'], 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),
@@ -405,7 +405,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),
             #'setuptools':      (False, ['scan'], SETUPTOOLS_STR, self.check_setuptools, DEPENDENCY_RUN_TIME, '-', None, GENERALDEP),
             #'pip':          (True, ['scan'], PIP_STR, self.check_pip, DEPENDENCY_RUN_TIME, '-', None, GENERALDEP),
             #'pypdf2':          (True, ['scan'], PYPDF2_STR, self.check_pypdf2, DEPENDENCY_RUN_TIME, '-', None, GENERALDEP),
@@ -421,7 +421,7 @@ class CoreInstall(object):
             'pyqt5':            (True,  ['gui_qt5'], QT5_STR, self.check_pyqt5, DEPENDENCY_RUN_TIME, '5.0', 'FUNC#get_pyQt5_version', GENERALDEP),
             '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),
             #'imutils':          (True, ['scan'], IMUTILS_STR, self.check_imutils, DEPENDENCY_RUN_TIME, '-', None, GENERALDEP),
             # Optional fax packages
@@ -955,7 +955,7 @@ class CoreInstall(object):
         return check_tool('gcc --version', 0) and check_tool('g++ --version', 0)
 
     def check_make(self):
-        return check_tool('make --version', 3.0)
+        return True
        
     #def check_pkgconf(self):
         #return check_tool('pkgconf --version', 0)
@@ -966,14 +966,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
 
@@ -987,10 +987,10 @@ class CoreInstall(object):
         return check_lib("libjpeg") and check_file("jpeglib.h")
 
     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):
         return check_lib("libnetsnmp") and check_file("net-snmp-config.h")
@@ -1030,7 +1030,7 @@ class CoreInstall(object):
         return check_lib('libsane')
 
     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):
         if os.getenv('DISPLAY'):
@@ -1105,7 +1105,7 @@ class CoreInstall(object):
             return False
 
     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):
@@ -1157,13 +1157,8 @@ class CoreInstall(object):
             return False
 
     def check_dbus(self):
-        log.debug("Checking for dbus running and header files present (dbus-devel)...")
-        if (self.distro_name.lower()=='fedora') and (self.distro_version>='30'):
-            return True
-        else:
-            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):
         return check_file('cups.h') and bool(utils.which('lpr'))
@@ -1178,11 +1173,11 @@ class CoreInstall(object):
             return True
 
     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):
         log.debug("Checking for libtool...")
@@ -1249,7 +1244,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/")
 
     def check_libavahi_dev(self):
         log.debug("Checking for libavahi-dev")
@@ -1304,7 +1299,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','${SYSCONFDIR}/sane.d/dll.d/hpaio', '${SYSCONFDIR}/sane.d/dll.d/hplip']:
             log.debug("'Checking for hpaio' in '%s'..." % path)
             try:
                 f = open(path, 'r')
@@ -1333,13 +1328,13 @@ 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'
+                        "'${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:
@@ -1352,20 +1347,20 @@ 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")
+                            "'${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)
@@ -1831,11 +1826,14 @@ class CoreInstall(object):
         return num_opt_missing
 
     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"):
@@ -1961,7 +1959,7 @@ class CoreInstall(object):
         cmds = []
         if self.get_distro_ver_data('fix_ppd_symlink', False, distro_ver):
             cmds.append(self.passwordObj.getAuthCmd() %
-                        'python ./installer/fix_symlink.py')
+                        '${MODPY_BIN} ./installer/fix_symlink.py')
 
         return cmds
 
