def set_seeds(self, options, seeds): self.seeds = seeds # Suppress most log information germinate_logging(logging.CRITICAL) logging.getLogger('germinate.archive').setLevel(logging.INFO) global MIRRORS, COMPONENTS print("Germinating") g = Germinator(options.arch) archive = germinate.archive.TagFile(options.dist, COMPONENTS, options.arch, MIRRORS, cleanup=True) g.parse_archive(archive) needed_seeds = [] build_tree = False try: structure = SeedStructure(options.release, options.seeds) for seedname in self.seeds: if seedname == ('%s+build-depends' % structure.supported): seedname = structure.supported build_tree = True needed_seeds.append(seedname) g.plant_seeds(structure, seeds=needed_seeds) except SeedError: sys.exit(1) g.grow(structure) for seedname in structure.names: for pkg in g.get_seed_entries(structure, seedname): self.package.setdefault(pkg, Package(pkg)) self.package[pkg].set_seed(seedname + ".seed") for pkg in g.get_seed_recommends_entries(structure, seedname): self.package.setdefault(pkg, Package(pkg)) self.package[pkg].set_seed(seedname + ".seed-recommends") for pkg in g.get_depends(structure, seedname): self.package.setdefault(pkg, Package(pkg)) self.package[pkg].set_seed(seedname + ".depends") if build_tree: build_depends = set(g.get_build_depends(structure, seedname)) for inner in structure.inner_seeds(structure.supported): build_depends -= set(g.get_seed_entries(structure, inner)) build_depends -= set( g.get_seed_recommends_entries(structure, inner)) build_depends -= g.get_depends(structure, inner) for pkg in build_depends: self.package.setdefault(pkg, Package(pkg)) self.package[pkg].set_seed(structure.supported + ".build-depends")
def set_seeds(self, options, seeds): self.seeds = seeds # Suppress most log information germinate_logging(logging.CRITICAL) logging.getLogger('germinate.archive').setLevel(logging.INFO) global MIRRORS, COMPONENTS print("Germinating") g = Germinator(options.arch) archive = germinate.archive.TagFile( options.dist, COMPONENTS, options.arch, MIRRORS, cleanup=True) g.parse_archive(archive) needed_seeds = [] build_tree = False try: structure = SeedStructure(options.release, options.seeds) for seedname in self.seeds: if seedname == ('%s+build-depends' % structure.supported): seedname = structure.supported build_tree = True needed_seeds.append(seedname) g.plant_seeds(structure, seeds=needed_seeds) except SeedError: sys.exit(1) g.grow(structure) for seedname in structure.names: for pkg in g.get_seed_entries(structure, seedname): self.package.setdefault(pkg, Package(pkg)) self.package[pkg].set_seed(seedname + ".seed") for pkg in g.get_seed_recommends_entries(structure, seedname): self.package.setdefault(pkg, Package(pkg)) self.package[pkg].set_seed(seedname + ".seed-recommends") for pkg in g.get_depends(structure, seedname): self.package.setdefault(pkg, Package(pkg)) self.package[pkg].set_seed(seedname + ".depends") if build_tree: build_depends = set(g.get_build_depends(structure, seedname)) for inner in structure.inner_seeds(structure.supported): build_depends -= set(g.get_seed_entries(structure, inner)) build_depends -= set(g.get_seed_recommends_entries( structure, inner)) build_depends -= g.get_depends(structure, inner) for pkg in build_depends: self.package.setdefault(pkg, Package(pkg)) self.package[pkg].set_seed(structure.supported + ".build-depends")
def test_depends_multiarch(self): """Compare Depends behaviour against the multiarch specification. https://wiki.ubuntu.com/MultiarchSpec """ for ma, qual, allowed in ( (None, "", True), (None, ":any", False), (None, ":native", False), ("same", "", True), ("same", ":any", False), ("same", ":native", False), ("foreign", "", True), ("foreign", ":any", False), ("foreign", ":native", False), ("allowed", "", True), ("allowed", ":any", True), ("allowed", ":native", False), ): self.addSource("precise", "main", "hello", "1.0-1", ["hello"]) self.addPackage("precise", "main", "i386", "hello", "1.0-1", fields={"Depends": "gettext%s" % qual}) self.addSource("precise", "main", "gettext", "0.18.1.1-5ubuntu3", ["gettext"]) package_fields = {} if ma is not None: package_fields["Multi-Arch"] = ma self.addPackage("precise", "main", "i386", "gettext", "0.18.1.1-5ubuntu3", fields=package_fields) branch = "collection.precise" self.addSeed(branch, "base") self.addSeedPackage(branch, "base", "hello") germinator = Germinator("i386") archive = TagFile("precise", "main", "i386", "file://%s" % self.archive_dir) germinator.parse_archive(archive) structure = self.openSeedStructure(branch) germinator.plant_seeds(structure) germinator.grow(structure) expected = set() if allowed: expected.add("gettext") self.assertEqual( expected, germinator.get_depends(structure, "base"), "Depends: gettext%s on Multi-Arch: %s incorrectly %s" % (qual, ma if ma else "none", "disallowed" if allowed else "allowed")) shutil.rmtree(self.archive_dir) shutil.rmtree(self.seeds_dir)
def test_depends_multiarch(self): """Compare Depends behaviour against the multiarch specification. https://wiki.ubuntu.com/MultiarchSpec """ for ma, qual, allowed in ( (None, "", True), (None, ":any", False), (None, ":native", False), ("same", "", True), ("same", ":any", False), ("same", ":native", False), ("foreign", "", True), ("foreign", ":any", False), ("foreign", ":native", False), ("allowed", "", True), ("allowed", ":any", True), ("allowed", ":native", False), ): self.addSource("precise", "main", "hello", "1.0-1", ["hello"]) self.addPackage("precise", "main", "i386", "hello", "1.0-1", fields={"Depends": "gettext%s" % qual}) self.addSource("precise", "main", "gettext", "0.18.1.1-5ubuntu3", ["gettext"]) package_fields = {} if ma is not None: package_fields["Multi-Arch"] = ma self.addPackage("precise", "main", "i386", "gettext", "0.18.1.1-5ubuntu3", fields=package_fields) branch = "collection.precise" self.addSeed(branch, "base") self.addSeedPackage(branch, "base", "hello") germinator = Germinator("i386") archive = TagFile( "precise", "main", "i386", "file://%s" % self.archive_dir) germinator.parse_archive(archive) structure = self.openSeedStructure(branch) germinator.plant_seeds(structure) germinator.grow(structure) expected = set() if allowed: expected.add("gettext") self.assertEqual( expected, germinator.get_depends(structure, "base"), "Depends: gettext%s on Multi-Arch: %s incorrectly %s" % ( qual, ma if ma else "none", "disallowed" if allowed else "allowed")) shutil.rmtree(self.archive_dir) shutil.rmtree(self.seeds_dir)
def test_versioned_provides(self): """Germinator.parse_archive resolves versioned provides.""" self.addSource("bionic", "main", "hello", "1.0-1", ["hello", "hello-dependency", "hello-bad"], fields={"Maintainer": "Test Person <*****@*****.**>"}) self.addPackage("bionic", "main", "i386", "hello", "1.0-1", fields={ "Maintainer": "Test Person <*****@*****.**>", "Depends": "hello-virtual (>= 2.0)", }) self.addPackage("bionic", "main", "i386", "hello-bad", "2.0-1", fields={ "Source": "hello (= 1.0-1)", "Provides": "hello-virtual (= 1.0)" }) self.addPackage("bionic", "main", "i386", "hello-dependency", "1.0-1", fields={ "Source": "hello", "Provides": "hello-virtual (= 2.0)" }) branch = "ubuntu.bionic" self.addSeed(branch, "supported") self.addSeedPackage(branch, "supported", "hello") germinator = Germinator("i386") archive = TagFile("bionic", "main", "i386", "file://%s" % self.archive_dir) germinator.parse_archive(archive) self.assertIn("hello", germinator._sources) self.assertIn("hello", germinator._packages) self.assertEqual("deb", germinator._packagetype["hello"]) self.assertIn("hello-dependency", germinator._packages) self.assertEqual("deb", germinator._packagetype["hello-dependency"]) self.assertIn("hello-bad", germinator._packages) self.assertEqual("deb", germinator._packagetype["hello-bad"]) self.assertEqual( {"hello-virtual": { "hello-bad": "1.0", "hello-dependency": "2.0" }}, germinator._provides) structure = self.openSeedStructure(branch) germinator.plant_seeds(structure) germinator.grow(structure) expected = set(["hello-dependency"]) self.assertEqual(expected, germinator.get_depends(structure, "supported"))