Exemple #1
0
 def test_open_without_scheme(self):
     """A Seed can be opened from a relative path on the filesystem."""
     seed = Seed([self.seeds_dir], ["collection.dist"], "test")
     with seed as seed_file:
         lines = list(seed_file)
         self.assertTrue(1, len(lines))
         self.assertTrue(" * foo\n", lines[0])
Exemple #2
0
 def test_behaves_as_file(self):
     """A Seed context can be read from as a file object."""
     seed = Seed(["file://%s" % self.seeds_dir], ["collection.dist"],
                 "test")
     with seed as seed_file:
         lines = list(seed_file)
         self.assertTrue(1, len(lines))
         self.assertTrue(" * foo\n", lines[0])
Exemple #3
0
 def test_init_no_vcs_snap(self):
     """__init__ can open a seed from a collection without a VCS."""
     seed = Seed(["file://%s" % self.seeds_dir], ["collection.dist"],
                 "test3")
     self.assertEqual("test3", seed.name)
     self.assertEqual("file://%s" % self.seeds_dir, seed.base)
     self.assertEqual("collection.dist", seed.branch)
     self.assertEqual(" * bar\n * snap:quux\n", seed.text)
Exemple #4
0
 def test_feature(self):
     """SingleSeedStructure parses the "feature" directive correctly."""
     branch = "collection.dist"
     self.addStructureLine(branch, "feature follow-recommends")
     seed = Seed(["file://%s" % self.seeds_dir], branch, "STRUCTURE")
     with seed as seed_file:
         structure = SingleSeedStructure(branch, seed_file)
     self.assertEqual(set(["follow-recommends"]), structure.features)
Exemple #5
0
 def test_include(self):
     """SingleSeedStructure parses the "include" directive correctly."""
     branch = "collection.dist"
     self.addStructureLine(branch, "include other.dist")
     seed = Seed(["file://%s" % self.seeds_dir], branch, "STRUCTURE")
     with seed as seed_file:
         structure = SingleSeedStructure(branch, seed_file)
     self.assertEqual([branch, "other.dist"], structure.branches)
Exemple #6
0
 def test_basic(self):
     """A SingleSeedStructure object has the correct basic properties."""
     branch = "collection.dist"
     self.addSeed(branch, "base")
     self.addSeed(branch, "desktop", parents=["base"])
     seed = Seed(["file://%s" % self.seeds_dir], branch, "STRUCTURE")
     with seed as seed_file:
         structure = SingleSeedStructure(branch, seed_file)
     self.assertEqual(["base", "desktop"], structure.seed_order)
     self.assertEqual({"base": [], "desktop": ["base"]}, structure.inherit)
     self.assertEqual([branch], structure.branches)
     self.assertEqual(["base:", "desktop: base"], structure.lines)
     self.assertEqual(set(), structure.features)
Exemple #7
0
 def test_not_equal_if_different_contents(self):
     """Two Seed objects with different text contents are not equal."""
     one = Seed(["file://%s" % self.seeds_dir], ["collection.dist"], "test")
     three = Seed(["file://%s" % self.seeds_dir], ["collection.dist"],
                  "test3")
     self.assertNotEqual(one, three)
Exemple #8
0
 def test_equal_if_same_contents(self):
     """Two Seed objects with the same text contents are equal."""
     one = Seed(["file://%s" % self.seeds_dir], ["collection.dist"], "test")
     two = Seed(["file://%s" % self.seeds_dir], ["collection.dist"],
                "test2")
     self.assertEqual(one, two)
Exemple #9
0
def main(argv):
    options = parse_options(argv)

    if options.verbose:
        germinate_logging(logging.DEBUG)
    else:
        germinate_logging(logging.INFO)

    g = Germinator(options.arch)
    g._always_follow_build_depends = options.always_follow_build_depends

    archive = germinate.archive.TagFile(options.dist,
                                        options.components,
                                        options.arch,
                                        options.mirrors,
                                        source_mirrors=options.source_mirrors,
                                        installer_packages=options.installer,
                                        cleanup=options.cleanup)
    g.parse_archive(archive)

    if os.path.isfile("hints"):
        with open("hints") as hints:
            g.parse_hints(hints)

    try:
        structure = SeedStructure(options.release, options.seeds, options.vcs)
        for seed_package in options.seed_packages:
            parent, pkg = seed_package.split('/')
            structure.add(pkg, [" * " + pkg], parent)
        g.plant_seeds(structure)
    except SeedError:
        sys.exit(1)

    try:
        with Seed(options.seeds, options.release, "blacklist",
                  options.vcs) as blacklist:
            g.parse_blacklist(structure, blacklist)
    except SeedError:
        pass

    g.grow(structure)
    g.add_extras(structure)
    if options.want_rdepends:
        g.reverse_depends(structure)

    for seedname in structure.names + ["extra"]:
        g.write_full_list(structure, seedname, seedname)
        g.write_seed_list(structure, seedname + ".seed", seedname)
        g.write_seed_recommends_list(structure, seedname + ".seed-recommends",
                                     seedname)
        g.write_depends_list(structure, seedname + ".depends", seedname)
        g.write_build_depends_list(structure, seedname + ".build-depends",
                                   seedname)
        g.write_snap_list(structure, seedname + ".snaps", seedname)

        if seedname != "extra" and seedname in structure:
            structure.write_seed_text(seedname + ".seedtext", seedname)
            g.write_sources_list(structure, seedname + ".sources", seedname)
        g.write_build_sources_list(structure, seedname + ".build-sources",
                                   seedname)

    g.write_all_list(structure, "all")
    g.write_all_source_list(structure, "all.sources")
    g.write_all_snap_list(structure, "all.snaps")

    g.write_supported_list(structure, "%s+build-depends" % structure.supported)
    g.write_supported_source_list(
        structure, "%s+build-depends.sources" % structure.supported)

    g.write_all_extra_list(structure, "all+extra")
    g.write_all_extra_source_list(structure, "all+extra.sources")

    g.write_provides_list(structure, "provides")

    structure.write("structure")
    structure.write_dot("structure.dot")

    if os.path.exists("rdepends"):
        shutil.rmtree("rdepends")
    if options.want_rdepends:
        os.mkdir("rdepends")
        os.mkdir(os.path.join("rdepends", "ALL"))
        for pkg in g.get_all(structure):
            dirname = os.path.join("rdepends", g.get_source(pkg))
            if not os.path.exists(dirname):
                os.mkdir(dirname)

            g.write_rdepend_list(structure, os.path.join(dirname, pkg), pkg)
            os.symlink(os.path.join("..", g.get_source(pkg), pkg),
                       os.path.join("rdepends", "ALL", pkg))

    g.write_blacklisted(structure, "blacklisted")

    return 0