Esempio n. 1
0
def add_android_support(config, arch, output_dir):
    """Copy Android support files to an Ubuntu Touch image.
    """
    live_scratch_dir = os.path.join(
        config.root, "scratch", config.project, config.full_series,
        config.image_type, "live")

    # copy recovery, boot and system imgs in place
    for target in Touch.list_targets_by_ubuntu_arch(arch):
        boot_img_src = "boot-%s+%s.img" % (target.ubuntu_arch, target.subarch)
        boot_img = "%s-preinstalled-boot-%s+%s.img" % (
            config.series, arch, target.subarch)
        system_img_src = "system-%s+%s.img" % (
            target.android_arch, target.subarch)
        system_img = "%s-preinstalled-system-%s+%s.img" % (
            config.series, target.android_arch, target.subarch)
        recovery_img_src = "recovery-%s+%s.img" % (
            target.android_arch, target.subarch)
        recovery_img = "%s-preinstalled-recovery-%s+%s.img" % (
            config.series, target.android_arch, target.subarch)

        shutil.copy2(
            os.path.join(live_scratch_dir, boot_img_src),
            os.path.join(output_dir, boot_img))
        shutil.copy2(
            os.path.join(live_scratch_dir, system_img_src),
            os.path.join(output_dir, system_img))
        shutil.copy2(
            os.path.join(live_scratch_dir, recovery_img_src),
            os.path.join(output_dir, recovery_img))
Esempio n. 2
0
def download_live_filesystems(config):
    project = config.project
    series = config["DIST"]

    output_dir = live_output_directory(config)
    osextras.mkemptydir(output_dir)

    if (config["CDIMAGE_LIVE"] or config["CDIMAGE_SQUASHFS_BASE"] or
            config["CDIMAGE_PREINSTALLED"]):
        got_image = False
        for arch in config.arches:
            if config["CDIMAGE_PREINSTALLED"]:
                if project == "ubuntu-server":
                    if download_live_items(config, arch, "disk1.img.xz"):
                        got_image = True
                    else:
                        continue
                elif download_live_items(config, arch, "ext4"):
                    got_image = True
                elif download_live_items(config, arch, "ext3"):
                    got_image = True
                elif download_live_items(config, arch, "ext2"):
                    got_image = True
                elif download_live_items(config, arch, "rootfs.tar.gz"):
                    got_image = True
                else:
                    continue
            elif config["UBUNTU_DEFAULTS_LOCALE"]:
                if download_live_items(config, arch, "iso"):
                    got_image = True
                else:
                    continue
            elif download_live_items(config, arch, "img.xz"):
                got_image = True
            elif download_live_items(config, arch, "cloop"):
                got_image = True
            elif download_live_items(config, arch, "squashfs"):
                download_live_items(config, arch, "modules.squashfs")
                got_image = True
            elif download_live_items(config, arch, "rootfs.tar.gz"):
                got_image = True
            elif download_live_items(config, arch, "tar.xz"):
                got_image = True
            else:
                continue
            if (project != "ubuntu-base" and
                    not config["CDIMAGE_SQUASHFS_BASE"] and
                    config.subproject != "wubi"):
                download_live_items(config, arch, "kernel")
                download_live_items(config, arch, "initrd")
                download_live_items(config, arch, "kernel-efi-signed")
                if config["CDIMAGE_PREINSTALLED"]:
                    download_live_items(config, arch, "bootimg")

            download_live_items(config, arch, "manifest")
            if not download_live_items(config, arch, "manifest-remove"):
                download_live_items(config, arch, "manifest-desktop")
            download_live_items(config, arch, "manifest-minimal-remove")
            download_live_items(config, arch, "size")

            if (config["UBUNTU_DEFAULTS_LOCALE"] or
                    config["CDIMAGE_PREINSTALLED"] or
                    config.subproject == "wubi"):
                continue

            if (project not in ("livecd-base", "ubuntu-base", "ubuntu-core",
                                "kubuntu-active") and
                    (project != "edubuntu" or series >= "precise") and
                    (project != "ubuntukylin" or series <= "trusty")):
                if series <= "trusty":
                    # TODO: We still have to do something about not
                    # including Wubi on the DVDs.
                    download_live_items(config, arch, "wubi")
                    wubi_path = os.path.join(output_dir, "%s.wubi.exe" % arch)
                    if os.path.exists(wubi_path):
                        # Nicely format the distribution name.
                        def upper_first(m):
                            text = m.group(0)
                            return text[0].upper() + text[1:]

                        autorun_project = re.sub(
                            r"(\b[a-z])", upper_first,
                            project.replace("-", " "))
                        write_autorun(
                            config, arch, "wubi.exe",
                            "Install %s" % autorun_project)

            if project not in ("livecd-base", "ubuntu-base", "ubuntu-core",
                               "edubuntu"):
                download_live_items(config, arch, "usb-creator")
            if project == "ubuntu-core" and config["CDIMAGE_LIVE"]:
                download_live_items(config, arch, "model-assertion")

        if not got_image:
            raise NoFilesystemImages("No filesystem images found.")

    if config.project == "ubuntu-touch":
        for arch in config.arches:
            for abootimg in (
                "boot-%s+%s.img" % (target.ubuntu_arch, target.subarch)
                    for target in Touch.list_targets_by_ubuntu_arch(arch)
            ):
                download_live_items(
                    config, arch, abootimg
                )
            for recoveryimg in (
                "recovery-%s+%s.img" % (target.android_arch, target.subarch)
                    for target in Touch.list_targets_by_ubuntu_arch(arch)
            ):
                download_live_items(
                    config, arch, recoveryimg
                )
            for systemimg in (
                "system-%s+%s.img" % (target.android_arch, target.subarch)
                    for target in Touch.list_targets_by_ubuntu_arch(arch)
            ):
                download_live_items(
                    config, arch, systemimg
                )
            download_live_items(config, arch, "custom.tar.gz")

    if config.project == "ubuntu-core":
        for arch in config.arches:
            download_live_items(config, arch, "device.tar.gz")

    if config.project == "ubuntu-core":
        for arch in config.arches:
            download_live_items(config, arch, "os.snap")
            download_live_items(config, arch, "kernel.snap")
            if arch == "amd64":
                for devarch in ("azure", "plano"):
                    download_live_items(config, arch, "%s.device.tar.gz" %
                                        devarch)
            if arch == "armhf":
                download_live_items(config, arch, "raspi2.device.tar.gz")
                download_live_items(config, arch, "raspi2.kernel.snap")
            if arch == "arm64":
                download_live_items(config, arch, "dragonboard.kernel.snap")

    if project == "edubuntu" and config["CDIMAGE_DVD"]:
        for arch in config.arches:
            if arch in ("amd64", "i386"):
                # Fetch the i386 LTSP chroot for Edubuntu Terminal Server.
                download_live_items(config, arch, "ltsp-squashfs")
