summaryrefslogtreecommitdiff
path: root/installer/core_install.py
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2016-01-04 16:45:25 +0100
committerDidier Raboud <odyx@debian.org>2016-01-04 16:45:25 +0100
commitbfdf57b19d6d77d62d062df9872a06064c4fc468 (patch)
treeec226a7327dee095f7ddc77c8812d7fa9997df11 /installer/core_install.py
parent9e61c3c0f74d2e88ddacf5a802227bdd0eafd522 (diff)
Imported Upstream version 2.8.4
Diffstat (limited to 'installer/core_install.py')
-rw-r--r--installer/core_install.py190
1 files changed, 132 insertions, 58 deletions
diff --git a/installer/core_install.py b/installer/core_install.py
index feae1e59d..568d407f9 100644
--- a/installer/core_install.py
+++ b/installer/core_install.py
@@ -51,13 +51,19 @@ HTTP_GET_TARGET = "http://www.google.com"
PLUGIN_CONF_URL = "http://hplip.sf.net/plugins.conf"
PASSWORD_LIST = [
-pexpect.EOF, # 0
-pexpect.TIMEOUT, # 1
-"passwor[dt]", # en/de
-"password for", # en
-"mot de passe", # fr
+ pexpect.EOF, # 0
+ pexpect.TIMEOUT, # 1
+ "passwor[dt]", # en/de/it/ru
+ "kennwort", # de?
+ "password for", # en
+ "mot de passe", # fr
+ "contraseña", # es
+ "palavra passe", # pt
+ "口令", # zh
+ "wachtwoord", # nl
]
+
PASSWORD_EXPECT_LIST = []
for s in PASSWORD_LIST:
try:
@@ -136,11 +142,19 @@ class CoreInstall(object):
'drv_dir' : TYPE_STRING,
'fix_ppd_symlink': TYPE_BOOL,
'code_name': TYPE_STRING,
- 'supported': TYPE_BOOL,
+ 'supported': TYPE_BOOL, # Supported by installer
'release_date': TYPE_STRING,
'packages': TYPE_LIST,
'commands': TYPE_LIST,
'same_as_version' : TYPE_STRING,
+ 'gui_supported' : TYPE_BOOL,
+ 'scan_supported' : TYPE_BOOL,
+ 'fax_supported' : TYPE_BOOL,
+ 'pcard_supported' : TYPE_BOOL,
+ 'network_supported' : TYPE_BOOL,
+ 'parallel_supported' : TYPE_BOOL,
+ 'usb_supported' : TYPE_BOOL,
+ 'packaged_version': TYPE_STRING, # Version of HPLIP pre-packaged in distro
}
# components
@@ -201,6 +215,8 @@ class CoreInstall(object):
'python2x': (True, ['base'], "Python 2.2 or greater - Python programming language", self.check_python2x, DEPENDENCY_RUN_AND_COMPILE_TIME),
'gs': (True, ['base', 'hpijs'], "GhostScript - PostScript and PDF language interpreter and previewer", self.check_gs, DEPENDENCY_RUN_TIME),
'libusb': (True, ['base'], "libusb - USB library", self.check_libusb, DEPENDENCY_RUN_AND_COMPILE_TIME),
+
+
# Optional base packages
'cups-ddk': (False, ['base'], "cups-ddk - CUPS driver development kit", self.check_cupsddk, DEPENDENCY_RUN_TIME), # req. for .drv PPD installs
@@ -216,13 +232,18 @@ class CoreInstall(object):
# Required fax packages
'python23': (True, ['fax'], "Python 2.3 or greater - Required for fax functionality", self.check_python23, DEPENDENCY_RUN_TIME),
+ 'dbus': (True, ['fax'], "dbus - Message bus system", self.check_dbus, DEPENDENCY_RUN_AND_COMPILE_TIME),
+ 'python-dbus': (True, ['fax'], "python-dbus - Python bindings for dbus", self.check_python_dbus, DEPENDENCY_RUN_TIME),
+ 'python-ctypes': (True, ['fax'], "python-ctypes - A foreign function library for Python", self.check_python_ctypes, DEPENDENCY_RUN_TIME),
+
+ # Optional fax packages
'reportlab': (False, ['fax'], "Reportlab - PDF library for Python", self.check_reportlab, DEPENDENCY_RUN_TIME),
# Required parallel I/O packages
'ppdev': (True, ['parallel'], "ppdev - Parallel port support kernel module.", self.check_ppdev, DEPENDENCY_RUN_TIME),
# Required gui packages
- 'pyqt': (True, ['gui'], "PyQt - Qt interface for Python", self.check_pyqt, DEPENDENCY_RUN_TIME),
+ 'pyqt': (True, ['gui'], "PyQt - Qt interface for Python", self.check_pyqt, DEPENDENCY_RUN_TIME), # PyQt 3.x
# Required network I/O packages
'libnetsnmp-devel': (True, ['network'], "libnetsnmp-devel - SNMP networking library development files", self.check_libnetsnmp, DEPENDENCY_RUN_AND_COMPILE_TIME),
@@ -236,6 +257,14 @@ class CoreInstall(object):
self.options[opt][2].append(d)
self.load_distros()
+
+ #for d in self.distros:
+ # print
+## import pprint
+## print "6: ", pprint.pprint(self.distros['fedora']['versions']['6'])
+## print
+## print "6.0: ", pprint.pprint(self.distros['fedora']['versions']['6.0'])
+## sys.exit(1)
self.distros_index = {}
for d in self.distros:
@@ -333,6 +362,7 @@ class CoreInstall(object):
if callback is not None:
callback("Done")
+
def init_for_docs(self, distro_name, version, bitness=32):
self.distro_name = distro_name
self.distro_version = version
@@ -345,7 +375,6 @@ class CoreInstall(object):
self.bitness = bitness
-
for d in self.dependencies:
self.have_dependencies[d] = True
@@ -390,7 +419,7 @@ class CoreInstall(object):
ok, ret = False, ''
# Hack! TODO: Fix!
check_timeout = not (cmd.startswith('xterm') or cmd.startswith('gnome-terminal'))
-
+
try:
child = pexpect.spawn(cmd, timeout=1)
except pexpect.ExceptionPexpect:
@@ -410,12 +439,13 @@ class CoreInstall(object):
# output
start = time.time()
log.log_to_file(cb)
+ log.debug(cb)
output.write(cb)
if callback is not None:
if callback(cb): # cancel
break
-
+
elif check_timeout:
# no output
span = int(time.time()-start)
@@ -546,18 +576,25 @@ class CoreInstall(object):
self.ppd_dir = self.get_distro_ver_data('ppd_dir')
- if not self.ppd_dir or not os.path.exists(self.ppd_dir):
+ if not self.ppd_dir:
log.warning("Invalid ppd_dir value: %s" % self.ppd_dir)
self.drv_dir = self.get_distro_ver_data('drv_dir')
- if not self.enable_ppds and (not self.drv_dir or not os.path.exists(self.drv_dir)):
+ if not self.enable_ppds and not self.drv_dir:
log.warning("Invalid drv_dir value: %s" % self.drv_dir)
self.distro_version_supported = self.get_distro_ver_data('supported', False)
-
+ self.selected_options['fax'] = self.get_distro_ver_data('fax-supported', True)
+ self.selected_options['gui'] = self.get_distro_ver_data('gui-supported', True)
+ self.selected_options['network'] = self.get_distro_ver_data('network-supported', True)
+ self.selected_options['scan'] = self.get_distro_ver_data('scan-supported', True)
+ self.selected_options['parallel'] = self.get_distro_ver_data('parallel-supported', False)
+
def __fixup_data(self, key, data):
field_type = self.FIELD_TYPES.get(key, TYPE_STRING)
+ #log.debug("%s (%s) %d" % (key, data, field_type))
+
if field_type == TYPE_BOOL:
return utils.to_bool(data)
@@ -592,12 +629,12 @@ class CoreInstall(object):
distros_dat_file = os.path.join('installer', 'distros.dat')
distros_dat = Config(distros_dat_file, True)
-
- distros_list = distros_dat.distros.distros.split(',')
+ distros_list = self.__fixup_data('distros', distros_dat.distros.distros)
log.debug(distros_list)
for distro in distros_list:
update_spinner()
+ d = {}
try:
distro_section = distros_dat[distro]
except KeyError:
@@ -605,56 +642,57 @@ class CoreInstall(object):
continue
for key in distro_section:
- distro_section[key] = self.__fixup_data(key, distro_section[key])
+ d[key] = self.__fixup_data(key, distro_section[key])
- self.distros[distro] = distro_section
-
- if type(self.distros[distro]['versions']) == type(''):
- self.distros[distro]['versions'] = [self.distros[distro]['versions']]
-
- temp_versions = self.distros[distro]['versions']
+ self.distros[distro] = d
+ versions = self.__fixup_data("versions", distros_dat[distro]['versions'])
self.distros[distro]['versions'] = {}
- for ver in temp_versions:
- v = ver
+ for ver in versions:
+ v = {}
try:
- ver_section = distros_dat["%s:%s" % (distro, v)].copy()
+ ver_section = distros_dat["%s:%s" % (distro, ver)]
except KeyError:
- log.debug("Missing version section in distros.dat: [%s:%s]" % (distro, v))
+ log.debug("Missing version section in distros.dat: [%s:%s]" % (distro, ver))
continue
for key in ver_section:
- ver_section[key] = self.__fixup_data(key, ver_section[key])
-
- if 'same_as_version' in ver_section:
- v = ver_section['same_as_version']
+ v[key] = self.__fixup_data(key, ver_section[key])
+
+ self.distros[distro]['versions'][ver] = v
+ self.distros[distro]['versions'][ver]['dependency_cmds'] = {}
+ for dep in self.dependencies:
+ dd = {}
try:
- ver_section = distros_dat["%s:%s" % (distro, v)].copy()
- ver_section['same_as_version'] = v
+ dep_section = distros_dat["%s:%s:%s" % (distro, ver, dep)].copy()
except KeyError:
- log.debug("Missing 'same_as_version=' version in distros.dat for section [%s:%s]." % (distro, v))
+ log.debug("Missing dependency section in distros.dat: [%s:%s:%s]" % (distro, ver, dep))
continue
- self.distros[distro]['versions'][ver] = ver_section
- self.distros[distro]['versions'][ver]['dependency_cmds'] = {}
-
- #if utils.to_bool(ver_section['supported']):
- if 1:
- for dep in self.dependencies:
- try:
- dep_section = distros_dat["%s:%s:%s" % (distro, v, dep)].copy()
- except KeyError:
- log.debug("Missing dependency section in distros.dat: [%s:%s:%s]" % (distro, v, dep))
- continue
-
-
- for key in dep_section:
- dep_section[key] = self.__fixup_data(key, dep_section[key])
- self.distros[distro]['versions'][ver]['dependency_cmds'][dep] = dep_section
-
+ for key in dep_section:
+ dd[key] = self.__fixup_data(key, dep_section[key])
+
+ self.distros[distro]['versions'][ver]['dependency_cmds'][dep] = dd
+
+ versions = self.distros[distro]['versions']
+ for ver in versions:
+ ver_section = distros_dat["%s:%s" % (distro, ver)]
+
+ if 'same_as_version' in ver_section:
+ v = self.__fixup_data("same_as_version", ver_section['same_as_version'])
+ log.debug("Setting %s:%s to %s:%s" % (distro, ver, distro, v))
+ try:
+ vv = self.distros[distro]['versions'][v].copy()
+ vv['same_as_version'] = v
+ self.distros[distro]['versions'][ver] = vv
+ except KeyError:
+ log.debug("Missing 'same_as_version=' version in distros.dat for section [%s:%s]." % (distro, v))
+ continue
+
+
def pre_install(self):
pass
@@ -682,7 +720,7 @@ class CoreInstall(object):
if not check_lib('libusb'):
return False
- return len(locate_file_contains("usb.h", '/usr/include', 'usb_init(void)')) > 0
+ return len(locate_file_contains("usb.h", '/usr/include', 'usb_init(void)'))
def check_libjpeg(self):
@@ -737,7 +775,7 @@ class CoreInstall(object):
def check_sane_devel(self):
- return len(locate_file_contains("sane.h", '/usr/include', 'extern SANE_Status sane_init')) > 0
+ return len(locate_file_contains("sane.h", '/usr/include', 'extern SANE_Status sane_init'))
def check_xsane(self):
@@ -766,11 +804,11 @@ class CoreInstall(object):
try:
pyqtVersion = qt.PYQT_VERSION_STR
log.debug("PYQT_VERSION_STR = %s" % pyqtVersion)
- except:
+ except AttributeError:
try:
pyqtVersion = qt.PYQT_VERSION
log.debug("PYQT_VERSION = %s" % pyqtVersion)
- except:
+ except AttributeError:
pass
if pyqtVersion is not None:
@@ -808,14 +846,50 @@ class CoreInstall(object):
return check_file('Python.h')
+ def check_python_dbus(self):
+ log.debug("Checking for python-dbus (>= 0.80)...")
+ try:
+ import dbus
+ try:
+ ver = dbus.version
+ log.debug("Version: %s" % '.'.join([str(x) for x in dbus.version]))
+ return ver >= (0,80,0)
+
+ except AttributeError:
+ try:
+ ver = dbus.__version__
+ log.debug("Version: %s" % dbus.__version__)
+ log.debug("HPLIP requires dbus version > 0.80.")
+ return False
+
+ except AttributeError:
+ log.debug("Unknown version. HPLIP requires dbus version > 0.80.")
+ return False
+
+ except ImportError:
+ return False
+
+
+ def check_python_ctypes(self):
+ try:
+ import ctypes
+ return True
+ except ImportError:
+ return False
+
+
+ def check_dbus(self):
+ log.debug("Checking for dbus running...")
+ return check_ps(['dbus-daemon']) and \
+ len(locate_file_contains("dbus-message.h", '/usr/include', 'dbus_message_new_signal'))
+
+
def check_cups_devel(self):
return check_file('cups.h') and bool(utils.which('lpr'))
def check_cups(self):
status, output = self.run('lpstat -r')
-
-
if status > 0:
log.debug("CUPS is not running.")
return False
@@ -831,7 +905,7 @@ class CoreInstall(object):
def check_hplip(self):
- log.debug("Checking for HPLIP...")
+ log.debug("Checking for HPLIP (pre-2.x)...")
return check_ps(['hpiod', 'hpssd']) and locate_files('hplip.conf', '/etc/hp')
@@ -1086,7 +1160,7 @@ class CoreInstall(object):
if not overall_commands_to_run:
log.error("No cmds/pkgs")
-
+
return overall_commands_to_run