Ejemplo n.º 1
0
    def test_sections_bzip2(self):
        """Test fetching sections from a basic TagFile archive using bzip2."""
        self.useTempDir()
        main_dir = os.path.join("mirror", "dists", "unstable", "main")
        binary_dir = os.path.join(main_dir, "binary-i386")
        source_dir = os.path.join(main_dir, "source")
        os.makedirs(binary_dir)
        os.makedirs(source_dir)
        with bz2.BZ2File(
                os.path.join(binary_dir, "Packages.bz2"), "wb") as packages:
            packages.write(textwrap.dedent(b"""\
                Package: test
                Version: 1.0
                Architecture: i386
                Maintainer: \xc3\xba\xe1\xb8\x83\xc3\xba\xc3\xb1\xc5\xa7\xc5\xaf\x20\xc4\x91\xc9\x99\x76\xe1\xba\xbd\xc5\x82\xc3\xb5\xe1\xb9\x97\xc3\xa8\xc5\x97\xe1\xb9\xa1

                """.decode("UTF-8")).encode("UTF-8"))
        with bz2.BZ2File(
                os.path.join(source_dir, "Sources.bz2"), "wb") as sources:
            sources.write(textwrap.dedent("""\
                Source: test
                Version: 1.0

                """).encode("UTF-8"))

        tagfile = TagFile(
            "unstable", "main", "i386", "file://%s/mirror" % self.temp_dir)
        sections = list(tagfile.sections())
        self.assertEqual(IndexType.PACKAGES, sections[0][0])
        self.assertEqual("test", sections[0][1]["Package"])
        self.assertEqual("1.0", sections[0][1]["Version"])
        self.assertEqual("i386", sections[0][1]["Architecture"])
        self.assertEqual(IndexType.SOURCES, sections[1][0])
        self.assertEqual("test", sections[1][1]["Source"])
        self.assertEqual("1.0", sections[1][1]["Version"])
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 def test_init_lists(self):
     """TagFile may be constructed with list parameters."""
     tagfile = TagFile(["dist"], ["component"],
                       "arch", ["mirror"],
                       source_mirrors=["source_mirror"])
     self.assertEqual(["dist"], tagfile._dists)
     self.assertEqual(["component"], tagfile._components)
     self.assertEqual(["mirror"], tagfile._mirrors)
     self.assertEqual(["source_mirror"], tagfile._source_mirrors)
Ejemplo n.º 4
0
 def test_init_strings(self):
     """TagFile may be constructed with string parameters."""
     tagfile = TagFile("dist",
                       "component",
                       "arch",
                       "mirror",
                       source_mirrors="source_mirror")
     self.assertEqual(["dist"], tagfile._dists)
     self.assertEqual(["component"], tagfile._components)
     self.assertEqual(["mirror"], tagfile._mirrors)
     self.assertEqual(["source_mirror"], tagfile._source_mirrors)
Ejemplo n.º 5
0
    def test_sections(self):
        """Test fetching sections from a basic TagFile archive."""
        self.useTempDir()
        main_dir = os.path.join("mirror", "dists", "unstable", "main")
        binary_dir = os.path.join(main_dir, "binary-i386")
        source_dir = os.path.join(main_dir, "source")
        os.makedirs(binary_dir)
        os.makedirs(source_dir)
        packages = gzip.GzipFile(os.path.join(binary_dir, "Packages.gz"), "w")
        try:
            packages.write(textwrap.dedent("""\
                Package: test
                Version: 1.0
                Architecture: i386

                """).encode("UTF-8"))
        finally:
            packages.close()
        sources = gzip.GzipFile(os.path.join(source_dir, "Sources.gz"), "w")
        try:
            sources.write(textwrap.dedent("""\
                Source: test
                Version: 1.0

                """).encode("UTF-8"))
        finally:
            sources.close()

        tagfile = TagFile(
            "unstable", "main", "i386", "file://%s/mirror" % self.temp_dir)
        sections = list(tagfile.sections())
        self.assertEqual(IndexType.PACKAGES, sections[0][0])
        self.assertEqual("test", sections[0][1]["Package"])
        self.assertEqual("1.0", sections[0][1]["Version"])
        self.assertEqual("i386", sections[0][1]["Architecture"])
        self.assertEqual(IndexType.SOURCES, sections[1][0])
        self.assertEqual("test", sections[1][1]["Source"])
        self.assertEqual("1.0", sections[1][1]["Version"])
