def C_doFTPArchive(self, is_careful):
     """Does the ftp-archive step: generates Sources and Packages."""
     self.log.debug("* Step C: Set apt-ftparchive up and run it")
     apt_handler = FTPArchiveHandler(self.log, self._config,
                                     self._diskpool, self.distro,
                                     self)
     apt_handler.run(is_careful)
Beispiel #2
0
    def test_generateConfig(self):
        # Generate apt-ftparchive configuration file and run it.

        # Setup FTPArchiveHandler with a real Publisher for Ubuntutest.
        publisher = Publisher(self._logger, self._config, self._dp,
                              self._archive)
        fa = FTPArchiveHandler(self._logger, self._config, self._dp,
                               self._distribution, publisher)
        fa.createEmptyPocketRequests(fullpublish=True)

        # Calculate overrides and filelists.
        self._publishDefaultOverrides(fa, 'main')
        self._publishDefaultFileLists(fa, 'main')

        # Add mentioned files in the repository pool/.
        self._addRepositoryFile('main', 'tiny', 'tiny_0.1.dsc')
        self._addRepositoryFile('main', 'tiny', 'tiny_0.1.tar.gz')
        self._addRepositoryFile('main', 'tiny', 'tiny_0.1_i386.deb')

        # When include_long_descriptions is set, apt.conf has
        # LongDescription "true" for that series.
        hoary_test = self._distribution.getSeries('hoary-test')
        self.assertTrue(hoary_test.include_long_descriptions)
        breezy_autotest = self._distribution.getSeries('breezy-autotest')
        breezy_autotest.include_long_descriptions = False

        # XXX cprov 2007-03-21: Relying on byte-to-byte configuration file
        # comparing is weak. We should improve this methodology to avoid
        # wasting time on test failures due to irrelevant format changes.
        apt_conf = fa.generateConfig(fullpublish=True)
        self._verifyFile("apt.conf", self._confdir)

        # XXX cprov 2007-03-21: This is an extra problem. Running a-f on
        # developer machines is wasteful. We need to find a away to split
        # those kind of tests and avoid to run it when performing 'make
        # check'. Although they should remain active in PQM to avoid possible
        # regressions.
        fa.runApt(apt_conf)
        self._verifyFile(
            "Packages",
            os.path.join(self._distsdir, "hoary-test", "main", "binary-i386"),
            skip_sha512)
        self._verifyEmpty(
            os.path.join(self._distsdir, "hoary-test", "main",
                         "debian-installer", "binary-i386", "Packages"))
        self._verifyFile(
            "Sources",
            os.path.join(self._distsdir, "hoary-test", "main", "source"),
            sanitize_apt_ftparchive_Sources_output)

        # XXX cprov 2007-03-21: see above, byte-to-byte configuration
        # comparing is weak.
        # Test that a publisher run now will generate an empty apt
        # config and nothing else.
        apt_conf = fa.generateConfig()
        assert len(file(apt_conf).readlines()) == 24

        # XXX cprov 2007-03-21: see above, do not run a-f on dev machines.
        fa.runApt(apt_conf)
    def test_generateConfig(self):
        # Generate apt-ftparchive configuration file and run it.

        # Setup FTPArchiveHandler with a real Publisher for Ubuntutest.
        publisher = Publisher(
            self._logger, self._config, self._dp, self._archive)
        fa = FTPArchiveHandler(self._logger, self._config, self._dp,
                               self._distribution, publisher)
        fa.createEmptyPocketRequests(fullpublish=True)

        # Calculate overrides and filelists.
        self._publishDefaultOverrides(fa, 'main')
        self._publishDefaultFileLists(fa, 'main')

        # Add mentioned files in the repository pool/.
        self._addRepositoryFile('main', 'tiny', 'tiny_0.1.dsc')
        self._addRepositoryFile('main', 'tiny', 'tiny_0.1.tar.gz')
        self._addRepositoryFile('main', 'tiny', 'tiny_0.1_i386.deb')

        # When include_long_descriptions is set, apt.conf has
        # LongDescription "true" for that series.
        hoary_test = self._distribution.getSeries('hoary-test')
        self.assertTrue(hoary_test.include_long_descriptions)
        breezy_autotest = self._distribution.getSeries('breezy-autotest')
        breezy_autotest.include_long_descriptions = False

        # XXX cprov 2007-03-21: Relying on byte-to-byte configuration file
        # comparing is weak. We should improve this methodology to avoid
        # wasting time on test failures due to irrelevant format changes.
        apt_conf = fa.generateConfig(fullpublish=True)
        self._verifyFile("apt.conf", self._confdir)

        # XXX cprov 2007-03-21: This is an extra problem. Running a-f on
        # developer machines is wasteful. We need to find a away to split
        # those kind of tests and avoid to run it when performing 'make
        # check'. Although they should remain active in PQM to avoid possible
        # regressions.
        fa.runApt(apt_conf)
        self._verifyFile("Packages",
            os.path.join(self._distsdir, "hoary-test", "main", "binary-i386"),
            skip_sha512)
        self._verifyEmpty(
            os.path.join(
                self._distsdir, "hoary-test", "main", "debian-installer",
                "binary-i386", "Packages"))
        self._verifyFile("Sources",
            os.path.join(self._distsdir, "hoary-test", "main", "source"),
            sanitize_apt_ftparchive_Sources_output)

        # XXX cprov 2007-03-21: see above, byte-to-byte configuration
        # comparing is weak.
        # Test that a publisher run now will generate an empty apt
        # config and nothing else.
        apt_conf = fa.generateConfig()
        assert len(file(apt_conf).readlines()) == 24

        # XXX cprov 2007-03-21: see above, do not run a-f on dev machines.
        fa.runApt(apt_conf)
