diff options
author | Richard Purdie <richard@openedhand.com> | 2007-05-26 22:46:47 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2007-05-26 22:46:47 +0000 |
commit | e010532f60e5f03887366cf93fb57fdaf89bc757 (patch) | |
tree | f056234fc50786220c78d9d8416b86b09b871d15 /meta | |
parent | 1fa7f838731998a125d6c7865309bd5e9852f1e0 (diff) | |
download | poky-e010532f60e5f03887366cf93fb57fdaf89bc757.tar.gz |
ipkg-utils: Merge in tweaked version of patches from OE bug #1504 (from Paul Sokolovsky) to massively speed ipkg-make-index
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1780 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta')
-rw-r--r-- | meta/packages/ipkg-utils/ipkg-utils-native_1.6+cvs20050404.bb | 4 | ||||
-rw-r--r-- | meta/packages/ipkg-utils/ipkg-utils/index_speedup.patch | 53 | ||||
-rw-r--r-- | meta/packages/ipkg-utils/ipkg-utils/ipkg-make-index-track-stamps.patch | 97 | ||||
-rw-r--r-- | meta/packages/ipkg-utils/ipkg-utils/ipkg-py-sane-vercompare.patch | 51 | ||||
-rw-r--r-- | meta/packages/ipkg-utils/ipkg-utils/ipkg-py-tarfile.patch | 306 | ||||
-rw-r--r-- | meta/packages/ipkg-utils/ipkg-utils/ipkg-utils-fix.patch (renamed from meta/packages/ipkg-utils/ipkg-utils-native/ipkg-utils-fix.patch) | 17 | ||||
-rw-r--r-- | meta/packages/ipkg-utils/ipkg-utils_1.6+cvs20050404.bb | 13 |
7 files changed, 471 insertions, 70 deletions
diff --git a/meta/packages/ipkg-utils/ipkg-utils-native_1.6+cvs20050404.bb b/meta/packages/ipkg-utils/ipkg-utils-native_1.6+cvs20050404.bb index 8079b46267..a0964d65b3 100644 --- a/meta/packages/ipkg-utils/ipkg-utils-native_1.6+cvs20050404.bb +++ b/meta/packages/ipkg-utils/ipkg-utils-native_1.6+cvs20050404.bb | |||
@@ -1,14 +1,14 @@ | |||
1 | require ipkg-utils_${PV}.bb | 1 | require ipkg-utils_${PV}.bb |
2 | SRC_URI += "file://ipkg-utils-fix.patch;patch=1" | ||
3 | 2 | ||
4 | RDEPENDS = "" | 3 | RDEPENDS = "" |
5 | PR = "r8" | 4 | PR = "r11" |
6 | 5 | ||
7 | inherit native | 6 | inherit native |
8 | 7 | ||
9 | # Avoid circular dependencies from package_ipk.bbclass | 8 | # Avoid circular dependencies from package_ipk.bbclass |
10 | PACKAGES = "" | 9 | PACKAGES = "" |
11 | FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/ipkg-utils" | 10 | FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/ipkg-utils" |
11 | INSTALL += "arfile.py" | ||
12 | 12 | ||
13 | do_stage() { | 13 | do_stage() { |
14 | for i in ${INSTALL}; do | 14 | for i in ${INSTALL}; do |
diff --git a/meta/packages/ipkg-utils/ipkg-utils/index_speedup.patch b/meta/packages/ipkg-utils/ipkg-utils/index_speedup.patch deleted file mode 100644 index bef28a9df1..0000000000 --- a/meta/packages/ipkg-utils/ipkg-utils/index_speedup.patch +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | Index: ipkg-utils/ipkg-make-index | ||
2 | =================================================================== | ||
3 | --- ipkg-utils.orig/ipkg-make-index 2005-03-20 18:10:54.000000000 +0000 | ||
4 | +++ ipkg-utils/ipkg-make-index 2006-07-24 09:18:16.000000000 +0100 | ||
5 | @@ -37,6 +37,21 @@ | ||
6 | if os.path.exists(pkg_dir + "/" + filename + ".asc"): | ||
7 | os.rename(pkg_dir + "/" + filename + ".asc", locale_dir + "/" + filename + ".asc") | ||
8 | |||
9 | +def md5sum(file): | ||
10 | + import md5 | ||
11 | + sum = md5.new() | ||
12 | + f = open(file, "r") | ||
13 | + while 1: | ||
14 | + data = f.read(1024) | ||
15 | + if not data: break | ||
16 | + sum.update(data) | ||
17 | + f.close() | ||
18 | + if sys.version[:1] > '2': | ||
19 | + # when using Python 2.0 or newer | ||
20 | + return sum.hexdigest() | ||
21 | + else: | ||
22 | + return string.join(map((lambda x:"%02x" % ord(x)),sum.digest()),'') | ||
23 | + | ||
24 | old_filename = None | ||
25 | packages_filename = None | ||
26 | filelist_filename = "Packages.filelist" | ||
27 | @@ -87,7 +102,7 @@ | ||
28 | files.sort() | ||
29 | for filename in files: | ||
30 | basename = os.path.basename(filename) | ||
31 | - if old_pkg_hash.has_key(basename): | ||
32 | + if old_pkg_hash.has_key(basename) and old_pkg_hash[basename].md5 == md5sum(filename) and old_pkg_hash[basename].size == os.stat(filename)[6]: | ||
33 | if (verbose): | ||
34 | sys.stderr.write("Found %s in Packages\n" % (filename,)) | ||
35 | pkg = old_pkg_hash[basename] | ||
36 | Index: ipkg-utils/ipkg.py | ||
37 | =================================================================== | ||
38 | --- ipkg-utils.orig/ipkg.py 2005-01-20 23:09:10.000000000 +0000 | ||
39 | +++ ipkg-utils/ipkg.py 2006-07-24 09:16:44.000000000 +0100 | ||
40 | @@ -210,8 +210,13 @@ | ||
41 | value = value + '\n' + line | ||
42 | if name == 'size': | ||
43 | self.size = int(value) | ||
44 | + elif name == 'md5sum': | ||
45 | + self.md5 = value | ||
46 | elif self.__dict__.has_key(name): | ||
47 | self.__dict__[name] = value | ||
48 | + else: | ||
49 | + print "Lost field %s, %s" % (name,value) | ||
50 | + | ||
51 | if line[0] == '\n': | ||
52 | return # consumes one blank line at end of package descriptoin | ||
53 | else: | ||
diff --git a/meta/packages/ipkg-utils/ipkg-utils/ipkg-make-index-track-stamps.patch b/meta/packages/ipkg-utils/ipkg-utils/ipkg-make-index-track-stamps.patch new file mode 100644 index 0000000000..9f9b9359ce --- /dev/null +++ b/meta/packages/ipkg-utils/ipkg-utils/ipkg-make-index-track-stamps.patch | |||
@@ -0,0 +1,97 @@ | |||
1 | --- | ||
2 | ipkg-make-index | 31 +++++++++++++++++++++++++++---- | ||
3 | 1 file changed, 27 insertions(+), 4 deletions(-) | ||
4 | |||
5 | Index: ipkg-utils/ipkg-make-index | ||
6 | =================================================================== | ||
7 | --- ipkg-utils.orig/ipkg-make-index 2007-05-26 23:45:56.000000000 +0100 | ||
8 | +++ ipkg-utils/ipkg-make-index 2007-05-26 23:47:25.000000000 +0100 | ||
9 | @@ -40,6 +40,7 @@ def to_locale(filename, locale): | ||
10 | old_filename = None | ||
11 | packages_filename = None | ||
12 | filelist_filename = "Packages.filelist" | ||
13 | +stamplist_filename = "Packages.stamps" | ||
14 | opt_s = 0 | ||
15 | opt_m = 0 | ||
16 | (opts, remaining_args) = getopt.getopt(sys.argv[1:], "hl:p:vsmr:L:") | ||
17 | @@ -50,6 +51,7 @@ for (optkey, optval) in opts: | ||
18 | opt_s = 1 | ||
19 | if optkey == '-p': | ||
20 | packages_filename = optval | ||
21 | + stamplist_filename = optval + ".stamps" | ||
22 | if optkey == '-l': | ||
23 | filelist_filename = optval | ||
24 | if optkey == '-v': | ||
25 | @@ -72,6 +74,7 @@ old_pkg_hash = {} | ||
26 | if packages_filename and not old_filename and os.path.exists(packages_filename): | ||
27 | old_filename = packages_filename | ||
28 | |||
29 | +pkgsStamps = {} | ||
30 | if old_filename: | ||
31 | if (verbose): | ||
32 | sys.stderr.write("Reading package list from " + old_filename + "\n") | ||
33 | @@ -80,6 +83,14 @@ if old_filename: | ||
34 | for k in old_packages.packages.keys(): | ||
35 | p = old_packages.packages[k] | ||
36 | old_pkg_hash[p.filename] = p | ||
37 | + try: | ||
38 | + f = open(stamplist_filename, "r") | ||
39 | + for l in f: | ||
40 | + l = l.strip() | ||
41 | + s, f = l.split(" ", 1) | ||
42 | + pkgsStamps[f] = int(s) | ||
43 | + except IOError: | ||
44 | + pass | ||
45 | |||
46 | if (verbose): | ||
47 | sys.stderr.write("Reading in all the package info from %s\n" % (pkg_dir, )) | ||
48 | @@ -87,11 +98,17 @@ files=glob(pkg_dir + '/*.ipk') + glob(pk | ||
49 | files.sort() | ||
50 | for filename in files: | ||
51 | basename = os.path.basename(filename) | ||
52 | + pkg = None | ||
53 | + fnameStat = os.stat(filename) | ||
54 | if old_pkg_hash.has_key(basename): | ||
55 | - if (verbose): | ||
56 | + if pkgsStamps.has_key(basename) and fnameStat.st_mtime == pkgsStamps[basename]: | ||
57 | + if (verbose): | ||
58 | sys.stderr.write("Found %s in Packages\n" % (filename,)) | ||
59 | - pkg = old_pkg_hash[basename] | ||
60 | - else: | ||
61 | + pkg = old_pkg_hash[basename] | ||
62 | + else: | ||
63 | + sys.stderr.write("Found %s in Packages, but mtime differs - re-reading\n" % (filename,)) | ||
64 | + | ||
65 | + if not pkg: | ||
66 | if (verbose): | ||
67 | sys.stderr.write("Reading info for package %s\n" % (filename,)) | ||
68 | pkg = ipkg.Package(filename) | ||
69 | @@ -101,6 +118,7 @@ for filename in files: | ||
70 | else: | ||
71 | old_filename = "" | ||
72 | s = packages.add_package(pkg) | ||
73 | + pkgsStamps[basename] = fnameStat.st_mtime | ||
74 | if s == 0: | ||
75 | if old_filename: | ||
76 | # old package was displaced by newer | ||
77 | @@ -114,6 +132,11 @@ for filename in files: | ||
78 | if opt_s: | ||
79 | print filename | ||
80 | |||
81 | +pkgsStampsFile = open(stamplist_filename, "w") | ||
82 | +for f in pkgsStamps.keys(): | ||
83 | + pkgsStampsFile.write("%d %s\n" % (pkgsStamps[f], f)) | ||
84 | +pkgsStampsFile.close() | ||
85 | + | ||
86 | if opt_s: | ||
87 | sys.exit(0) | ||
88 | |||
89 | @@ -154,7 +177,7 @@ if packages_filename: | ||
90 | os.rename(tmp_packages_filename, packages_filename) | ||
91 | os.rename(tmp_gzip_filename, gzip_filename) | ||
92 | |||
93 | -if verbose: | ||
94 | +if verbose: | ||
95 | sys.stderr.write("Generate Packages.filelist file\n") | ||
96 | files = {} | ||
97 | names = packages.packages.keys() | ||
diff --git a/meta/packages/ipkg-utils/ipkg-utils/ipkg-py-sane-vercompare.patch b/meta/packages/ipkg-utils/ipkg-utils/ipkg-py-sane-vercompare.patch new file mode 100644 index 0000000000..00ee391405 --- /dev/null +++ b/meta/packages/ipkg-utils/ipkg-utils/ipkg-py-sane-vercompare.patch | |||
@@ -0,0 +1,51 @@ | |||
1 | Only in ipkg-utils: ipkg-py-sane-vercompare.patch | ||
2 | diff -ur ipkg-utils.org/ipkg.py ipkg-utils/ipkg.py | ||
3 | --- ipkg-utils.org/ipkg.py 2005-01-08 18:08:52.000000000 +0000 | ||
4 | +++ ipkg-utils/ipkg.py 2007-04-04 11:52:46.000000000 +0000 | ||
5 | @@ -48,9 +48,9 @@ | ||
6 | self.epoch = epoch | ||
7 | self.version = version | ||
8 | |||
9 | - def _versioncompare(self, ref): | ||
10 | - selfversion = self.version | ||
11 | - refversion = ref.version | ||
12 | + def _versioncompare(self, selfversion, refversion): | ||
13 | + if not selfversion: selfversion = "" | ||
14 | + if not refversion: refversion = "" | ||
15 | while 1: | ||
16 | ## first look for non-numeric version component | ||
17 | selfm = re.match('([^0-9]*)(.*)', selfversion) | ||
18 | @@ -89,7 +89,18 @@ | ||
19 | elif (self.epoch < ref.epoch): | ||
20 | return -1 | ||
21 | else: | ||
22 | - return self._versioncompare(ref) | ||
23 | + self_ver_comps = re.match(r"(.+?)(-r.+)?$", self.version) | ||
24 | + ref_ver_comps = re.match(r"(.+?)(-r.+)?$", ref.version) | ||
25 | + #print (self_ver_comps.group(1), self_ver_comps.group(2)) | ||
26 | + #print (ref_ver_comps.group(1), ref_ver_comps.group(2)) | ||
27 | + r = self._versioncompare(self_ver_comps.group(1), ref_ver_comps.group(1)) | ||
28 | + if r == 0: | ||
29 | + r = self._versioncompare(self_ver_comps.group(2), ref_ver_comps.group(2)) | ||
30 | + #print "compare: %s vs %s = %d" % (self, ref, r) | ||
31 | + return r | ||
32 | + | ||
33 | + def __str__(self): | ||
34 | + return str(self.epoch) + ":" + self.version | ||
35 | |||
36 | def parse_version(versionstr): | ||
37 | epoch = 0 | ||
38 | @@ -445,6 +456,13 @@ | ||
39 | return self.packages[key] | ||
40 | |||
41 | if __name__ == "__main__": | ||
42 | + | ||
43 | + assert Version(0, "1.2.2-r1").compare(Version(0, "1.2.3-r0")) == -1 | ||
44 | + assert Version(0, "1.2.2-r0").compare(Version(0, "1.2.2+cvs20070308-r0")) == -1 | ||
45 | + assert Version(0, "1.2.2+cvs20070308").compare(Version(0, "1.2.2-r0")) == 1 | ||
46 | + assert Version(0, "1.2.2-r0").compare(Version(0, "1.2.2-r0")) == 0 | ||
47 | + assert Version(0, "1.2.2-r5").compare(Version(0, "1.2.2-r0")) == 1 | ||
48 | + | ||
49 | package = Package() | ||
50 | |||
51 | package.set_package("FooBar") | ||
diff --git a/meta/packages/ipkg-utils/ipkg-utils/ipkg-py-tarfile.patch b/meta/packages/ipkg-utils/ipkg-utils/ipkg-py-tarfile.patch new file mode 100644 index 0000000000..94c57f63f2 --- /dev/null +++ b/meta/packages/ipkg-utils/ipkg-utils/ipkg-py-tarfile.patch | |||
@@ -0,0 +1,306 @@ | |||
1 | --- | ||
2 | arfile.py | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
3 | ipkg.py | 106 ++++++++++++++++++++++++++--------------------------- | ||
4 | setup.py | 2 - | ||
5 | 3 files changed, 177 insertions(+), 55 deletions(-) | ||
6 | |||
7 | Index: ipkg-utils/arfile.py | ||
8 | =================================================================== | ||
9 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
10 | +++ ipkg-utils/arfile.py 2007-05-26 23:46:59.000000000 +0100 | ||
11 | @@ -0,0 +1,124 @@ | ||
12 | +""" | ||
13 | +arfile - A module to parse GNU ar archives. | ||
14 | + | ||
15 | +Copyright (c) 2006-7 Paul Sokolovsky | ||
16 | +This file is released under the terms | ||
17 | +of GNU General Public License v2 or later. | ||
18 | +""" | ||
19 | +import sys | ||
20 | +import os | ||
21 | +import tarfile | ||
22 | + | ||
23 | + | ||
24 | +class FileSection: | ||
25 | + "A class which allows to treat portion of file as separate file object." | ||
26 | + | ||
27 | + def __init__(self, f, offset, size): | ||
28 | + self.f = f | ||
29 | + self.offset = offset | ||
30 | + self.size = size | ||
31 | + self.seek(0, 0) | ||
32 | + | ||
33 | + def seek(self, offset, whence = 0): | ||
34 | +# print "seek(%x, %d)" % (offset, whence) | ||
35 | + if whence == 0: | ||
36 | + return self.f.seek(offset + self.offset, whence) | ||
37 | + elif whence == 1: | ||
38 | + return self.f.seek(offset, whence) | ||
39 | + elif whence == 2: | ||
40 | + return self.f.seek(self.offset + self.size + offset, 0) | ||
41 | + else: | ||
42 | + assert False | ||
43 | + | ||
44 | + def tell(self): | ||
45 | +# print "tell()" | ||
46 | + return self.f.tell() - self.offset | ||
47 | + | ||
48 | + def read(self, size = -1): | ||
49 | +# print "read(%d)" % size | ||
50 | + return self.f.read(size) | ||
51 | + | ||
52 | +class ArFile: | ||
53 | + | ||
54 | + def __init__(self, f): | ||
55 | + self.f = f | ||
56 | + self.directory = {} | ||
57 | + self.directoryRead = False | ||
58 | + | ||
59 | + signature = self.f.readline() | ||
60 | + assert signature == "!<arch>\n" | ||
61 | + self.directoryOffset = self.f.tell() | ||
62 | + | ||
63 | + def open(self, fname): | ||
64 | + if self.directory.has_key(fname): | ||
65 | + return FileSection(self.f, self.directory[fname][-1], int(self.directory[fname][5])) | ||
66 | + | ||
67 | + if self.directoryRead: | ||
68 | + raise IOError, (2, "AR member not found: " + fname) | ||
69 | + | ||
70 | + f = self._scan(fname) | ||
71 | + if f == None: | ||
72 | + raise IOError, (2, "AR member not found: " + fname) | ||
73 | + return f | ||
74 | + | ||
75 | + | ||
76 | + def _scan(self, fname): | ||
77 | + self.f.seek(self.directoryOffset, 0) | ||
78 | + | ||
79 | + while True: | ||
80 | + l = self.f.readline() | ||
81 | + if not l: | ||
82 | + self.directoryRead = True | ||
83 | + return None | ||
84 | + | ||
85 | + if l == "\n": | ||
86 | + l = self.f.readline() | ||
87 | + if not l: break | ||
88 | + descriptor = l.split() | ||
89 | +# print descriptor | ||
90 | + size = int(descriptor[5]) | ||
91 | + memberName = descriptor[0][:-1] | ||
92 | + self.directory[memberName] = descriptor + [self.f.tell()] | ||
93 | +# print "read:", memberName | ||
94 | + if memberName == fname: | ||
95 | + # Record directory offset to start from next time | ||
96 | + self.directoryOffset = self.f.tell() + size | ||
97 | + return FileSection(self.f, self.f.tell(), size) | ||
98 | + | ||
99 | + # Skip data and loop | ||
100 | + data = self.f.seek(size, 1) | ||
101 | +# print hex(f.tell()) | ||
102 | + | ||
103 | + | ||
104 | +if __name__ == "__main__": | ||
105 | + if None: | ||
106 | + f = open(sys.argv[1], "rb") | ||
107 | + | ||
108 | + ar = ArFile(f) | ||
109 | + tarStream = ar.open("data.tar.gz") | ||
110 | + print "--------" | ||
111 | + tarStream = ar.open("data.tar.gz") | ||
112 | + print "--------" | ||
113 | + tarStream = ar.open("control.tar.gz") | ||
114 | + print "--------" | ||
115 | + tarStream = ar.open("control.tar.gz2") | ||
116 | + | ||
117 | + sys.exit(0) | ||
118 | + | ||
119 | + | ||
120 | + dir = "." | ||
121 | + if len(sys.argv) > 1: | ||
122 | + dir = sys.argv[1] | ||
123 | + for f in os.listdir(dir): | ||
124 | + if not f.endswith(".ipk"): continue | ||
125 | + | ||
126 | + print "=== %s ===" % f | ||
127 | + f = open(dir + "/" + f, "rb") | ||
128 | + | ||
129 | + ar = ArFile(f) | ||
130 | + tarStream = ar.open("control.tar.gz") | ||
131 | + tarf = tarfile.open("control.tar.gz", "r", tarStream) | ||
132 | + #tarf.list() | ||
133 | + | ||
134 | + f2 = tarf.extractfile("control") | ||
135 | + print f2.read() | ||
136 | Index: ipkg-utils/setup.py | ||
137 | =================================================================== | ||
138 | --- ipkg-utils.orig/setup.py 2007-05-26 23:45:55.000000000 +0100 | ||
139 | +++ ipkg-utils/setup.py 2007-05-26 23:46:59.000000000 +0100 | ||
140 | @@ -16,6 +16,6 @@ distutils.core.setup( name = 'ipkg-utils | ||
141 | platforms = 'POSIX', | ||
142 | keywords = 'ipkg familiar', | ||
143 | url = 'http://www.handhelds.org/sources.html/', | ||
144 | - py_modules = [ 'ipkg' ], | ||
145 | + py_modules = [ 'ipkg', 'arfile' ], | ||
146 | scripts = ['ipkg-compare-indexes', 'ipkg-make-index', 'ipkg-update-index', 'ipkg-build', 'ipkg-unbuild', 'ipkg-upload'] | ||
147 | ) | ||
148 | Index: ipkg-utils/ipkg.py | ||
149 | =================================================================== | ||
150 | --- ipkg-utils.orig/ipkg.py 2007-05-26 23:46:55.000000000 +0100 | ||
151 | +++ ipkg-utils/ipkg.py 2007-05-26 23:45:20.000000000 +0100 | ||
152 | @@ -41,6 +41,8 @@ import re | ||
153 | import string | ||
154 | import commands | ||
155 | from stat import ST_SIZE | ||
156 | +import arfile | ||
157 | +import tarfile | ||
158 | |||
159 | class Version: | ||
160 | """A class for holding parsed package version information.""" | ||
161 | @@ -131,78 +133,58 @@ class Package: | ||
162 | self.section = None | ||
163 | self.filename_header = None | ||
164 | self.file_list = [] | ||
165 | - self.md5 = None | ||
166 | + # md5 is lazy attribute, computed on demand | ||
167 | + #self.md5 = None | ||
168 | self.size = None | ||
169 | self.installed_size = None | ||
170 | self.filename = None | ||
171 | self.isdeb = 0 | ||
172 | + self.fn = fn | ||
173 | |||
174 | if fn: | ||
175 | # see if it is deb format | ||
176 | - f = open(fn, "r") | ||
177 | + f = open(fn, "rb") | ||
178 | magic = f.read(4) | ||
179 | - f.close() | ||
180 | + f.seek(0, 0) | ||
181 | if (magic == "!<ar"): | ||
182 | self.isdeb = 1 | ||
183 | |||
184 | - # compute the MD5. | ||
185 | - f = open(fn, "r") | ||
186 | - sum = md5.new() | ||
187 | - while 1: | ||
188 | - data = f.read(1024) | ||
189 | - if not data: break | ||
190 | - sum.update(data) | ||
191 | - f.close() | ||
192 | - if sys.version[:1] > '2': | ||
193 | - # when using Python 2.0 or newer | ||
194 | - self.md5 = sum.hexdigest() | ||
195 | - else: | ||
196 | - self.md5 = string.join(map((lambda x:"%02x" % ord(x)),sum.digest()),'') | ||
197 | - stat = os.stat(fn) | ||
198 | - self.size = stat[ST_SIZE] | ||
199 | + | ||
200 | self.filename = os.path.basename(fn) | ||
201 | + assert self.isdeb == 1, "Old ipk format (non-deb) is unsupported" | ||
202 | + | ||
203 | ## sys.stderr.write(" extracting control.tar.gz from %s\n"% (fn,)) | ||
204 | - if self.isdeb: | ||
205 | - control = os.popen("ar p "+fn+" control.tar.gz | tar xfzO - './control'","r") | ||
206 | - else: | ||
207 | - control = os.popen("tar xfzO "+fn+" 'control.tar.gz' | tar xfzO - './control'","r") | ||
208 | - line = control.readline() | ||
209 | - while 1: | ||
210 | - if not line: break | ||
211 | - line = string.rstrip(line) | ||
212 | - lineparts = re.match(r'([\w-]*?):\s*(.*)', line) | ||
213 | - if lineparts: | ||
214 | - name = string.lower(lineparts.group(1)) | ||
215 | - value = lineparts.group(2) | ||
216 | - while 1: | ||
217 | - line = control.readline() | ||
218 | - if not line: break | ||
219 | - if line[0] != ' ': break | ||
220 | - line = string.rstrip(line) | ||
221 | - value = value + '\n' + line | ||
222 | - # don't allow package to override its own filename | ||
223 | - if name == "filename": | ||
224 | - self.filename_header = value | ||
225 | - else: | ||
226 | - if self.__dict__.has_key(name): | ||
227 | - self.__dict__[name] = value | ||
228 | - else: | ||
229 | - line = control.readline() | ||
230 | + | ||
231 | + ar = arfile.ArFile(f) | ||
232 | + tarStream = ar.open("control.tar.gz") | ||
233 | + tarf = tarfile.open("control.tar.gz", "r", tarStream) | ||
234 | + | ||
235 | + control = tarf.extractfile("control") | ||
236 | + self.read_control(control) | ||
237 | control.close() | ||
238 | - if self.isdeb: | ||
239 | - data = os.popen("ar p "+fn+" data.tar.gz | tar tfz -","r") | ||
240 | - else: | ||
241 | - data = os.popen("tar xfzO "+fn+" '*data.tar.gz' | tar tfz -","r") | ||
242 | - while 1: | ||
243 | - line = data.readline() | ||
244 | - if not line: break | ||
245 | - self.file_list.append(string.rstrip(line)) | ||
246 | - data.close() | ||
247 | |||
248 | self.scratch_dir = None | ||
249 | self.file_dir = None | ||
250 | self.meta_dir = None | ||
251 | |||
252 | + def __getattr__(self, name): | ||
253 | + if name == "md5": | ||
254 | + self._computeFileMD5() | ||
255 | + return self.md5 | ||
256 | + else: | ||
257 | + raise AttributeError, name | ||
258 | + | ||
259 | + def _computeFileMD5(self): | ||
260 | + # compute the MD5. | ||
261 | + f = open(self.fn, "rb") | ||
262 | + sum = md5.new() | ||
263 | + while 1: | ||
264 | + data = f.read(1024) | ||
265 | + if not data: break | ||
266 | + sum.update(data) | ||
267 | + f.close() | ||
268 | + self.md5 = sum.hexdigest() | ||
269 | + | ||
270 | def read_control(self, control): | ||
271 | import os | ||
272 | |||
273 | @@ -221,9 +203,15 @@ class Package: | ||
274 | value = value + '\n' + line | ||
275 | if name == 'size': | ||
276 | self.size = int(value) | ||
277 | + elif name == 'md5sum': | ||
278 | + self.md5 = value | ||
279 | elif self.__dict__.has_key(name): | ||
280 | self.__dict__[name] = value | ||
281 | - if line[0] == '\n': | ||
282 | + else: | ||
283 | + #print "Lost field %s, %s" % (name,value) | ||
284 | + pass | ||
285 | + | ||
286 | + if line and line[0] == '\n': | ||
287 | return # consumes one blank line at end of package descriptoin | ||
288 | else: | ||
289 | line = control.readline() | ||
290 | @@ -314,6 +302,16 @@ class Package: | ||
291 | return self.section | ||
292 | |||
293 | def get_file_list(self): | ||
294 | + if not self.fn: | ||
295 | + return [] | ||
296 | + f = open(self.fn, "rb") | ||
297 | + ar = arfile.ArFile(f) | ||
298 | + tarStream = ar.open("data.tar.gz") | ||
299 | + tarf = tarfile.open("data.tar.gz", "r", tarStream) | ||
300 | + self.file_list = tarf.getnames() | ||
301 | + self.file_list = map(lambda a: ["./", ""][a.startswith("./")] + a, self.file_list) | ||
302 | + | ||
303 | + f.close() | ||
304 | return self.file_list | ||
305 | |||
306 | def write_package(self, dirname): | ||
diff --git a/meta/packages/ipkg-utils/ipkg-utils-native/ipkg-utils-fix.patch b/meta/packages/ipkg-utils/ipkg-utils/ipkg-utils-fix.patch index a9e6fc4d05..b3e0d62cd9 100644 --- a/meta/packages/ipkg-utils/ipkg-utils-native/ipkg-utils-fix.patch +++ b/meta/packages/ipkg-utils/ipkg-utils/ipkg-utils-fix.patch | |||
@@ -1,11 +1,14 @@ | |||
1 | --- ../../../work/i686-linux/ipkg-utils-native-1.6+cvs20050404-r6/ipkg-utils/ipkg.py 2005-01-08 19:08:52.000000000 +0100 | 1 | --- |
2 | +++ ipkg-utils/ipkg.py 2006-06-29 12:52:58.466446000 +0200 | 2 | ipkg.py | 4 ++-- |
3 | @@ -150,11 +150,11 @@ | 3 | 1 file changed, 2 insertions(+), 2 deletions(-) |
4 | stat = os.stat(fn) | 4 | |
5 | self.size = stat[ST_SIZE] | 5 | Index: ipkg-utils/ipkg.py |
6 | =================================================================== | ||
7 | --- ipkg-utils.orig/ipkg.py 2007-05-26 23:49:05.000000000 +0100 | ||
8 | +++ ipkg-utils/ipkg.py 2007-05-26 23:49:23.000000000 +0100 | ||
9 | @@ -152,9 +152,9 @@ class Package: | ||
6 | self.filename = os.path.basename(fn) | 10 | self.filename = os.path.basename(fn) |
7 | - ## sys.stderr.write(" extracting control.tar.gz from %s\n"% (fn,)) | 11 | ## sys.stderr.write(" extracting control.tar.gz from %s\n"% (fn,)) |
8 | + sys.stderr.write(" extracting control.tar.gz from %s\n"% (fn,)) | ||
9 | if self.isdeb: | 12 | if self.isdeb: |
10 | - control = os.popen("ar p "+fn+" control.tar.gz | tar xfzO - '*control'","r") | 13 | - control = os.popen("ar p "+fn+" control.tar.gz | tar xfzO - '*control'","r") |
11 | + control = os.popen("ar p "+fn+" control.tar.gz | tar xfzO - './control'","r") | 14 | + control = os.popen("ar p "+fn+" control.tar.gz | tar xfzO - './control'","r") |
diff --git a/meta/packages/ipkg-utils/ipkg-utils_1.6+cvs20050404.bb b/meta/packages/ipkg-utils/ipkg-utils_1.6+cvs20050404.bb index 48c7445828..6ffe6fe679 100644 --- a/meta/packages/ipkg-utils/ipkg-utils_1.6+cvs20050404.bb +++ b/meta/packages/ipkg-utils/ipkg-utils_1.6+cvs20050404.bb | |||
@@ -5,10 +5,13 @@ LICENSE = "GPL" | |||
5 | CONFLICTS = "ipkg-link" | 5 | CONFLICTS = "ipkg-link" |
6 | RDEPENDS = "python" | 6 | RDEPENDS = "python" |
7 | SRCDATE = "20050404" | 7 | SRCDATE = "20050404" |
8 | PR = "r12" | 8 | PR = "r14" |
9 | 9 | ||
10 | SRC_URI = "${HANDHELDS_CVS};module=ipkg-utils \ | 10 | SRC_URI = "${HANDHELDS_CVS};module=ipkg-utils \ |
11 | file://index_speedup.patch;patch=1" | 11 | file://ipkg-utils-fix.patch;patch=1 \ |
12 | file://ipkg-py-sane-vercompare.patch;patch=1 \ | ||
13 | file://ipkg-py-tarfile.patch;patch=1 \ | ||
14 | file://ipkg-make-index-track-stamps.patch;patch=1" | ||
12 | 15 | ||
13 | S = "${WORKDIR}/ipkg-utils" | 16 | S = "${WORKDIR}/ipkg-utils" |
14 | 17 | ||
@@ -26,9 +29,3 @@ do_install() { | |||
26 | done | 29 | done |
27 | } | 30 | } |
28 | 31 | ||
29 | #FIXME: ipkg-utils is not allowed to have packages or else a ipkg-native -> ipkg-utils -> ipkg-utils | ||
30 | # recursive dependency is triggered. This has been fixed by installing the ipkg-link script in | ||
31 | # a dedicated package. | ||
32 | #PACKAGES_prepend = "ipkg-link " | ||
33 | #FILES_ipkg-link = "${bindir}/ipkg-link" | ||
34 | |||