Esempio n. 3
0
def download_live_items(config, arch, item):
    output_dir = live_output_directory(config)
    found = False

    urls = list(live_item_paths(config, arch, item))
    if not urls:
        return False

    if item in (
        "kernel", "initrd", "bootimg"
    ):
        for url in urls:
            flavour = re.sub(
                r"^.*?\..*?\..*?-", "", unquote(os.path.basename(url)))
            target = os.path.join(
                output_dir, "%s.%s-%s" % (arch, item, flavour))
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in (
        "boot-%s+%s.img" % (target.ubuntu_arch, target.subarch)
            for target in Touch.list_targets_by_ubuntu_arch(arch)
    ):
        for url in urls:
            target = os.path.join(output_dir, item)
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in (
        "modules.squashfs",
    ):
        for url in urls:
            base = unquote(os.path.basename(url))
            base = "%s.%s" % (arch, base.split('.', 2)[2])
            target = os.path.join(output_dir, base)
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in (
        "recovery-%s+%s.img" % (target.android_arch, target.subarch)
            for target in Touch.list_targets_by_ubuntu_arch(arch)
    ):
        for url in urls:
            target = os.path.join(output_dir, item)
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in (
        "system-%s+%s.img" % (target.android_arch, target.subarch)
            for target in Touch.list_targets_by_ubuntu_arch(arch)
    ):
        for url in urls:
            target = os.path.join(output_dir, item)
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item == "kernel-efi-signed":
        for url in urls:
            base = unquote(os.path.basename(url))
            if base.endswith(".efi.signed"):
                base = base[:-len(".efi.signed")]
            flavour = re.sub(r"^.*?\..*?\..*?-", "", base)
            target = os.path.join(
                output_dir, "%s.kernel-%s.efi.signed" % (arch, flavour))
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in ("wubi", "usb-creator"):
        target = os.path.join(output_dir, "%s.%s.exe" % (arch, item))
        try:
            osextras.fetch(config, urls[0], target)
            found = True
        except osextras.FetchError:
            pass
    else:
        for url in urls:
            # strip livecd.<PROJECT> and replace by arch
            filename = unquote(os.path.basename(url)).split('.', 2)[-1]
            target = os.path.join(output_dir, "%s.%s" % (arch, filename))
            try:
                osextras.fetch(config, url, target)
                if target.endswith("squashfs"):
                    sign.sign_cdimage(config, target)
                found = True
            except osextras.FetchError:
                pass
    return found
