def test_mkemptydir_previously_populated(self): new_dir = os.path.join(self.temp_dir, "dir") os.mkdir(new_dir) touch(os.path.join(new_dir, "file")) osextras.mkemptydir(new_dir) self.assertTrue(os.path.isdir(new_dir)) self.assertEqual([], os.listdir(new_dir))
def _check_installable_command(config): britney, _, _, data = _check_installable_dirs(config) report_dir = os.path.join( britney, "report", config["PROJECT"], config["IMAGE_TYPE"]) mkemptydir(report_dir) return [ os.path.join(britney, "rptprobs.sh"), data, os.path.join(report_dir, "%s_probs.html" % config.series), "%s %s" % (config["CAPPROJECT"], config.series), ]
def _prepare_check_installable(config): _, image_top, live, data = _check_installable_dirs(config) mkemptydir(data) for fullarch in config.arches: arch = fullarch.split("+")[0] packages = os.path.join(data, "Packages_%s" % arch) with open(packages, "w") as packages_file: if config["CDIMAGE_SQUASHFS_BASE"]: squashfs = os.path.join(live, "%s.squashfs" % fullarch) if os.path.exists(squashfs): _ensure_tempdir() with open("/dev/null", "w") as devnull: subprocess.check_call([ "unsquashfs", "-d", os.path.join(_tempdir, fullarch), squashfs, "/var/lib/dpkg/status", ], stdout=devnull) status_path = os.path.join( _tempdir, fullarch, "var", "lib", "dpkg", "status") with open(os.path.join(status_path)) as status: subprocess.call([ "grep-dctrl", "-XFStatus", "install ok installed", ], stdin=status, stdout=packages_file) for component in "main", "restricted", "universe", "multiverse": packages_gz = os.path.join( image_top, "%s-%s" % (config.series, fullarch), "CD1", "dists", config.series, component, "binary-%s" % arch, "Packages.gz") if os.path.exists(packages_gz): packages_gz_file = gzip.GzipFile(packages_gz) try: packages_file.write(packages_gz_file.read()) finally: packages_gz_file.close() if os.stat(packages).st_size == 0: logger.warning( "No Packages.gz for %s/%s; not checking" % (config.series, arch)) os.unlink(packages) with open(os.path.join(data, "Sources"), "w"): pass
def test_mkemptydir_previously_missing(self): new_dir = os.path.join(self.temp_dir, "dir") osextras.mkemptydir(new_dir) self.assertTrue(os.path.isdir(new_dir)) self.assertEqual([], os.listdir(new_dir))
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")
def germinate_arch(self, project, arch): cpuarch = arch.split("+")[0] for dist in self.germinate_dists: for suffix in ( "binary-%s/Packages.gz" % cpuarch, "source/Sources.gz", "debian-installer/binary-%s/Packages.gz" % cpuarch, ): files = [ "dists/%s/%s/%s" % (dist, component, suffix) for component in self.components ] if self.config["LOCAL"]: files.append("%s/dists/%s/local/%s" % (self.config["LOCALDEBS"], dist, suffix)) self.make_index(project, arch, files[0], files) arch_output_dir = os.path.join(self.output_dir(project), arch) osextras.mkemptydir(arch_output_dir) if (self.config["GERMINATE_HINTS"] and os.path.isfile(self.config["GERMINATE_HINTS"])): shutil.copy2(self.config["GERMINATE_HINTS"], os.path.join(arch_output_dir, "hints")) command = [ self.germinate_path, "--seed-source", ",".join(self.seed_sources(project)), "--mirror", "file://%s/" % self.output_dir(project), "--seed-dist", self.seed_dist(project), "--dist", ",".join(self.germinate_dists), "--arch", cpuarch, "--components", "main", "--no-rdepends", ] if self.use_bzr: command.append("--bzr") if self.config.image_type == "source": command.append("--always-follow-build-depends") proxy_check_call(self.config, "germinate", command, cwd=arch_output_dir) output_structure = os.path.join(self.output_dir(project), "STRUCTURE") shutil.copy2(os.path.join(arch_output_dir, "structure"), output_structure) if self.config.series == "breezy": # Unfortunately, we now need a second germinate run to figure # out the dependencies of language packs and the like. extras = [] with open(os.path.join(arch_output_dir, "ship.acsets"), "w") as ship_acsets: output = GerminateOutput(self.config, output_structure) for pkg in output.seed_packages(arch, "ship.seed"): extras.append("desktop/%s" % pkg) print(pkg, file=ship_acsets) if extras: logger.info( "Re-germinating for %s/%s language pack dependencies ..." % (self.config.series, arch)) command.extend(["--seed-packages", ",".join(extras)]) proxy_check_call(self.config, "germinate", command, cwd=arch_output_dir)
def test_mkemptydir_previously_populated(self): new_dir = os.path.join(self.temp_dir, "dir") touch(os.path.join(new_dir, "file")) osextras.mkemptydir(new_dir) self.assertTrue(os.path.isdir(new_dir)) self.assertEqual([], os.listdir(new_dir))
def test_mkemptydir_previously_missing(self): new_dir = os.path.join(self.temp_dir, "dir") osextras.mkemptydir(new_dir) self.assertTrue(os.path.isdir(new_dir)) self.assertEqual([], os.listdir(new_dir))