Beispiel #4
0
 def test_runApt_reports_failure(self):
     # If we sabotage apt-ftparchive, runApt notices that it failed
     # and raises an exception.
     distroarchseries = self.factory.makeDistroArchSeries()
     distro = distroarchseries.distroseries.distribution
     fa = FTPArchiveHandler(DevNullLogger(), None, None, distro, None)
     self.assertRaises(AptFTPArchiveFailure, fa.runApt, "bogus-config")
Beispiel #5
0
    def test_generateConfig_index_compressors_changed(self):
        # If index_compressors changes between runs, then old compressed
        # files are removed.
        publisher = Publisher(self._logger, self._config, self._dp,
                              self._archive)
        fa = FTPArchiveHandler(self._logger, self._config, self._dp,
                               self._distribution, publisher)
        fa.createEmptyPocketRequests(fullpublish=True)
        self._publishDefaultOverrides(fa, "main")
        self._publishDefaultFileLists(fa, "main")
        self._addRepositoryFile("main", "tiny", "tiny_0.1.dsc")
        self._addRepositoryFile("main", "tiny", "tiny_0.1.tar.gz")
        self._addRepositoryFile("main", "tiny", "tiny_0.1_i386.deb")
        comp_dir = os.path.join(self._distsdir, "hoary-test", "main")
        os.makedirs(os.path.join(comp_dir, "signed"))
        with open(os.path.join(comp_dir, "signed", "stuff"), "w"):
            pass
        os.symlink("signed", os.path.join(comp_dir, "uefi"))
        os.makedirs(os.path.join(comp_dir, "i18n"))
        for name in ("Translation-de", "Translation-de.gz", "Translation-en",
                     "Translation-en.Z"):
            with open(os.path.join(comp_dir, "i18n", name), "w"):
                pass
        self._distribution["hoary-test"].include_long_descriptions = False

        # Run the publisher once with gzip and bzip2 compressors.
        apt_conf = fa.generateConfig(fullpublish=True)
        with open(apt_conf) as apt_conf_file:
            self.assertIn('Packages::Compress "gzip bzip2";',
                          apt_conf_file.read())
        fa.runApt(apt_conf)
        self.assertContentEqual(["Packages.gz", "Packages.bz2"],
                                os.listdir(
                                    os.path.join(comp_dir, "binary-i386")))
        self.assertContentEqual(["Packages.gz", "Packages.bz2"],
                                os.listdir(
                                    os.path.join(comp_dir, "debian-installer",
                                                 "binary-i386")))
        self.assertContentEqual(["Sources.gz", "Sources.bz2"],
                                os.listdir(os.path.join(comp_dir, "source")))
        self.assertContentEqual([
            "Translation-de", "Translation-de.gz", "Translation-en.gz",
            "Translation-en.bz2"
        ], os.listdir(os.path.join(comp_dir, "i18n")))

        # Try again, this time with gzip and xz compressors.  There are no
        # bzip2 leftovers, but other files are left untouched.
        self._distribution["hoary-test"].index_compressors = [
            IndexCompressionType.GZIP, IndexCompressionType.XZ
        ]
        apt_conf = fa.generateConfig(fullpublish=True)
        with open(apt_conf) as apt_conf_file:
            self.assertIn('Packages::Compress "gzip xz";',
                          apt_conf_file.read())
        fa.runApt(apt_conf)
        self.assertContentEqual(["Packages.gz", "Packages.xz"],
                                os.listdir(
                                    os.path.join(comp_dir, "binary-i386")))
        self.assertContentEqual(["Packages.gz", "Packages.xz"],
                                os.listdir(
                                    os.path.join(comp_dir, "debian-installer",
                                                 "binary-i386")))
        self.assertContentEqual(["Sources.gz", "Sources.xz"],
                                os.listdir(os.path.join(comp_dir, "source")))
        self.assertEqual(["stuff"],
                         os.listdir(os.path.join(comp_dir, "signed")))
        self.assertEqual(["stuff"], os.listdir(os.path.join(comp_dir, "uefi")))
        self.assertContentEqual([
            "Translation-de", "Translation-de.gz", "Translation-en.gz",
            "Translation-en.xz"
        ], os.listdir(os.path.join(comp_dir, "i18n")))