Esempio n. 4
0
def live_item_paths(config, arch, item):
    if item == "ltsp-squashfs" and arch == "amd64":
        # use i386 LTSP image on amd64 too
        arch = "i386"
    cpuarch, subarch = split_arch(arch)
    project = config.project
    series = config["DIST"]
    liveproject = live_project(config, arch)
    if subarch:
        liveproject_subarch = "%s-%s" % (liveproject, subarch)
    else:
        liveproject_subarch = liveproject

    lp, lp_livefs = get_lp_livefs(config, arch)
    uris = []
    root = ""
    if lp_livefs is not None:
        lp_kwargs = live_build_lp_kwargs(config, lp, lp_livefs, arch)
        lp_build = lp_livefs.getLatestBuild(
            lp_kwargs["distro_arch_series"],
            unique_key=lp_kwargs.get("unique_key"))
        uris = list(lp_build.getFileUrls())
    else:
        root = livecd_base(config, arch)
        try:
            uris = [os.path.join(root, u) for u in os.listdir(root)]
        except OSError:
            # fallback to exact given uri (for http://) in url_for as we can't
            # list content.
            pass

    def urls_for(base, item):
        if uris:
            for uri in uris:
                filename = unquote(os.path.basename(uri))
                if (filename.startswith(base + '.') and
                        filename.endswith('.' + item)):
                    yield uri
        else:
            yield os.path.join(root, base + '.' + item)

    if item in (
        "cloop", "squashfs", "manifest", "manifest-desktop", "manifest-remove",
        "manifest-minimal-remove", "size", "ext2", "ext3", "ext4",
        "rootfs.tar.gz", "custom.tar.gz", "device.tar.gz",
        "azure.device.tar.gz", "raspi2.device.tar.gz", "plano.device.tar.gz",
        "tar.xz", "iso", "os.snap", "kernel.snap", "disk1.img.xz",
        "dragonboard.kernel.snap", "raspi2.kernel.snap",
        "img.xz", "model-assertion"
    ):
        if item == "ext4" and arch == "armhf+nexus7":
            for url in urls_for(
                    "livecd." + liveproject_subarch, item + "-nexus7"):
                yield url
        elif item == "disk1.img.xz":
            for url in urls_for(
                    "livecd." + liveproject, item):
                yield url
        else:
            for url in urls_for("livecd." + liveproject_subarch, item):
                # filter out redundant artefacts
                if url.endswith("modules.squashfs"):
                    continue
                yield url
    elif item in (
        "kernel", "initrd", "bootimg", "modules.squashfs"
    ):
        our_flavours = flavours(config, arch)
        our_flavours.extend(["%s-hwe" % (f,) for f in our_flavours])
        for flavour in our_flavours:
            for url in urls_for("livecd." + liveproject_subarch,
                                item + "-" + flavour):
                yield url
    elif item in (
        "boot-%s+%s.img" % (target.ubuntu_arch, target.subarch)
            for target in Touch.list_targets_by_ubuntu_arch(arch)
    ) or item in (
        "recovery-%s+%s.img" % (target.android_arch, target.subarch)
            for target in Touch.list_targets_by_ubuntu_arch(arch)
    ) or item in (
        "system-%s+%s.img" % (target.android_arch, target.subarch)
            for target in Touch.list_targets_by_ubuntu_arch(arch)
    ):
        for flavour in flavours(config, arch):
            for url in urls_for("livecd." + liveproject_subarch, item):
                yield url
    elif item == "kernel-efi-signed":
        if series >= "precise" and arch == "amd64":
            for flavour in flavours(config, arch):
                for url in urls_for("livecd." + liveproject_subarch,
                                    "kernel-" + flavour + ".efi.signed"):
                    yield url
    elif item == "wubi":
        if (project != "xubuntu" and arch in ("amd64", "i386")):
            yield ("http://people.canonical.com/~ubuntu-archive/wubi/%s/"
                   "stable" % series)
    elif item == "usb-creator":
        if arch in ("amd64", "i386"):
            yield ("http://people.canonical.com/~evand/usb-creator/%s/"
                   "stable" % series)
    elif item == "ltsp-squashfs":
        if arch in ("amd64", "i386"):
            for url in urls_for("livecd." + liveproject + "-ltsp", "squashfs"):
                yield url
    else:
        raise UnknownLiveItem("Unknown live filesystem item '%s'" % item)
