################################################################################
import os
+from os.path import normpath
import re
import psycopg2
import traceback
from datetime import datetime, timedelta
from errno import ENOENT
from tempfile import mkstemp, mkdtemp
+from subprocess import Popen, PIPE
+from tarfile import TarFile
from inspect import getargspec
def get_component_name(self):
return self.poolfile.location.component.component_name
+ def scan_contents(self):
+ '''
+ Yields the contents of the package. Only regular files are yielded and
+ the path names are normalized.
+ '''
+ fullpath = self.poolfile.fullpath
+ debdata = Popen(['dpkg-deb', '--fsys-tarfile', fullpath],
+ stdout = PIPE).stdout
+ tar = TarFile.open(fileobj = debdata, mode = 'r|')
+ for member in tar.getmembers():
+ if member.isfile():
+ yield normpath(member.name)
+ tar.close()
+ debdata.close()
+
__all__.append('DBBinary')
@session_wrapper
self.assertEqual('tests/fixtures/ftp/squeeze/main/Contents-i386.gz', \
cw.output_filename())
+ def test_scan_contents(self):
+ self.setup_binaries()
+ filelist = [f for f in self.binary['hello_2.2-1_i386'].scan_contents()]
+ self.assertEqual(['usr/bin/hello', 'usr/share/doc/hello/copyright'],
+ filelist)
+
def classes_to_clean(self):
return [Override, Suite, BinContents, DBBinary, DBSource, Architecture, Section, \
OverrideType, Maintainer, Component, Priority, PoolFile]