Esempio n. 1
0
    def testRootCreation(self):
        """`RepositoryIndexFile` creates given 'root' path if necessary."""
        missing_root = os.path.join(self.root, 'donotexist')
        repo_file = RepositoryIndexFile(os.path.join(missing_root, 'boing'),
                                        self.temp_root)

        self.assertFalse(os.path.exists(missing_root))

        repo_file.close()

        self.assertEqual(['boing', 'boing.bz2', 'boing.gz'],
                         sorted(os.listdir(missing_root)))
    def testRootCreation(self):
        """`RepositoryIndexFile` creates given 'root' path if necessary."""
        missing_root = os.path.join(self.root, 'donotexist')
        repo_file = RepositoryIndexFile(
            os.path.join(missing_root, 'boing'), self.temp_root)

        self.assertFalse(os.path.exists(missing_root))

        repo_file.close()

        self.assertEqual(
            ['boing', 'boing.bz2', 'boing.gz'],
            sorted(os.listdir(missing_root)))
Esempio n. 3
0
    def _writeComponentIndexes(self, distroseries, pocket, component):
        """Write Index files for single distroseries + pocket + component.

        Iterates over all supported architectures and 'sources', no
        support for installer-* yet.
        Write contents using LP info to an extra plain file (Packages.lp
        and Sources.lp .
        """
        suite_name = distroseries.getSuite(pocket)
        self.log.debug("Generate Indexes for %s/%s"
                       % (suite_name, component.name))

        self.log.debug("Generating Sources")

        source_index = RepositoryIndexFile(
            get_sources_path(self._config, suite_name, component),
            self._config.temproot)

        for spp in distroseries.getSourcePackagePublishing(
                pocket, component, self.archive):
            stanza = spp.getIndexStanza().encode('utf8') + '\n\n'
            source_index.write(stanza)

        source_index.close()

        for arch in distroseries.architectures:
            if not arch.enabled:
                continue

            arch_path = 'binary-%s' % arch.architecturetag

            self.log.debug("Generating Packages for %s" % arch_path)

            indices = {}
            indices[None] = RepositoryIndexFile(
                get_packages_path(self._config, suite_name, component, arch),
                self._config.temproot)

            for subcomp in self.subcomponents:
                indices[subcomp] = RepositoryIndexFile(
                    get_packages_path(
                        self._config, suite_name, component, arch, subcomp),
                    self._config.temproot)

            for bpp in distroseries.getBinaryPackagePublishing(
                    arch.architecturetag, pocket, component, self.archive):
                subcomp = FORMAT_TO_SUBCOMPONENT.get(
                    bpp.binarypackagerelease.binpackageformat)
                if subcomp not in indices:
                    # Skip anything that we're not generating indices
                    # for, eg. ddebs where publish_debug_symbols is
                    # disabled.
                    continue
                stanza = bpp.getIndexStanza().encode('utf-8') + '\n\n'
                indices[subcomp].write(stanza)

            for index in indices.itervalues():
                index.close()
Esempio n. 4
0
    def getRepoFile(self, filename):
        """Return a `RepositoryIndexFile` for the given filename.

        The `RepositoryIndexFile` is created with the test 'root' and
        'temp_root'.
        """
        return RepositoryIndexFile(os.path.join(self.root, filename),
                                   self.temp_root)
    def getRepoFile(self, filename, compressors=None):
        """Return a `RepositoryIndexFile` for the given filename.

        The `RepositoryIndexFile` is created with the test 'root' and
        'temp_root'.
        """
        if compressors is None:
            compressors = [
                IndexCompressionType.GZIP,
                IndexCompressionType.BZIP2,
                IndexCompressionType.XZ,
            ]
        return RepositoryIndexFile(os.path.join(self.root, filename),
                                   self.temp_root, compressors)
    def makeIndexFiles(self, script, distroseries):
        """Create a limited subset of index files for testing."""
        ensure_directory_exists(script.config.temproot)

        for component in distroseries.components:
            source_index = RepositoryIndexFile(
                get_sources_path(script.config, distroseries.name, component),
                script.config.temproot)
            for spp in distroseries.getSourcePackagePublishing(
                    PackagePublishingPocket.RELEASE, component,
                    distroseries.main_archive):
                stanza = spp.getIndexStanza().encode("utf-8") + "\n\n"
                source_index.write(stanza)
            source_index.close()

            for arch in distroseries.architectures:
                package_index = RepositoryIndexFile(
                    get_packages_path(
                        script.config, distroseries.name, component, arch),
                    script.config.temproot)
                for bpp in distroseries.getBinaryPackagePublishing(
                        arch.architecturetag, PackagePublishingPocket.RELEASE,
                        component, distroseries.main_archive):
                    stanza = bpp.getIndexStanza().encode("utf-8") + "\n\n"
                    package_index.write(stanza)
                package_index.close()