----
- arfile.py | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ipkg.py | 106 ++++++++++++++++++++++++++---------------------------
- setup.py | 2 -
- 3 files changed, 177 insertions(+), 55 deletions(-)
-
-Index: ipkg-utils/arfile.py
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ ipkg-utils/arfile.py 2007-05-26 23:46:59.000000000 +0100
+diff -r 720080c24d2f arfile.py
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arfile.py Sun Jan 27 23:26:35 2008 +0200
@@ -0,0 +1,124 @@
+"""
+arfile - A module to parse GNU ar archives.
+
+ f2 = tarf.extractfile("control")
+ print f2.read()
-Index: ipkg-utils/setup.py
-===================================================================
---- ipkg-utils.orig/setup.py 2007-05-26 23:45:55.000000000 +0100
-+++ ipkg-utils/setup.py 2007-05-26 23:46:59.000000000 +0100
-@@ -16,6 +16,6 @@ distutils.core.setup( name = 'ipkg-utils
- platforms = 'POSIX',
- keywords = 'ipkg familiar',
- url = 'http://www.handhelds.org/sources.html/',
-- py_modules = [ 'ipkg' ],
-+ py_modules = [ 'ipkg', 'arfile' ],
- scripts = ['ipkg-compare-indexes', 'ipkg-make-index', 'ipkg-update-index', 'ipkg-build', 'ipkg-unbuild', 'ipkg-upload']
- )
-Index: ipkg-utils/ipkg.py
-===================================================================
---- ipkg-utils.orig/ipkg.py 2007-05-26 23:46:55.000000000 +0100
-+++ ipkg-utils/ipkg.py 2007-05-26 23:45:20.000000000 +0100
-@@ -41,6 +41,8 @@ import re
+diff -r 720080c24d2f ipkg.py
+--- a/ipkg.py Sun Jan 27 23:13:26 2008 +0200
++++ b/ipkg.py Sun Jan 27 23:26:35 2008 +0200
+@@ -41,6 +41,8 @@ import string
import string
import commands
from stat import ST_SIZE
class Version:
"""A class for holding parsed package version information."""
-@@ -131,78 +133,61 @@ class Package:
+@@ -131,77 +133,61 @@ class Package:
self.section = None
self.filename_header = None
self.file_list = []
- self.size = stat[ST_SIZE]
+
self.filename = os.path.basename(fn)
-+ assert self.isdeb == 1, "Old ipk format (non-deb) is unsupported"
-+
## sys.stderr.write(" extracting control.tar.gz from %s\n"% (fn,))
- if self.isdeb:
- control = os.popen("ar p "+fn+" control.tar.gz | tar xfzO - './control'","r")
- self.__dict__[name] = value
- else:
- line = control.readline()
++ if self.isdeb:
++ ar = arfile.ArFile(f)
++ tarStream = ar.open("control.tar.gz")
++ tarf = tarfile.open("control.tar.gz", "r", tarStream)
++
++ try:
++ control = tarf.extractfile("control")
++ except KeyError:
++ control = tarf.extractfile("./control")
++ else:
++ control = os.popen("tar --wildcards -xzO -f " + fn + " '*control.tar.gz' | tar xfzO - './control'", "r")
+
-+ ar = arfile.ArFile(f)
-+ tarStream = ar.open("control.tar.gz")
-+ tarf = tarfile.open("control.tar.gz", "r", tarStream)
-+
-+ try:
-+ control = tarf.extractfile("control")
-+ except KeyError:
-+ control = tarf.extractfile("./control")
+ self.read_control(control)
control.close()
- if self.isdeb:
self.scratch_dir = None
self.file_dir = None
self.meta_dir = None
-
++
+ def __getattr__(self, name):
+ if name == "md5":
+ self._computeFileMD5()
+ sum.update(data)
+ f.close()
+ self.md5 = sum.hexdigest()
-+
+
def read_control(self, control):
import os
-
-@@ -221,9 +203,15 @@ class Package:
+@@ -221,9 +207,15 @@ class Package:
value = value + '\n' + line
if name == 'size':
self.size = int(value)
return # consumes one blank line at end of package descriptoin
else:
line = control.readline()
-@@ -314,6 +302,16 @@ class Package:
+@@ -314,7 +306,27 @@ class Package:
return self.section
def get_file_list(self):
+- return self.file_list
+ if not self.fn:
+ return []
-+ f = open(self.fn, "rb")
-+ ar = arfile.ArFile(f)
-+ tarStream = ar.open("data.tar.gz")
-+ tarf = tarfile.open("data.tar.gz", "r", tarStream)
-+ self.file_list = tarf.getnames()
++
++ if self.isdeb:
++ f = open(self.fn, "rb")
++ ar = arfile.ArFile(f)
++ tarStream = ar.open("data.tar.gz")
++ tarf = tarfile.open("data.tar.gz", "r", tarStream)
++ self.file_list = tarf.getnames()
++ f.close()
++ else:
++ f = os.popen("tar xfzO " + self.fn + " '*data.tar.gz' | tar tfz -","r")
++ while 1:
++ line = f.readline()
++ if not line: break
++ self.file_list.append(string.rstrip(line))
++ f.close()
++
++ # Make sure that filelist has consistent format regardless of tar version
+ self.file_list = map(lambda a: ["./", ""][a.startswith("./")] + a, self.file_list)
-+
-+ f.close()
- return self.file_list
++ return self.file_list
def write_package(self, dirname):
+ buf = self.render_control()
+diff -r 720080c24d2f setup.py
+--- a/setup.py Sun Jan 27 23:13:26 2008 +0200
++++ b/setup.py Sun Jan 27 23:26:35 2008 +0200
+@@ -16,6 +16,6 @@ distutils.core.setup( name = 'ipkg-utils
+ platforms = 'POSIX',
+ keywords = 'ipkg familiar',
+ url = 'http://www.handhelds.org/sources.html/',
+- py_modules = [ 'ipkg' ],
++ py_modules = [ 'ipkg', 'arfile' ],
+ scripts = ['ipkg-compare-indexes', 'ipkg-make-index', 'ipkg-update-index', 'ipkg-build', 'ipkg-unbuild', 'ipkg-upload']
+ )