Beispiel #6
0
    def test_generateConfig_empty_and_careful(self):
        # Generate apt-ftparchive config for an specific empty suite.
        #
        # By passing 'careful_apt' option associated with 'allowed_suite'
        # we can publish only a specific group of the suites even if they
        # are still empty. It makes APT clients happier during development
        # cycle.
        #
        # This test should check:
        #
        #  * if apt.conf was generated correctly.
        #  * a-f runs based on this config without any errors
        #  * a-f *only* creates the wanted archive indexes.
        allowed_suites = set()
        allowed_suites.add(('hoary-test', PackagePublishingPocket.UPDATES))

        publisher = Publisher(self._logger,
                              self._config,
                              self._dp,
                              allowed_suites=allowed_suites,
                              archive=self._archive)

        fa = FTPArchiveHandler(self._logger, self._config, self._dp,
                               self._distribution, publisher)

        fa.createEmptyPocketRequests(fullpublish=True)

        # createEmptyPocketRequests creates empty override and file
        # listings.
        lists = (
            'hoary-test-updates_main_source',
            'hoary-test-updates_main_binary-i386',
            'hoary-test-updates_main_debian-installer_binary-i386',
            'override.hoary-test-updates.main',
            'override.hoary-test-updates.extra.main',
            'override.hoary-test-updates.main.src',
        )

        for listname in lists:
            path = os.path.join(self._config.overrideroot, listname)
            self._verifyEmpty(path)

        # XXX cprov 2007-03-21: see above, byte-to-byte configuration
        # comparing is weak.
        apt_conf = fa.generateConfig(fullpublish=True)
        self.assertTrue(os.path.exists(apt_conf))
        apt_conf_content = file(apt_conf).read()
        sample_content = file(
            os.path.join(self._sampledir,
                         'apt_conf_single_empty_suite_test')).read()
        self.assertEqual(apt_conf_content, sample_content)

        # XXX cprov 2007-03-21: see above, do not run a-f on dev machines.
        fa.runApt(apt_conf)
        self.assertTrue(
            os.path.exists(
                os.path.join(self._distsdir, "hoary-test-updates", "main",
                             "binary-i386", "Packages.gz")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self._distsdir, "hoary-test-updates", "main",
                             "debian-installer", "binary-i386",
                             "Packages.gz")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self._distsdir, "hoary-test-updates", "main",
                             "source", "Sources.gz")))

        self.assertFalse(
            os.path.exists(
                os.path.join(self._distsdir, "hoary-test", "main",
                             "binary-i386", "Packages.gz")))
        self.assertFalse(
            os.path.exists(
                os.path.join(self._distsdir, "hoary-test", "main",
                             "debian-installer", "binary-i386",
                             "Packages.gz")))
        self.assertFalse(
            os.path.exists(
                os.path.join(self._distsdir, "hoary-test", "main", "source",
                             "Sources.gz")))
