def setSeeds(self, seeds): self.seeds = seeds # Suppress most log information logging.getLogger().setLevel(logging.CRITICAL) global RELEASE, MIRROR, DIST, COMPONENTS, ARCH print "Germinating" g = Germinator() apt_pkg.InitConfig() apt_pkg.Config.Set("APT::Architecture", ARCH) Germinate.Archive.TagFile(MIRROR).feed(g, DIST, COMPONENTS, ARCH) (seednames, seedinherit) = g.parseStructure( Germinate.seeds.open_seed(SEEDS + RELEASE, "STRUCTURE")) for seedname in self.seeds: g.plantSeed(Germinate.seeds.open_seed(SEEDS + RELEASE, seedname), ARCH, seedname, list(seedinherit[seedname]), RELEASE) g.prune() g.grow() for seedname in self.seeds: for pkg in g.seed[seedname]: self.package.setdefault(pkg, Package(pkg)) self.package[pkg].setSeed(seedname + ".seed") for pkg in g.depends[seedname]: self.package.setdefault(pkg, Package(pkg)) self.package[pkg].setSeed(seedname + ".depends")
def __init__(self, arch=None): Germinator.__init__(self) if arch is None: arch = get_architecture() apt_pkg.InitConfig() apt_pkg.Config.Set("APT::Architecture", arch) apt_pkg.InitSystem()
def get_apt_cache_dir(): try: apt_pkg.InitConfig() _dir = os.path.join(apt_pkg.config.get("dir"), apt_pkg.config.get("dir::cache"), apt_pkg.config.get("dir::cache::archives")) except: _dir = "/var/cache/apt/archives" # default setting return _dir
def init(options, argv): global _default_config global _istatus apt_pkg.InitConfig() for key in _default_config.keys(): apt_pkg.Config[key] = _default_config[key] args = apt_pkg.ParseCommandLine(apt_pkg.Config, options, argv) apt_pkg.InitSystem() istatus_path = _retrieve_config_dir_path("Dir::Comps::InstalledState") if os.path.exists(istatus_path): istatus_f = open(istatus_path) _istatus = pickle.load(istatus_f) istatus_f.close() else: _quick_status("No installed status file found; creating one.") update_installed() return args
#!/usr/bin/python # This is a simple clone of tests/versiontest.cc import apt_pkg, sys, re, string apt_pkg.InitConfig() apt_pkg.InitSystem() TestFile = apt_pkg.ParseCommandLine(apt_pkg.Config, [], sys.argv) if len(TestFile) != 1: print "Must have exactly 1 file name" sys.exit(0) # Go over the file.. List = open(TestFile[0], "r") CurLine = 0 while (1): Line = List.readline() CurLine = CurLine + 1 if Line == "": break Line = string.strip(Line) if len(Line) == 0 or Line[0] == '#': continue Split = re.split("[ \n]", Line) # Check forward if apt_pkg.VersionCompare(Split[0], Split[1]) != int(Split[2]): print "Comparision failed on line %u. '%s' ? '%s' %i != %i" % ( CurLine, Split[0], Split[1], apt_pkg.VersionCompare(Split[0], Split[1]), int(Split[2]))
def main(): global SEEDS, RELEASE, MIRROR, SOURCE_MIRROR global DIST, ARCH, COMPONENTS, CHECK_IPV6 verbose = False bzr = False cleanup = False want_rdepends = True seed_packages = () g = Germinator() try: opts, args = getopt.getopt(sys.argv[1:], "hvS:s:m:d:c:a:i", [ "help", "verbose", "seed-source=", "seed-dist=", "mirror=", "source-mirror=", "dist=", "components=", "arch=", "ipv6", "bzr", "cleanup", "no-rdepends", "seed-packages=" ]) except getopt.GetoptError: usage(sys.stderr) sys.exit(2) for option, value in opts: if option in ("-h", "--help"): usage(sys.stdout) sys.exit() elif option in ("-v", "--verbose"): verbose = True elif option in ("-S", "--seed-source"): SEEDS = value if not SEEDS.endswith("/"): SEEDS += "/" elif option in ("-s", "--seed-dist"): RELEASE = value elif option in ("-m", "--mirror"): MIRROR = value if not MIRROR.endswith("/"): MIRROR += "/" elif option == "--source-mirror": SOURCE_MIRROR = value if not SOURCE_MIRROR.endswith("/"): SOURCE_MIRROR += "/" elif option in ("-d", "--dist"): DIST = value.split(",") elif option in ("-c", "--components"): COMPONENTS = value.split(",") elif option in ("-a", "--arch"): ARCH = value elif option in ("-i", "--ipv6"): CHECK_IPV6 = True elif option == "--bzr": bzr = True elif option == "--cleanup": cleanup = True elif option == "--no-rdepends": want_rdepends = False elif option == "--seed-packages": seed_packages = value.split(',') logger = logging.getLogger() if verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(Germinator.PROGRESS) handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter('%(levelname)s%(message)s')) logger.addHandler(handler) apt_pkg.InitConfig() apt_pkg.Config.Set("APT::Architecture", ARCH) Germinate.Archive.TagFile(MIRROR, SOURCE_MIRROR).feed(g, DIST, COMPONENTS, ARCH, cleanup) if CHECK_IPV6: g.parseIPv6(open_ipv6_tag_file("dailydump")) if os.path.isfile("hints"): g.parseHints(open("hints")) blacklist = Germinate.seeds.open_seed(SEEDS + RELEASE, "blacklist", bzr) if blacklist is not None: g.parseBlacklist(blacklist) (seednames, seedinherit) = g.parseStructure( Germinate.seeds.open_seed(SEEDS + RELEASE, "STRUCTURE", bzr)) for seedname in seednames: g.plantSeed(Germinate.seeds.open_seed(SEEDS + RELEASE, seedname, bzr), ARCH, seedname, list(seedinherit[seedname]), RELEASE) for seed_package in seed_packages: (parent, pkg) = seed_package.split('/') g.plantSeed([" * " + pkg], ARCH, pkg, seedinherit[parent] + [parent], RELEASE) seednames.append(pkg) g.prune() g.grow() g.addExtras(RELEASE) if want_rdepends: g.reverseDepends() seednames_extra = list(seednames) seednames_extra.append('extra') for seedname in seednames_extra: write_list( seedname, seedname, g, set(g.seed[seedname]) | set(g.seedrecommends[seedname]) | set(g.depends[seedname])) write_list(seedname, seedname + ".seed", g, g.seed[seedname]) write_list(seedname, seedname + ".seed-recommends", g, g.seedrecommends[seedname]) write_list(seedname, seedname + ".depends", g, g.depends[seedname]) write_list(seedname, seedname + ".build-depends", g, g.build_depends[seedname]) if seedname != "extra": write_source_list(seedname + ".sources", g, g.sourcepkgs[seedname]) write_source_list(seedname + ".build-sources", g, g.build_sourcepkgs[seedname]) all = set() sup = set() all_srcs = set() sup_srcs = set() for seedname in seednames: all.update(g.seed[seedname]) all.update(g.seedrecommends[seedname]) all.update(g.depends[seedname]) all.update(g.build_depends[seedname]) all_srcs.update(g.sourcepkgs[seedname]) all_srcs.update(g.build_sourcepkgs[seedname]) if seedname == "supported": sup.update(g.seed[seedname]) sup.update(g.seedrecommends[seedname]) sup.update(g.depends[seedname]) sup_srcs.update(g.sourcepkgs[seedname]) # Only include those build-dependencies that aren't already in the # dependency outputs for inner seeds of supported. This allows # supported+build-depends to be usable as an "everything else" # output. build_depends = dict.fromkeys(g.build_depends[seedname], True) build_sourcepkgs = dict.fromkeys(g.build_sourcepkgs[seedname], True) for seed in g.innerSeeds("supported"): build_depends.update(dict.fromkeys(g.seed[seed], False)) build_depends.update(dict.fromkeys(g.seedrecommends[seed], False)) build_depends.update(dict.fromkeys(g.depends[seed], False)) build_sourcepkgs.update(dict.fromkeys(g.sourcepkgs[seed], False)) sup.update([k for (k, v) in build_depends.iteritems() if v]) sup_srcs.update([k for (k, v) in build_sourcepkgs.iteritems() if v]) write_list("all", "all", g, all) write_source_list("all.sources", g, all_srcs) write_list("all", "supported+build-depends", g, sup) write_source_list("supported+build-depends.sources", g, sup_srcs) write_list("all", "all+extra", g, g.all) write_source_list("all+extra.sources", g, g.all_srcs) write_prov_list("provides", g.pkgprovides) if os.path.exists("rdepends"): shutil.rmtree("rdepends") if want_rdepends: os.mkdir("rdepends") os.mkdir(os.path.join("rdepends", "ALL")) for pkg in g.all: dirname = os.path.join("rdepends", g.packages[pkg]["Source"]) if not os.path.exists(dirname): os.mkdir(dirname) write_rdepend_list(os.path.join(dirname, pkg), g, pkg) os.symlink(os.path.join("..", g.packages[pkg]["Source"], pkg), os.path.join("rdepends", "ALL", pkg)) g.writeBlacklisted("blacklisted")