Esempio n. 5
0
def download_live_items(config, arch, item):
    output_dir = live_output_directory(config)
    found = False

    if item == "server-squashfs":
        original_project = config.project
        try:
            config["PROJECT"] = "ubuntu-server"
            urls = list(live_item_paths(config, arch, "squashfs"))
        finally:
            config["PROJECT"] = original_project
    else:
        urls = list(live_item_paths(config, arch, item))
    if not urls:
        return False

    if item in ("kernel", "initrd", "bootimg"):
        for url in urls:
            flavour = re.sub(r"^.*?\..*?\..*?-", "",
                             unquote(os.path.basename(url)))
            target = os.path.join(output_dir,
                                  "%s.%s-%s" % (arch, item, flavour))
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in ("boot-%s+%s.img" % (target.ubuntu_arch, target.subarch)
                  for target in Touch.list_targets_by_ubuntu_arch(arch)):
        for url in urls:
            target = os.path.join(output_dir, item)
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in ("recovery-%s+%s.img" % (target.android_arch, target.subarch)
                  for target in Touch.list_targets_by_ubuntu_arch(arch)):
        for url in urls:
            target = os.path.join(output_dir, item)
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in ("system-%s+%s.img" % (target.android_arch, target.subarch)
                  for target in Touch.list_targets_by_ubuntu_arch(arch)):
        for url in urls:
            target = os.path.join(output_dir, item)
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item == "kernel-efi-signed":
        for url in urls:
            base = unquote(os.path.basename(url))
            if base.endswith(".efi.signed"):
                base = base[:-len(".efi.signed")]
            flavour = re.sub(r"^.*?\..*?\..*?-", "", base)
            target = os.path.join(output_dir,
                                  "%s.kernel-%s.efi.signed" % (arch, flavour))
            try:
                osextras.fetch(config, url, target)
                found = True
            except osextras.FetchError:
                pass
    elif item in ("wubi", "umenu", "usb-creator"):
        target = os.path.join(output_dir, "%s.%s.exe" % (arch, item))
        try:
            osextras.fetch(config, urls[0], target)
            found = True
        except osextras.FetchError:
            pass
    elif item == "winfoss":
        target = os.path.join(output_dir, "%s.%s.tgz" % (arch, item))
        try:
            osextras.fetch(config, urls[0], target)
            found = True
        except osextras.FetchError:
            pass
    else:
        target = os.path.join(output_dir, "%s.%s" % (arch, item))
        try:
            osextras.fetch(config, urls[0], target)
            if item in ["squashfs", "server-squashfs"]:
                sign.sign_cdimage(config, target)
            found = True
        except osextras.FetchError:
            pass
    return found
