Пример #1
0
def build_ubuntu_defaults_locale(config):
    locale = config["UBUNTU_DEFAULTS_LOCALE"]
    if locale != "zh_CN":
        raise UnknownLocale(
            "UBUNTU_DEFAULTS_LOCALE='%s' not currently supported!" % locale)

    series = config["DIST"]
    log_marker("Downloading live filesystem images")
    download_live_filesystems(config)
    scratch = live_output_directory(config)
    for entry in os.listdir(scratch):
        if "." in entry:
            os.rename(os.path.join(scratch, entry),
                      os.path.join(scratch, "%s-desktop-%s" % (series, entry)))
    pi_makelist = os.path.join(config.root, "debian-cd", "tools",
                               "pi-makelist")
    for entry in os.listdir(scratch):
        if entry.endswith(".iso"):
            entry_path = os.path.join(scratch, entry)
            list_path = "%s.list" % entry_path.rsplit(".", 1)[0]
            with open(list_path, "w") as list_file:
                subprocess.check_call([pi_makelist, entry_path],
                                      stdout=list_file)
Пример #2
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
Пример #3
0
def build_livecd_base(config):
    log_marker("Downloading live filesystem images")
    download_live_filesystems(config)

    if (config.project in ("ubuntu-server") and
            config.image_type == "daily-preinstalled"):
        log_marker("Copying images to debian-cd output directory")
        scratch_dir = os.path.join(
            config.root, "scratch", config.project, config.full_series,
            config.image_type)
        live_dir = os.path.join(scratch_dir, "live")
        for arch in config.arches:
            output_dir = os.path.join(scratch_dir, "debian-cd", arch)
            osextras.ensuredir(output_dir)
            live_prefix = os.path.join(live_dir, arch)
            rootfs = "%s.disk1.img.xz" % (live_prefix)
            output_prefix = os.path.join(output_dir,
                                         "%s-preinstalled-server-%s" %
                                         (config.series, arch))
            with open("%s.type" % output_prefix, "w") as f:
                print("EXT4 Filesystem Image", file=f)
            shutil.copy2(rootfs, "%s.raw" % output_prefix)
            shutil.copy2(
                "%s.manifest" % live_prefix, "%s.manifest" % output_prefix)

    if (config.project == "ubuntu-core" and
            config.image_type == "daily-live"):
        log_marker("Copying images to debian-cd output directory")
        scratch_dir = os.path.join(
            config.root, "scratch", config.project, config.full_series,
            config.image_type)
        live_dir = os.path.join(scratch_dir, "live")
        for arch in config.arches:
            output_dir = os.path.join(scratch_dir, "debian-cd", arch)
            osextras.ensuredir(output_dir)
            live_prefix = os.path.join(live_dir, arch)
            rootfs = "%s.img.xz" % (live_prefix)
            output_prefix = os.path.join(output_dir,
                                         "%s-live-core-%s" %
                                         (config.series, arch))
            with open("%s.type" % output_prefix, "w") as f:
                print("Disk Image", file=f)
            shutil.copy2(rootfs, "%s.raw" % output_prefix)
            shutil.copy2(
                "%s.manifest" % live_prefix, "%s.manifest" % output_prefix)
            shutil.copy2(
                "%s.model-assertion" % live_prefix,
                "%s.model-assertion" % output_prefix)

    if (config.project in ("ubuntu-base", "ubuntu-touch") or
        (config.project == "ubuntu-core" and
         config.subproject == "system-image")):
        log_marker("Copying images to debian-cd output directory")
        scratch_dir = os.path.join(
            config.root, "scratch", config.project, config.full_series,
            config.image_type)
        live_dir = os.path.join(scratch_dir, "live")
        for arch in config.arches:
            live_prefix = os.path.join(live_dir, arch)
            rootfs = "%s.rootfs.tar.gz" % live_prefix
            if os.path.exists(rootfs):
                output_dir = os.path.join(scratch_dir, "debian-cd", arch)
                osextras.ensuredir(output_dir)
                if config.project == "ubuntu-core":
                    output_prefix = os.path.join(
                        output_dir,
                        "%s-preinstalled-core-%s" % (config.series, arch))
                elif config.project == "ubuntu-base":
                    output_prefix = os.path.join(
                        output_dir, "%s-base-%s" % (config.series, arch))
                elif config.project == "ubuntu-touch":
                    output_prefix = os.path.join(
                        output_dir,
                        "%s-preinstalled-touch-%s" % (config.series, arch))
                shutil.copy2(rootfs, "%s.raw" % output_prefix)
                with open("%s.type" % output_prefix, "w") as f:
                    print("tar archive", file=f)
                shutil.copy2(
                    "%s.manifest" % live_prefix, "%s.manifest" % output_prefix)
                if config.project == "ubuntu-touch":
                    osextras.link_force(
                        "%s.raw" % output_prefix, "%s.tar.gz" % output_prefix)
                    add_android_support(config, arch, output_dir)
                    custom = "%s.custom.tar.gz" % live_prefix
                    if os.path.exists(custom):
                        shutil.copy2(
                            custom, "%s.custom.tar.gz" % output_prefix)
                if config.project == "ubuntu-core":
                    for dev in ("azure.device", "device", "raspi2.device",
                                "plano.device"):
                        device = "%s.%s.tar.gz" % (live_prefix, dev)
                        if os.path.exists(device):
                            shutil.copy2(
                                device, "%s.%s.tar.gz" % (output_prefix, dev))
                    for snaptype in ("os", "kernel", "raspi2.kernel",
                                     "dragonboard.kernel"):
                        snap = "%s.%s.snap" % (live_prefix, snaptype)
                        if os.path.exists(snap):
                            shutil.copy2(
                                snap, "%s.%s.snap" % (output_prefix, snaptype))
