def make_index(self, project, arch, rel_target, rel_paths): target = os.path.join(self.output_dir(project), rel_target) osextras.mkemptydir(os.path.dirname(target)) with gzip.GzipFile(target, "wb") as target_file: for rel_path in rel_paths: if os.path.isabs(rel_path): abs_path = rel_path else: abs_path = os.path.join(find_mirror(self.config, arch), rel_path) if os.path.isfile(abs_path): with gzip.GzipFile(abs_path, "rb") as source_file: target_file.write(source_file.read())
def initrd_packages(self, initrd, arch): manifest_path = os.path.join(find_mirror(self.config, arch), "dists", self.config.series, "main", "installer-%s" % arch, "current", "images", "MANIFEST.udebs") if not os.path.exists(manifest_path): return set() if initrd.startswith("./"): initrd = initrd[2:] packages = set() with open(manifest_path) as manifest: found_initrd = False for line in manifest: line = line.rstrip("\n") if line == initrd: found_initrd = True elif found_initrd: if line and not line[0].isspace(): break else: packages.add(line.split()[0]) return packages
def extract_debootstrap(config): output_dir = os.path.join(config.root, "scratch", config.project, config.full_series, config.image_type, "debootstrap") osextras.ensuredir(output_dir) for fullarch in config.arches: arch = fullarch.split("+")[0] mirror = find_mirror(config, arch) # TODO: This might be more sensible with python-debian or python-apt. packages_path = os.path.join(mirror, "dists", config.series, "main", "debian-installer", "binary-%s" % arch, "Packages.gz") with gzip.GzipFile(packages_path, "rb") as packages: grep_dctrl = subprocess.Popen( ["grep-dctrl", "-nsFilename", "-PX", "debootstrap-udeb"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) udeb, _ = grep_dctrl.communicate(packages.read()) if not isinstance(udeb, str): udeb = udeb.decode() udeb = udeb.rstrip("\n") udeb_path = os.path.join(mirror, udeb) if not udeb or not os.path.exists(udeb_path): logger.warning("No debootstrap-udeb for %s/%s!" % (config.series, arch)) continue # TODO: With python-debian, we could extract the one file we need # directly. unpack_dir = os.path.join(output_dir, "unpack-%s" % fullarch) try: shutil.rmtree(unpack_dir) except OSError: pass subprocess.check_call(["dpkg", "-x", udeb_path, unpack_dir]) shutil.copy2( os.path.join(unpack_dir, _debootstrap_script(config)), os.path.join(output_dir, "%s-%s" % (config.series, fullarch)))
def assertMirrorEqual(self, base, arch, series): config = Config(read=False) config["DIST"] = Series.find_by_name(series) self.assertEqual( os.path.join(config.root, base), find_mirror(config, arch))
def assertMirrorEqual(self, base, arch, series): config = Config(read=False) config["DIST"] = series self.assertEqual(os.path.join(config.root, base), find_mirror(config, arch))