# -*- coding: utf-8 -*- # # (c) Copyright 2003-2007 Hewlett-Packard Development Company, L.P. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Author: Don Welch # # Std Lib import sys import os import os.path import re import time import cStringIO import grp import pwd import urllib # TODO: Replace with urllib2 (urllib is deprecated in Python 3.0) import sha # TODO: Replace with hashlib (sha is deprecated in Python 3.0) import tarfile # Local from base.g import * from base.codes import * from base import utils, pexpect from dcheck import * DISTRO_UNKNOWN = 0 DISTRO_VER_UNKNOWN = '0.0' MODE_INSTALLER = 0 # hplip-install/hp-setup MODE_CHECK = 1 # hp-check MODE_CREATE_DOCS = 2 # create_docs TYPE_STRING = 1 TYPE_LIST = 2 TYPE_BOOL = 3 TYPE_INT = 4 DEPENDENCY_RUN_TIME = 1 DEPENDENCY_COMPILE_TIME = 2 DEPENDENCY_RUN_AND_COMPILE_TIME = 3 PING_TARGET = "www.google.com" HTTP_GET_TARGET = "http://www.google.com" PASSWORD_LIST = [ 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 "heslo", # czech ] PASSWORD_EXPECT_LIST = [] for s in PASSWORD_LIST: try: p = re.compile(s, re.I) except TypeError: PASSWORD_EXPECT_LIST.append(s) else: PASSWORD_EXPECT_LIST.append(p) OK_PROCESS_LIST = ['adpept-notifier', 'yum-updatesd', ] CONFIGURE_ERRORS = { 1 : "General/unknown error", 2 : "libusb not found", 3 : "cups-devel not found", 4 : "libnetsnmp not found", 5 : "netsnmp-devel not found", 6 : "python-devel not found", 7 : "pthread-devel not found", 8 : "ppdev-devel not found", 9 : "libcups not found", 10 : "libm not found", 11 : "libusb-devel not found", 12 : "sane-backends-devel not found", 13 : "libdbus not found", 14 : "dbus-devel not found", 15 : "fax requires dbus support", 102 : "libjpeg not found", 103 : "jpeg-devel not found", 104 : "libdi not found", } try: from functools import update_wrapper except ImportError: # using Python version < 2.5 def trace(f): def newf(*args, **kw): log.debug("TRACE: func=%s(), args=%s, kwargs=%s" % (f.__name__, args, kw)) return f(*args, **kw) newf.__name__ = f.__name__ newf.__dict__.update(f.__dict__) newf.__doc__ = f.__doc__ newf.__module__ = f.__module__ return newf else: # using Python 2.5+ def trace(f): def newf(*args, **kw): log.debug("TRACE: func=%s(), args=%s, kwargs=%s" % (f.__name__, args, kw)) return f(*args, **kw) return update_wrapper(newf, f) class CoreInstall(object): def __init__(self, mode=MODE_INSTALLER, ui_mode=INTERACTIVE_MODE): os.umask(0022) self.mode = mode self.ui_mode = ui_mode self.password = '' self.version_description, self.version_public, self.version_internal = '', '', '' self.bitness = 32 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.hpoj_present = False self.hplip_present = False self.have_dependencies = {} self.cups11 = False self.hpijs_build = False self.ppd_dir = None self.drv_dir = None self.distros = {} self.logoff_required = False self.restart_required = False self.network_connected = False self.ui_toolkit = 'qt3' self.enable = None self.disable = None self.plugin_path = os.path.join(prop.home_dir, "data", "plugin") self.plugin_version = '0.0.0' self.plugin_name = '' self.FIELD_TYPES = { 'distros' : TYPE_LIST, 'index' : TYPE_INT, 'versions' : TYPE_LIST, 'display_name' : TYPE_STRING, 'alt_names': TYPE_LIST, 'display': TYPE_BOOL, 'notes': TYPE_STRING, 'package_mgrs': TYPE_LIST, 'package_mgr_cmd':TYPE_STRING, 'pre_install_cmd': TYPE_LIST, 'pre_depend_cmd': TYPE_LIST, 'post_depend_cmd': TYPE_LIST, 'hpoj_remove_cmd': TYPE_STRING, 'hplip_remove_cmd': TYPE_STRING, 'su_sudo': TYPE_STRING, 'ppd_install': TYPE_STRING, 'udev_mode_fix': TYPE_BOOL, 'ppd_dir': TYPE_STRING, 'drv_dir' : TYPE_STRING, 'fix_ppd_symlink': TYPE_BOOL, 'code_name': TYPE_STRING, '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 'cups_path_with_bitness' : TYPE_BOOL, 'ui_toolkit' : TYPE_STRING, # qt3 or qt4 [or gtk] } # components # 'name': ('description', [