Пример #4
0
def build_ubuntu_defaults_locale(config):
    locale = config["UBUNTU_DEFAULTS_LOCALE"]
    if locale != "zh_CN":
        raise UnknownLocale(
            "UBUNTU_DEFAULTS_LOCALE='%s' not currently supported!" % locale)

    series = config["DIST"]
    if series < "oneiric":
        # Original hack: repack an existing image.
        iso = config["ISO"]
        if not iso:
            raise Exception(
                "Pass ISO=<path to Ubuntu image> in the environment.")

        scratch = os.path.join(
            config.root, "scratch", "ubuntu-chinese-edition", series.name)
        bsdtar_tree = os.path.join(scratch, "bsdtar-tree")

        log_marker("Unpacking")
        if os.path.isdir(bsdtar_tree):
            subprocess.check_call(["chmod", "-R", "+w", bsdtar_tree])
        osextras.mkemptydir(bsdtar_tree)
        subprocess.check_call(["bsdtar", "-xf", iso, "-C", bsdtar_tree])
        subprocess.check_call(["chmod", "-R", "+w", bsdtar_tree])

        log_marker("Transforming (robots in disguise)")
        with open(os.path.join(bsdtar_tree, "isolinux", "lang"), "w") as lang:
            print(locale, file=lang)
        subprocess.call([
            "mkisofs",
            "-r", "-V", "Ubuntu Chinese %s i386" % series.version,
            "-o", os.path.join(scratch, os.path.basename(iso)),
            "-cache-inodes", "-J", "-l",
            "-b", "isolinux/isolinux.bin", "-c", "isolinux/boot.cat",
            "-no-emul-boot", "-boot-load-size", "4", "-boot-info-table",
            bsdtar_tree,
        ])

        iso_prefix = iso.rsplit(".", 1)[0]
        scratch_prefix = os.path.join(
            scratch, os.path.basename(iso).rsplit(".", 1)[0])

        for ext in "list", "manifest":
            if os.path.exists("%s.%s" % (iso_prefix, ext)):
                shutil.copy2(
                    "%s.%s" % (iso_prefix, ext),
                    "%s.%s" % (scratch_prefix, ext))
            else:
                osextras.unlink_force("%s.%s" % (scratch_prefix, ext))
    else:
        log_marker("Downloading live filesystem images")
        download_live_filesystems(config)
        scratch = live_output_directory(config)
        for entry in os.listdir(scratch):
            if "." in entry:
                os.rename(
                    os.path.join(scratch, entry),
                    os.path.join(scratch, "%s-desktop-%s" % (series, entry)))
        pi_makelist = os.path.join(
            config.root, "debian-cd", "tools", "pi-makelist")
        for entry in os.listdir(scratch):
            if entry.endswith(".iso"):
                entry_path = os.path.join(scratch, entry)
                list_path = "%s.list" % entry_path.rsplit(".", 1)[0]
                with open(list_path, "w") as list_file:
                    subprocess.check_call(
                        [pi_makelist, entry_path], stdout=list_file)