Exemplo n.º 1
0
class TestTree(TestCase):
    def setUp(self):
        super(TestTree, self).setUp()
        self.use_temp_dir()
        self.config = Config(read=False)
        self.tree = Tree(self.config, self.temp_dir)

    def test_path_to_project(self):
        self.assertEqual("kubuntu", self.tree.path_to_project("kubuntu/foo"))
        self.assertEqual("ubuntu", self.tree.path_to_project("foo"))
        self.assertEqual("ubuntu", self.tree.path_to_project("ubuntu/foo/bar"))

    def test_manifest_file_allowed_passes_good_extensions(self):
        paths = [
            os.path.join(self.temp_dir, name)
            for name in (
                "foo.iso", "foo.img", "foo.img.gz",
                "foo.tar.gz", "foo.tar.xz",
                )]
        for path in paths:
            touch(path)
            self.assertTrue(self.tree.manifest_file_allowed(path))

    def test_manifest_file_allowed_fails_bad_extensions(self):
        paths = [
            os.path.join(self.temp_dir, name)
            for name in ("foo.txt", "foo")]
        for path in paths:
            touch(path)
            self.assertFalse(self.tree.manifest_file_allowed(path))

    def test_manifest_file_allowed_fails_directories(self):
        path = os.path.join(self.temp_dir, "dir.iso")
        os.mkdir(path)
        self.assertFalse(self.tree.manifest_file_allowed(path))
Exemplo n.º 2
0
def tracker_set_rebuild_status(config, current_state, new_state, arches=None):

    if not isinstance(arches, list):
        arches = [arches]

    # Only import it here as we need to have the right paths in sys.path
    try:
        from isotracker import ISOTracker
    except ImportError:
        # Become a no-op if the isotracker module can't be found
        return

    if not arches:
        arches = config.arches

    tree = Tree.get_daily(config)
    publisher = Publisher.get_daily(tree, "daily")

    # Build a dict of tracker instance and product list
    qa_products = {}
    for arch in arches:
        qaproduct = publisher.qa_product(config.project, config.image_type,
                                         None, arch)

        if not qaproduct:
            continue

        if qaproduct[1] not in qa_products:
            qa_products[qaproduct[1]] = []

        qa_products[qaproduct[1]].append(qaproduct[0])

    # Iterate through the trackers and set the new status
    for instance, products in qa_products.items():
        try:
            tracker = ISOTracker(target="%s-%s" %
                                 (instance, config.full_series))
        except xmlrpclib.Error as e:
            logger.warning("Unable to contact tracker: %s" % e)
            continue

        for rebuild in tracker.qatracker.get_rebuilds(current_state):
            if rebuild.series_title.lower() != config.full_series:
                continue

            if rebuild.product_title in products:
                rebuild.status = new_state
                rebuild.save()
Exemplo n.º 3
0
def build_image_set_locked(config, options, multipidfile_state):
    image_type = config.image_type
    config["CDIMAGE_DATE"] = date = next_build_id(config, image_type)
    log_path = None

    try:
        configure_for_project(config)
        log_path = open_log(config)

        if want_live_builds(options):
            log_marker("Building live filesystems")
            live_successful = run_live_builds(config)
            config.limit_arches(live_successful)
        else:
            tracker_set_rebuild_status(config, [0, 1], 2)

        if not is_live_fs_only(config):
            sync_local_mirror(config, multipidfile_state)

            if config["LOCAL"]:
                log_marker("Updating archive of local packages")
                update_local_indices(config)

            build_britney(config)

            log_marker("Extracting debootstrap scripts")
            extract_debootstrap(config)

        if config["UBUNTU_DEFAULTS_LOCALE"]:
            build_ubuntu_defaults_locale(config)
        elif is_live_fs_only(config):
            build_livecd_base(config)
        else:
            if not config["CDIMAGE_PREINSTALLED"]:
                log_marker("Germinating")
                germination = Germination(config)
                germination.run()

                log_marker("Generating new task lists")
                germinate_output = germination.output(config.project)
                germinate_output.write_tasks()

                log_marker("Checking for other task changes")
                germinate_output.update_tasks(date)

            if (config["CDIMAGE_LIVE"] or config["CDIMAGE_SQUASHFS_BASE"] or
                    config["CDIMAGE_PREINSTALLED"]):
                log_marker("Downloading live filesystem images")
                download_live_filesystems(config)

            configure_splash(config)

            run_debian_cd(config)
            fix_permissions(config)

        # Temporarily turned off for live builds.
        if (config["CDIMAGE_INSTALL_BASE"] and
                not config["CDIMAGE_ADDON"] and
                not config["CDIMAGE_PREINSTALLED"]):
            log_marker("Producing installability report")
            check_installable(config)

        if not config["DEBUG"] and not config["CDIMAGE_NOPUBLISH"]:
            log_marker("Publishing")
            tree = Tree.get_daily(config)
            publisher = Publisher.get_daily(tree, image_type)
            publisher.publish(date)

            log_marker("Purging old images")
            publisher.purge()

            log_marker("Triggering mirrors")
            trigger_mirrors(config)

        log_marker("Finished")
        return True
    except Exception as e:
        for line in traceback.format_exc().splitlines():
            logger.error(line)
        sys.stdout.flush()
        sys.stderr.flush()
        if not isinstance(e, LiveBuildsFailed):
            notify_failure(config, log_path)
        return False
Exemplo n.º 4
0
 def setUp(self):
     super(TestTree, self).setUp()
     self.use_temp_dir()
     self.config = Config(read=False)
     self.tree = Tree(self.config, self.temp_dir)