def cmd_unpack(self) -> None: archive_path = self.get_archive_path() common.iprint("Unpacking archive: {}".format(archive_path)) dist_prefix = "dist/" extracted = set() with common.tar_context(archive_path, "r") as tar_f: for tar_info in tar_f: if tar_info.isdir(): continue if not tar_info.name.startswith(dist_prefix): raise error.UnexpectedArchiveMemberError(tar_info.name) rel_path = tar_info.name[len(dist_prefix):] dest_path = self.dest_path_from_rel_path(rel_path) tar_info.name = str(dest_path) common.vprint("[unpack] {}".format(rel_path)) tar_f.extract(tar_info) extracted.add(rel_path) specs = self._detect_specs(extracted) targets = self._detect_targets(specs, extracted) common.iprint("Unpacked specs: {}".format(len(specs))) for spec in specs: common.iprint(" {}".format(spec)) common.iprint("Unpacked targets: {}".format(len(targets))) for target in targets: common.iprint(" {}".format(target)) self.specs = specs self.targets = targets
def pack( crates: List[Crate], crates_root: Path, bundle_path: Optional[Path], archive_path: Path, keep_going: bool, ) -> None: num_good_paths = 0 num_bad_paths = 0 with common.tar_context(archive_path, "w") as tar_f: if bundle_path is not None: packed_name = INDEX_BUNDLE_PACKED_NAME common.vprint("[pack] {}".format(packed_name)) tar_f.add(str(bundle_path), packed_name) for rel_path in sorted(crate.rel_path() for crate in crates): path = crates_root / rel_path packed_name = "crates/" + rel_path.as_posix() try: common.vprint("[pack] {}".format(rel_path.name)) tar_f.add(str(path), packed_name) num_good_paths += 1 except FileNotFoundError: num_bad_paths += 1 common.eprint("Error: Missing {}".format(rel_path)) if not keep_going: raise error.AbortError() common.iprint("{} bad paths, {} good paths".format(num_bad_paths, num_good_paths))
def cmd_pack(self) -> None: base_targets = dist.require_targets(self.targets, default="*") archive_path = self.get_archive_path() common.iprint("Packing archive: {}".format(archive_path)) with common.tar_context(archive_path, "w") as tar_f: def pack_path(rel_path: str) -> None: dest_path = self.dest_path_from_rel_path(rel_path) packed_name = "rustup/" + rel_path common.vprint("[pack] {}".format(rel_path)) try: tar_f.add(str(dest_path), packed_name) except FileNotFoundError: raise error.MissingFileError(str(dest_path)) def pack_rel_path(rel_path: str) -> None: pack_path(rel_path) pack_path(integrity.append_hash_suffix(rel_path)) for spec in self.adjust_wild_specs(self.specs): common.iprint("Pack: {}".format(spec)) version = self.version_from_spec(spec, download=False) common.iprint(" version: {}".format(version)) targets = self.adjust_targets(version, base_targets) common.iprint(" targets: {}".format(len(targets))) for t in targets: common.vvprint(" target: {}".format(t)) for target in targets: rel_path = self.rustup_init_rel_path(version, target) pack_rel_path(rel_path)
def unpack( repo: git.Repo, crates_root: Path, bundle_path: Path, archive_path: Path, keep_going: bool, ) -> None: num_crates = 0 crates_prefix = "crates/" found_bundle = False try: with common.tar_context(archive_path, "r") as tar_f: for tar_info in tar_f: if tar_info.isdir(): continue elif tar_info.name == INDEX_BUNDLE_PACKED_NAME: found_bundle = True tar_info.name = str(bundle_path) common.vprint("[unpack] {}".format(tar_info.name)) tar_f.extract(tar_info) elif tar_info.name.startswith(crates_prefix): num_crates += 1 tar_info.name = tar_info.name[len(crates_prefix):] common.vprint("[unpack] {}".format( os.path.basename(tar_info.name))) tar_f.extract(tar_info, str(crates_root)) else: common.eprint("Unexpected archive member {}".format( tar_info.name)) if not keep_going: raise error.AbortError() except Exception as err: common.eprint("Exception unpacking: {}".format(err)) raise if not found_bundle: common.eprint("Missing {} in archive".format(INDEX_BUNDLE_PACKED_NAME)) if not keep_going: raise error.AbortError() common.iprint("{} extracted crates".format(num_crates))
def cmd_pack(self) -> None: base_targets = dist.require_targets(self.targets, default="*") archive_path = self.get_archive_path() common.iprint("Packing archive: {}".format(archive_path)) with common.tar_context(archive_path, "w") as tar_f: def pack_path(rel_path: str) -> None: dest_path = self.dest_path_from_rel_path(rel_path) packed_name = "dist/" + rel_path common.vprint("[pack] {}".format(rel_path)) try: tar_f.add(str(dest_path), packed_name) except FileNotFoundError: raise error.MissingFileError(str(dest_path)) def pack_rel_path(rel_path: str) -> None: pack_path(rel_path) pack_path(integrity.append_hash_suffix(rel_path)) if self._with_sig: pack_path(signature.append_sig_suffix(rel_path)) for spec in self.adjust_wild_specs(self.specs): common.iprint("Pack: {}".format(spec)) manifest = self.select_manifest(spec, download=False, canonical=True) common.iprint(" ident: {}".format(manifest.ident)) targets = self.adjust_targets(manifest, base_targets) packages = list( manifest.gen_available_packages(targets=targets)) common.iprint(" packages: {}, targets: {}".format( len(packages), len(targets))) for t in targets: common.vvprint(" target: {}".format(t)) # Pack channel file. pack_rel_path(channel_rel_path(manifest.date, manifest.channel)) # Pack up package file parts. for package in packages: pack_rel_path(package.rel_path)