Ejemplo n.º 6
0
    def test_sections_bzip2(self):
        """Test fetching sections from a basic TagFile archive using bzip2."""
        self.useTempDir()
        main_dir = os.path.join("mirror", "dists", "unstable", "main")
        binary_dir = os.path.join(main_dir, "binary-i386")
        source_dir = os.path.join(main_dir, "source")
        os.makedirs(binary_dir)
        os.makedirs(source_dir)
        with bz2.BZ2File(os.path.join(binary_dir, "Packages.bz2"),
                         "wb") as packages:
            packages.write(
                textwrap.dedent(b"""\
                Package: test
                Version: 1.0
                Architecture: i386
                Maintainer: \xc3\xba\xe1\xb8\x83\xc3\xba\xc3\xb1\xc5\xa7\xc5\xaf\x20\xc4\x91\xc9\x99\x76\xe1\xba\xbd\xc5\x82\xc3\xb5\xe1\xb9\x97\xc3\xa8\xc5\x97\xe1\xb9\xa1

                """.decode("UTF-8")).encode("UTF-8"))
        with bz2.BZ2File(os.path.join(source_dir, "Sources.bz2"),
                         "wb") as sources:
            sources.write(
                textwrap.dedent("""\
                Source: test
                Version: 1.0

                """).encode("UTF-8"))

        tagfile = TagFile("unstable", "main", "i386",
                          "file://%s/mirror" % self.temp_dir)
        sections = list(tagfile.sections())
        self.assertEqual(IndexType.PACKAGES, sections[0][0])
        self.assertEqual("test", sections[0][1]["Package"])
        self.assertEqual("1.0", sections[0][1]["Version"])
        self.assertEqual("i386", sections[0][1]["Architecture"])
        self.assertEqual(IndexType.SOURCES, sections[1][0])
        self.assertEqual("test", sections[1][1]["Source"])
        self.assertEqual("1.0", sections[1][1]["Version"])
Ejemplo n.º 7
0
    def test_sections_gzip(self):
        """Test fetching sections from a basic TagFile archive using gzip."""
        self.useTempDir()
        main_dir = os.path.join("mirror", "dists", "unstable", "main")
        binary_dir = os.path.join(main_dir, "binary-i386")
        source_dir = os.path.join(main_dir, "source")
        os.makedirs(binary_dir)
        os.makedirs(source_dir)
        with gzip.GzipFile(os.path.join(binary_dir, "Packages.gz"),
                           "wb") as packages:
            packages.write(
                textwrap.dedent(u"""\
                Package: test
                Version: 1.0
                Architecture: i386
                Maintainer: úḃúñŧů đəvẽłõṗèŗṡ

                """).encode("UTF-8"))
        with gzip.GzipFile(os.path.join(source_dir, "Sources.gz"),
                           "wb") as sources:
            sources.write(
                textwrap.dedent("""\
                Source: test
                Version: 1.0

                """).encode("UTF-8"))

        tagfile = TagFile("unstable", "main", "i386",
                          "file://%s/mirror" % self.temp_dir)
        sections = list(tagfile.sections())
        self.assertEqual(IndexType.PACKAGES, sections[0][0])
        self.assertEqual("test", sections[0][1]["Package"])
        self.assertEqual("1.0", sections[0][1]["Version"])
        self.assertEqual("i386", sections[0][1]["Architecture"])
        self.assertEqual(IndexType.SOURCES, sections[1][0])
        self.assertEqual("test", sections[1][1]["Source"])
        self.assertEqual("1.0", sections[1][1]["Version"])
Ejemplo n.º 8
0
    def test_build_depends_profiles(self):
        """Test that https://wiki.debian.org/BuildProfileSpec restrictions
        are parseable.
        """
        self.addSource("precise",
                       "main",
                       "hello",
                       "1.0-1", ["hello"],
                       fields={
                           "Build-Depends":
                           "gettext <!stage1> <!cross>, "
                           "base-files <stage1>, "
                           "gettext (<< 0.7) | debhelper (>= 9)"
                       })
        self.addPackage("precise", "main", "i386", "hello", "1.0-1")
        self.addSource("precise", "main", "gettext", "0.8.1.1-5ubuntu3",
                       ["gettext"])
        self.addPackage("precise", "main", "i386", "gettext",
                        "0.8.1.1-5ubuntu3")
        self.addSource("precise", "main", "base-files", "6.5ubuntu6",
                       ["base-files"])
        self.addPackage("precise", "main", "i386", "base-files", "6.5ubuntu6")
        self.addSource("precise", "main", "debhelper", "9.20120115ubuntu3",
                       ["debhelper"])
        self.addPackage("precise", "main", "i386", "debhelper",
                        "9.20120115ubuntu3")
        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)

        self.assertEqual(set(["gettext", "debhelper"]),
                         germinator.get_build_depends(structure, "base"))
