--- hplip-3.11.10/base/pkit.py.org 2011-11-30 20:01:59.640469386 +0100 +++ hplip-3.11.10/base/pkit.py 2011-11-30 20:06:43.216664960 +0100 @@ -30,6 +30,11 @@ import shutil import stat +try: + from hashlib import md5 as md5 +except ImportError: + from md5 import md5 + # Local from base.logger import * from base.g import * @@ -318,7 +323,32 @@ log.debug("shutdown: %s" % str(e)) return False - +def binaryPatch(f): + try: + # file, md5sum, replace content at address with specified byte + patches = { 'lj-x86_32.so' : { 'md5': '30bdf8c844508a53d80362f9eba670c5', + # https://bugs.launchpad.net/hplip/+bug/666780 + 'replace' : [ (0xA068, 0x10) ] }, + 'lj-x86_64.so' : { 'md5': '28e1b2cde011cbbcd4b5c85c1866c893', + # https://bugs.launchpad.net/hplip/+bug/666780 + 'replace' : [ (0xD0D0, 0x10) ] } + } + fs = os.path.basename(f) + if fs in patches: + d = open(f, 'rb').read() + m = md5() + m.update(d) + m.digest() + if patches[fs]['md5'] == m.hexdigest(): + file = open(f, 'rb+') + for (addr, val) in patches[fs]['replace']: + file.seek(addr) + file.write(chr(val)) + file.close() + except Exception, e: + log.error("Could not patch binary `%s' for known issues." % str(e)) + return False + return True def copyPluginFiles(src_dir): os.chdir(src_dir) @@ -411,6 +441,9 @@ continue else: + + binaryPatch(trg) + if not os.path.exists(trg): log.error("Target file %s does not exist. File copy failed." % trg) continue