def validate_sources(suite, component): """ Ensure files mentioned in Sources exist """ filename = "%s/dists/%s/%s/source/Sources" % (Cnf["Dir::Root"], suite, component) filename = utils.find_possibly_compressed_file(filename) print("Processing %s..." % (filename)) with apt_pkg.TagFile(filename) as Sources: while Sources.step(): source = Sources.section.find('Package') directory = Sources.section.find('Directory') files = Sources.section.find('Files') for i in files.split('\n'): (md5, size, name) = i.split() filename = "%s/%s/%s" % (Cnf["Dir::Root"], directory, name) if not os.path.exists(filename): if directory.find("potato") == -1: print("W: %s missing." % (filename)) else: pool_location = utils.poolify(source) pool_filename = "%s/%s/%s" % (Cnf["Dir::Pool"], pool_location, name) if not os.path.exists(pool_filename): print("E: %s missing (%s)." % (filename, pool_filename)) else: # Create symlink pool_filename = os.path.normpath(pool_filename) filename = os.path.normpath(filename) src = utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"]) print("Symlinking: %s -> %s" % (filename, src))
def validate_sources(suite, component): """ Ensure files mentioned in Sources exist """ cnf = Config() filename = "%s/dists/%s/%s/source/Sources.gz" % (cnf["Dir::Root"], suite, component) print "Processing %s..." % (filename) # apt_pkg.TagFile needs a real file handle and can't handle a GzipFile instance... (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) sources = utils.open_file(temp_filename) Sources = apt_pkg.TagFile(sources) while Sources.step(): source = Sources.section.find('Package') directory = Sources.section.find('Directory') files = Sources.section.find('Files') for i in files.split('\n'): (md5, size, name) = i.split() filename = "%s/%s/%s" % (cnf["Dir::Root"], directory, name) if not os.path.exists(filename): if directory.find("potato") == -1: print "W: %s missing." % (filename) else: pool_location = utils.poolify(source, component) pool_filename = "%s/%s/%s" % (cnf["Dir::Pool"], pool_location, name) if not os.path.exists(pool_filename): print "E: %s missing (%s)." % (filename, pool_filename) else: # Create symlink pool_filename = os.path.normpath(pool_filename) filename = os.path.normpath(filename) src = utils.clean_symlink(pool_filename, filename, cnf["Dir::Root"]) print "Symlinking: %s -> %s" % (filename, src) #os.symlink(src, filename) sources.close() os.unlink(temp_filename)
def validate_sources(suite, component): """ Ensure files mentioned in Sources exist """ cnf = Config() filename = "%s/dists/%s/%s/source/Sources.gz" % (cnf["Dir::Root"], suite, component) print "Processing %s..." % (filename) # apt_pkg.TagFile needs a real file handle and can't handle a GzipFile instance... (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) sys.exit(result) sources = utils.open_file(temp_filename) Sources = apt_pkg.TagFile(sources) while Sources.step(): source = Sources.section.find('Package') directory = Sources.section.find('Directory') files = Sources.section.find('Files') for i in files.split('\n'): (md5, size, name) = i.split() filename = "%s/%s/%s" % (cnf["Dir::Root"], directory, name) if not os.path.exists(filename): if directory.find("potato") == -1: print "W: %s missing." % (filename) else: pool_location = utils.poolify (source, component) pool_filename = "%s/%s/%s" % (cnf["Dir::Pool"], pool_location, name) if not os.path.exists(pool_filename): print "E: %s missing (%s)." % (filename, pool_filename) else: # Create symlink pool_filename = os.path.normpath(pool_filename) filename = os.path.normpath(filename) src = utils.clean_symlink(pool_filename, filename, cnf["Dir::Root"]) print "Symlinking: %s -> %s" % (filename, src) #os.symlink(src, filename) sources.close() os.unlink(temp_filename)