Ejemplo n.º 9
0
    def test_different_providers_between_suites(self):
        """Provides from later versions override those from earlier ones."""
        self.addSource("warty", "main", "hello", "1.0-1", ["hello"])
        self.addPackage("warty",
                        "main",
                        "i386",
                        "hello",
                        "1.0-1",
                        fields={"Provides": "goodbye"})
        self.addSource("warty-updates", "main", "hello", "1.0-1.1", ["hello"])
        self.addPackage("warty-updates",
                        "main",
                        "i386",
                        "hello",
                        "1.0-1.1",
                        fields={"Provides": "hello-goodbye"})
        germinator = Germinator("i386")
        archive = TagFile(["warty", "warty-updates"], "main", "i386",
                          "file://%s" % self.archive_dir)
        germinator.parse_archive(archive)

        self.assertNotIn("goodbye", germinator._provides)
        self.assertIn("hello-goodbye", germinator._provides)
        self.assertEqual({"hello": ""}, germinator._provides["hello-goodbye"])
Ejemplo n.º 10
0
    def germinateArch(self,
                      override_file,
                      series_name,
                      components,
                      arch,
                      flavours,
                      structures,
                      seed_outputs=None):
        """Germinate seeds on all flavours for a single architecture."""
        germinator = Germinator(arch)

        # Read archive metadata.
        archive = TagFile(series_name,
                          components,
                          arch,
                          "file://%s" % self.config.archiveroot,
                          cleanup=True)
        germinator.parse_archive(archive)

        for flavour in flavours:
            self.logger.info("Germinating for %s/%s/%s", flavour, series_name,
                             arch)
            # Add this to the germinate log as well so that that can be
            # debugged more easily.  Log a separator line first.
            self.logGerminateProgress("")
            self.logGerminateProgress("Germinating for %s/%s/%s", flavour,
                                      series_name, arch)

            self.germinateArchFlavour(override_file,
                                      germinator,
                                      series_name,
                                      arch,
                                      flavour,
                                      structures[flavour],
                                      flavour == flavours[0],
                                      seed_outputs=seed_outputs)
Ejemplo n.º 11
0
    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"))
Ejemplo n.º 12
0
    def test_parse_archive(self):
        """Germinator.parse_archive successfully parses a simple archive."""
        self.addSource("warty",
                       "main",
                       "hello",
                       "1.0-1", ["hello", "hello-dependency"],
                       fields={"Maintainer": "Test Person <*****@*****.**>"})
        self.addPackage("warty",
                        "main",
                        "i386",
                        "hello",
                        "1.0-1",
                        fields={
                            "Maintainer": "Test Person <*****@*****.**>",
                            "Depends": "hello-dependency",
                        })
        self.addPackage("warty",
                        "main",
                        "i386",
                        "hello-dependency",
                        "1.0-1",
                        fields={
                            "Source": "hello",
                            "Multi-Arch": "foreign"
                        })
        self.addSeed("ubuntu.warty", "supported")
        self.addSeedPackage("ubuntu.warty", "supported", "hello")
        germinator = Germinator("i386")
        archive = TagFile("warty", "main", "i386",
                          "file://%s" % self.archive_dir)
        germinator.parse_archive(archive)

        self.assertIn("hello", germinator._sources)
        self.assertEqual(
            {
                "Maintainer": u"Test Person <*****@*****.**>",
                "Version": "1.0-1",
                "Build-Depends": [],
                "Build-Depends-Indep": [],
                "Build-Depends-Arch": [],
                "Binaries": ["hello", "hello-dependency"],
            }, germinator._sources["hello"])
        self.assertIn("hello", germinator._packages)
        self.assertEqual(
            {
                "Section": "",
                "Version": "1.0-1",
                "Maintainer": u"Test Person <*****@*****.**>",
                "Essential": "",
                "Pre-Depends": [],
                "Built-Using": [],
                "Depends": [[("hello-dependency", "", "")]],
                "Recommends": [],
                "Size": 0,
                "Installed-Size": 0,
                "Source": "hello",
                "Provides": [],
                "Kernel-Version": "",
                "Multi-Arch": "none",
            }, germinator._packages["hello"])
        self.assertEqual("deb", germinator._packagetype["hello"])
        self.assertIn("hello-dependency", germinator._packages)
        self.assertEqual(
            {
                "Section": "",
                "Version": "1.0-1",
                "Maintainer": u"",
                "Essential": "",
                "Pre-Depends": [],
                "Built-Using": [],
                "Depends": [],
                "Recommends": [],
                "Size": 0,
                "Installed-Size": 0,
                "Source": "hello",
                "Provides": [],
                "Kernel-Version": "",
                "Multi-Arch": "foreign",
            }, germinator._packages["hello-dependency"])
        self.assertEqual("deb", germinator._packagetype["hello-dependency"])
        self.assertEqual({}, germinator._provides)