예제 #1
0
def cloud_build(args):
    licenses = set([x.license for x in emu_downloads_menu.get_emus_info()] +
                   [x.license for x in emu_downloads_menu.get_images_info()])

    for l in licenses:
        l.force_accept()

    imgzip = [x.download() for x in emu_downloads_menu.find_image(args.img)]
    emuzip = [x.download() for x in emu_downloads_menu.find_emulator("canary")]
    devices = []

    steps = []
    images = []
    emulators = set()

    for (img, emu) in itertools.product(imgzip, emuzip):
        logging.info("Processing %s, %s", img, emu)
        img_rel = emu_downloads_menu.AndroidReleaseZip(img)
        if not img_rel.is_system_image():
            logging.warn(
                "{} is not a zip file with a system image (Unexpected description), skipping"
                .format(img))
            continue
        emu_rel = emu_downloads_menu.AndroidReleaseZip(emu)
        if not emu_rel.is_emulator():
            raise Exception(
                "{} is not a zip file with an emulator".format(emu))

        emulators.add(emu_rel.build_id())
        for metrics in [True, False]:
            name = img_rel.repo_friendly_name()
            if not metrics:
                name += "-no-metrics"

            dest = os.path.join(args.dest, name)
            logging.info("Generating %s", name)
            device = DockerDevice(emu,
                                  img,
                                  dest,
                                  gpu=False,
                                  repo=args.repo,
                                  tag=emu_rel.build_id(),
                                  name=name)
            device.create_docker_file("",
                                      metrics=True,
                                      by_copying_zip_files=True)
            steps.append(device.create_cloud_build_step())
            images.append(device.tag)

    cloudbuild = {"steps": steps, "images": images}
    with open(os.path.join(args.dest, "cloudbuild.yaml"), "w") as ymlfile:
        yaml.dump(cloudbuild, ymlfile)

    writer = TemplateWriter(args.dest)
    writer.write_template(
        "cloudbuild.README.MD",
        {
            "emu_version": ", ".join(emulators),
            "emu_images": "\n".join(images)
        },
        rename_as="README.MD",
    )
예제 #2
0
def cloud_build(args):
    licenses = set(
        [x.license for x in emu_downloads_menu.get_emus_info()]
        + [x.license for x in emu_downloads_menu.get_images_info()]
    )

    for l in licenses:
        l.force_accept()

    imgzip = [x.download() for x in emu_downloads_menu.find_image(args.img)]
    emuzip = [args.emuzip]
    if emuzip[0] in ["stable", "canary", "all"]:
        emuzip = [x.download() for x in emu_downloads_menu.find_emulator(emuzip[0])]
    elif re.match("\d+", emuzip[0]):
        # We must be looking for a build id
        logging.info("Treating %s as a build id", emuzip[0])
        emuzip = [emu_downloads_menu.download_build(emuzip[0])]

    steps = []
    images = []
    desserts = set()
    emulators = set()

    for (img, emu) in itertools.product(imgzip, emuzip):
        logging.info("Processing %s, %s", img, emu)
        img_rel = emu_downloads_menu.AndroidReleaseZip(img)
        if not img_rel.is_system_image():
            logging.warning("{} is not a zip file with a system image (Unexpected description), skipping".format(img))
            continue
        emu_rel = emu_downloads_menu.AndroidReleaseZip(emu)
        if not emu_rel.is_emulator():
            raise Exception("{} is not a zip file with an emulator".format(emu))

        emulators.add(emu_rel.build_id())
        desserts.add(img_rel.codename())
        for metrics in [True, False]:
            name = img_rel.repo_friendly_name()
            if not metrics:
                name += "-no-metrics"

            dest = os.path.join(args.dest, name)
            logging.info("Generating %s", name)
            device = DockerDevice(emu, img, dest, gpu=False, repo=args.repo, tag=emu_rel.build_id(), name=name)
            device.create_docker_file("", metrics=True, by_copying_zip_files=True)
            steps.append(device.create_cloud_build_step())
            images.append(device.tag)
            images.append(device.latest)

    steps[-1]["waitFor"] = ["-"]
    cloudbuild = {"steps": steps, "images": images, "timeout": "21600s"}
    with open(os.path.join(args.dest, "cloudbuild.yaml"), "w") as ymlfile:
        yaml.dump(cloudbuild, ymlfile)

    writer = TemplateWriter(args.dest)
    writer.write_template(
        "cloudbuild.README.MD",
        {"emu_version": ", ".join(emulators), "emu_images": "\n".join(["* {}".format(x) for x in images])},
        rename_as="README.MD",
    )
    writer.write_template(
        "registry.README.MD",
        {
            "emu_version": ", ".join(emulators),
            "emu_images": "\n".join(["* {}".format(x) for x in images]),
            "first_image": images[0]
        },
        rename_as="REGISTRY.MD",
    )

    if args.git:
        git_commit_and_push(args.dest)