X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=b5e090da3eb24324f89307fedff7920928115d4c;hb=904ac9b520fb3a9449a42f7f26e71c372789227d;hp=4744f6a2f214dd7cbf67aee9a5b4cae54c604a7a;hpb=5d965c34b35048f8a8fab0a7a11f2943d833952d;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py index 4744f6a2..b5e090da 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -1548,12 +1548,12 @@ def parse_wnpp_bug_file(file = "/srv/ftp-master.debian.org/scripts/masterfiles/w returns a dict associating source package name with a list of open wnpp bugs (Yes, there might be more than one) """ - + line = [] try: f = open(file) lines = f.readlines() - except IOerror, e: + except IOError, e: print "Warning: Couldn't open %s; don't know about WNPP bugs, so won't close any." % file lines = [] wnpp = {} @@ -1572,3 +1572,40 @@ def parse_wnpp_bug_file(file = "/srv/ftp-master.debian.org/scripts/masterfiles/w wnpp[source] = bugs return wnpp +################################################################################ + +def get_packages_from_ftp(root, suite, component, architecture): + """ + Returns an object containing apt_pkg-parseable data collected by + aggregating Packages.gz files gathered for each architecture. + + @type root: string + @param root: path to ftp archive root directory + + @type suite: string + @param suite: suite to extract files from + + @type component: string + @param component: component to extract files from + + @type architecture: string + @param architecture: architecture to extract files from + + @rtype: TagFile + @return: apt_pkg class containing package data + + """ + filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (root, suite, component, architecture) + (fd, temp_file) = temp_filename() + (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_file)) + if (result != 0): + fubar("Gunzip invocation failed!\n%s\n" % (output), result) + filename = "%s/dists/%s/%s/debian-installer/binary-%s/Packages.gz" % (root, suite, component, architecture) + if os.path.exists(filename): + (result, output) = commands.getstatusoutput("gunzip -c %s >> %s" % (filename, temp_file)) + if (result != 0): + fubar("Gunzip invocation failed!\n%s\n" % (output), result) + packages = open_file(temp_file) + Packages = apt_pkg.ParseTagFile(packages) + os.unlink(temp_file) + return Packages