Beispiel #7
0
 def _setUpFTPArchiveHandler(self):
     return FTPArchiveHandler(self._logger, self._config, self._dp,
                              self._distribution, self._publisher)
    def test_generateConfig_empty_and_careful(self):
        # Generate apt-ftparchive config for an specific empty suite.
        #
        # By passing 'careful_apt' option associated with 'allowed_suite'
        # we can publish only a specific group of the suites even if they
        # are still empty. It makes APT clients happier during development
        # cycle.
        #
        # This test should check:
        #
        #  * if apt.conf was generated correctly.
        #  * a-f runs based on this config without any errors
        #  * a-f *only* creates the wanted archive indexes.
        allowed_suites = set()
        allowed_suites.add(('hoary-test', PackagePublishingPocket.UPDATES))

        publisher = Publisher(
            self._logger, self._config, self._dp,
            allowed_suites=allowed_suites, archive=self._archive)

        fa = FTPArchiveHandler(self._logger, self._config, self._dp,
                               self._distribution, publisher)

        fa.createEmptyPocketRequests(fullpublish=True)

        # createEmptyPocketRequests creates empty override and file
        # listings.
        lists = (
            'hoary-test-updates_main_source',
            'hoary-test-updates_main_binary-i386',
            'hoary-test-updates_main_debian-installer_binary-i386',
            'override.hoary-test-updates.main',
            'override.hoary-test-updates.extra.main',
            'override.hoary-test-updates.main.src',
            )

        for listname in lists:
            path = os.path.join(self._config.overrideroot, listname)
            self._verifyEmpty(path)

        # XXX cprov 2007-03-21: see above, byte-to-byte configuration
        # comparing is weak.
        apt_conf = fa.generateConfig(fullpublish=True)
        self.assertTrue(os.path.exists(apt_conf))
        apt_conf_content = file(apt_conf).read()
        sample_content = file(
            os.path.join(
            self._sampledir, 'apt_conf_single_empty_suite_test')).read()
        self.assertEqual(apt_conf_content, sample_content)

        # XXX cprov 2007-03-21: see above, do not run a-f on dev machines.
        fa.runApt(apt_conf)
        self.assertTrue(os.path.exists(
            os.path.join(self._distsdir, "hoary-test-updates", "main",
                         "binary-i386", "Packages")))
        self.assertTrue(os.path.exists(
            os.path.join(self._distsdir, "hoary-test-updates", "main",
                         "debian-installer", "binary-i386", "Packages")))
        self.assertTrue(os.path.exists(
            os.path.join(self._distsdir, "hoary-test-updates", "main",
                         "source", "Sources")))

        self.assertFalse(os.path.exists(
            os.path.join(self._distsdir, "hoary-test", "main",
                         "binary-i386", "Packages")))
        self.assertFalse(os.path.exists(
            os.path.join(self._distsdir, "hoary-test", "main",
                         "debian-installer", "binary-i386", "Packages")))
        self.assertFalse(os.path.exists(
            os.path.join(self._distsdir, "hoary-test", "main",
                         "source", "Sources")))