On Sun, Jan 27, 2008 at 01:16:14PM -0800, Cameron Dale wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Package: python-debian
> Version: 0.1.8
> Severity: normal
> 
> debfile doesn't understand the new package format that uses data.tar.bz2. You
> can see this by using the dpkg-info script in the examples to try and read a
> file in this new format, e.g.:
> 
> http://ftp.us.debian.org/debian/pool/main/v/vim/vim-runtime_7.1-241+1_all.deb

I came up with the attached patch, it works but I'll give Zack a change to
comment and/or adapt before commit.

filippo
--
Filippo Giunchedi - http://esaurito.net
PGP key: 0x6B79D401
random quote follows:

Date: Tuesday, 2002/10/22 - 08:09
dselect proves the existence of Satan. It's the worst part of Debian.
=== modified file 'debian_bundle/debfile.py'
--- debian_bundle/debfile.py	2007-08-20 17:37:07 +0000
+++ debian_bundle/debfile.py	2008-02-06 19:13:22 +0000
@@ -1,6 +1,6 @@
 # DebFile: a Python representation of Debian .deb binary packages.
-# Copyright (C) 2007    Stefano Zacchiroli  <[EMAIL PROTECTED]>
-# Copyright (C) 2007    Filippo Giunchedi   <[EMAIL PROTECTED]>
+# Copyright (C) 2007-2008    Stefano Zacchiroli  <[EMAIL PROTECTED]>
+# Copyright (C) 2007-2008    Filippo Giunchedi   <[EMAIL PROTECTED]>
 #
 # 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
@@ -15,6 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import bz2
 import gzip
 import string
 import tarfile
@@ -24,6 +25,7 @@
 from changelog import Changelog
 from deb822 import Deb822
 
+REQUIRED_DATA_PART = ['data.tar.gz', 'data.tar.bz2']
 DATA_PART = 'data.tar.gz'
 CTRL_PART = 'control.tar.gz'
 INFO_PART = 'debian-binary'
@@ -64,8 +66,11 @@
         package."""
 
         if self.__tgz is None:
-            gz = gzip.GzipFile(fileobj=self.__member, mode='r')
-            self.__tgz = tarfile.TarFile(fileobj=gz, mode='r')
+            if self.__member.name.endswith('.gz'):
+                zfile = gzip.GzipFile(fileobj=self.__member, mode='r')
+            elif self.__member.name.endswith('.bz2'):
+                zfile = bz2.BZ2File(fileobj=self.__member, mode='r')
+            self.__tgz = tarfile.TarFile(fileobj=zfile, mode='r')
         return self.__tgz
 
     @staticmethod
@@ -188,14 +193,25 @@
     """
 
     def __init__(self, filename=None, mode='r', fileobj=None):
+        global DATA_PART
         ArFile.__init__(self, filename, mode, fileobj)
-        required_names = set([INFO_PART, CTRL_PART, DATA_PART])
+        
+        required_data = set(REQUIRED_DATA_PART)
+        required_names = set([INFO_PART, CTRL_PART])
         actual_names = set(self.getnames())
         if not (required_names <= actual_names):
             raise DebError(
                     "the following required .deb members are missing: " \
                             + string.join(required_names - actual_names))
 
+        found_data = actual_names.intersection(required_data)
+        if not found_data:
+            raise DebError(
+                    "the following required .deb members are missing: " \
+                            + string.join(required_data - actual_names))
+
+        DATA_PART = found_data.pop()
+
         self.__parts = {}
         self.__parts[CTRL_PART] = DebControl(self.getmember(CTRL_PART))
         self.__parts[DATA_PART] = DebData(self.getmember(DATA_PART))

Reply via email to