]>
Commit | Line | Data |
---|---|---|
fb0d6296 AM |
1 | --- hplip-3.11.10/base/pkit.py.org 2011-11-30 20:01:59.640469386 +0100 |
2 | +++ hplip-3.11.10/base/pkit.py 2011-11-30 20:06:43.216664960 +0100 | |
f72e0b03 AM |
3 | @@ -30,6 +30,11 @@ |
4 | import shutil | |
5 | import stat | |
6 | ||
7 | +try: | |
8 | + from hashlib import md5 as md5 | |
9 | +except ImportError: | |
10 | + from md5 import md5 | |
11 | + | |
12 | # Local | |
13 | from base.logger import * | |
14 | from base.g import * | |
65f2802b | 15 | @@ -318,7 +323,32 @@ |
3452672b AM |
16 | log.debug("shutdown: %s" % str(e)) |
17 | return False | |
18 | ||
19 | - | |
20 | +def binaryPatch(f): | |
6de0c927 | 21 | + try: |
3452672b AM |
22 | + # file, md5sum, replace content at address with specified byte |
23 | + patches = { 'lj-x86_32.so' : { 'md5': '30bdf8c844508a53d80362f9eba670c5', | |
24 | + # https://bugs.launchpad.net/hplip/+bug/666780 | |
fb0d6296 AM |
25 | + 'replace' : [ (0xA068, 0x10) ] }, |
26 | + 'lj-x86_64.so' : { 'md5': '28e1b2cde011cbbcd4b5c85c1866c893', | |
27 | + # https://bugs.launchpad.net/hplip/+bug/666780 | |
28 | + 'replace' : [ (0xD0D0, 0x10) ] } | |
29 | + } | |
65f2802b AM |
30 | + fs = os.path.basename(f) |
31 | + if fs in patches: | |
3452672b | 32 | + d = open(f, 'rb').read() |
f72e0b03 | 33 | + m = md5() |
3452672b AM |
34 | + m.update(d) |
35 | + m.digest() | |
65f2802b | 36 | + if patches[fs]['md5'] == m.hexdigest(): |
3452672b | 37 | + file = open(f, 'rb+') |
65f2802b | 38 | + for (addr, val) in patches[fs]['replace']: |
3452672b AM |
39 | + file.seek(addr) |
40 | + file.write(chr(val)) | |
41 | + file.close() | |
42 | + except Exception, e: | |
65f2802b | 43 | + log.error("Could not patch binary `%s' for known issues." % str(e)) |
3452672b AM |
44 | + return False |
45 | + return True | |
46 | ||
47 | def copyPluginFiles(src_dir): | |
48 | os.chdir(src_dir) | |
65f2802b | 49 | @@ -411,6 +441,9 @@ |
3452672b AM |
50 | continue |
51 | ||
52 | else: | |
53 | + | |
c7a44e0a | 54 | + binaryPatch(trg) |
3452672b AM |
55 | + |
56 | if not os.path.exists(trg): | |
57 | log.error("Target file %s does not exist. File copy failed." % trg) | |
58 | continue |