Esempio n. 6
0
def live_item_paths(config, arch, item):
    if item == "ltsp-squashfs" and arch == "amd64":
        # use i386 LTSP image on amd64 too
        arch = "i386"
    cpuarch, subarch = split_arch(arch)
    project = config.project
    series = config["DIST"]
    liveproject = live_project(config, arch)
    if subarch:
        liveproject_subarch = "%s-%s" % (liveproject, subarch)
    else:
        liveproject_subarch = liveproject

    lp, lp_livefs = get_lp_livefs(config, arch)
    if lp_livefs is not None:
        lp_kwargs = live_build_lp_kwargs(config, lp, lp_livefs, arch)
        lp_build = lp_livefs.getLatestBuild(
            lp_kwargs["distro_arch_series"],
            unique_key=lp_kwargs.get("unique_key"))
        lp_urls = list(lp_build.getFileUrls())

        def urls_for(base):
            for url in lp_urls:
                if unquote(os.path.basename(url)) == base:
                    yield url
    else:
        root = livecd_base(config, arch)

        def urls_for(base):
            yield "%s/%s" % (root, base)

    if item in ("cloop", "squashfs", "manifest", "manifest-desktop",
                "manifest-remove", "size", "ext2", "ext3", "ext4",
                "rootfs.tar.gz", "custom.tar.gz", "device.tar.gz",
                "azure.device.tar.gz", "raspi2.device.tar.gz",
                "plano.device.tar.gz", "tar.xz", "iso", "os.snap",
                "kernel.snap", "disk1.img.xz", "dragonboard.kernel.snap",
                "raspi2.kernel.snap", "installer.squashfs", "img.xz",
                "model-assertion"):
        if project == "tocd3":
            # auto-purged - reverting to plan B
            yield "/home/cjwatson/tocd3/livecd.tocd3.%s" % item
        elif project == "ubuntu" and series == "breezy":
            # auto-purged - reverting to plan B
            yield "/home/cjwatson/breezy-live/ubuntu/livecd.%s.%s" % (arch,
                                                                      item)
        elif item == "ext4" and arch == "armhf+nexus7":
            for url in urls_for("livecd.%s.%s-nexus7" %
                                (liveproject_subarch, item)):
                yield url
        elif item in ("disk1.img.xz", "img.xz", "model-assertion"):
            for url in urls_for("livecd.%s.%s" % (liveproject, item)):
                yield url
        else:
            for url in urls_for("livecd.%s.%s" % (liveproject_subarch, item)):
                yield url
    elif item in ("kernel", "initrd", "bootimg"):
        for flavour in flavours(config, arch):
            base = "livecd.%s.%s-%s" % (liveproject_subarch, item, flavour)
            for url in urls_for(base):
                yield url
    elif item in (
            "boot-%s+%s.img" % (target.ubuntu_arch, target.subarch)
            for target in Touch.list_targets_by_ubuntu_arch(arch)) or item in (
                "recovery-%s+%s.img" % (target.android_arch, target.subarch)
                for target in Touch.list_targets_by_ubuntu_arch(arch)
            ) or item in (
                "system-%s+%s.img" % (target.android_arch, target.subarch)
                for target in Touch.list_targets_by_ubuntu_arch(arch)):
        for flavour in flavours(config, arch):
            base = "livecd.%s.%s" % (liveproject_subarch, item)
            for url in urls_for(base):
                yield url
    elif item == "kernel-efi-signed":
        if series >= "precise" and arch == "amd64":
            for flavour in flavours(config, arch):
                base = "livecd.%s.kernel-%s.efi.signed" % (liveproject_subarch,
                                                           flavour)
                for url in urls_for(base):
                    yield url
    elif item == "winfoss":
        for path in live_item_path_winfoss(config, arch):
            yield path
    elif item == "wubi":
        if (project != "xubuntu" and arch in ("amd64", "i386")
                and series >= "gutsy"):
            yield ("http://people.canonical.com/~ubuntu-archive/wubi/%s/"
                   "stable" % series)
    elif item == "umenu":
        if arch in ("amd64", "i386") and series == "hardy":
            yield "http://people.canonical.com/~evand/umenu/stable"
    elif item == "usb-creator":
        if arch in ("amd64", "i386"):
            yield ("http://people.canonical.com/~evand/usb-creator/%s/"
                   "stable" % series)
    elif item == "ltsp-squashfs":
        if arch in ("amd64", "i386"):
            for url in urls_for("livecd.%s-ltsp.squashfs" % liveproject):
                yield url
    else:
        raise UnknownLiveItem("Unknown live filesystem item '%s'" % item)