def test_link_present(self):
     source = os.path.join(self.temp_dir, "source")
     touch(source)
     target = os.path.join(self.temp_dir, "target")
     touch(target)
     osextras.link_force(source, target)
     self.assertEqual(os.stat(source), os.stat(target))
Exemple #2
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))