def download_file(url, dest_path, expected_size=None, expected_sha1=None): """Download a file with optional size and hash verification.""" dest_path = Path(dest_path) dest_path.parent.mkdir(parents=True, exist_ok=True)
# ------------------------------ # Main CLI # ------------------------------ def main(): parser = argparse.ArgumentParser(description="UUPdump-style Windows ISO builder") parser.add_argument("build", help="Build number, e.g., 22621.1") parser.add_argument("lang", help="Language code, e.g., en-us") parser.add_argument("edition", help="Edition, e.g., Professional") parser.add_argument("--out", "-o", help="Output ISO path", default="windows_install.iso") parser.add_argument("--work-dir", help="Working directory", default="UUP_workspace") parser.add_argument("--keep-temp", action="store_true", help="Keep temporary files") args = parser.parse_args() work_dir = Path(args.work_dir) work_dir.mkdir(exist_ok=True) try: print(f"Fetching UUP info for build {args.build}, lang {args.lang}, edition {args.edition}") uup_info = fetch_uup_info(args.build, args.lang, args.edition) print("Downloading UUP files...") uup_files_dir = download_uup_files(uup_info, work_dir, args.edition) print("Converting to ISO...") convert_to_iso(uup_files_dir, args.edition, Path(args.out), keep_temp=args.keep_temp) print("Done.") except Exception as e: print(f"Error: {e}") sys.exit(1) uupdump
# Resume support headers = {} if dest_path.exists(): existing_size = dest_path.stat().st_size if expected_size and existing_size == expected_size: print(f" [SKIP] {dest_path.name} already complete") return True headers['Range'] = f'bytes={existing_size}-' print(f" [DL] {url}") resp = requests.get(url, stream=True, headers=headers) resp.raise_for_status() mode = 'ab' if 'Range' in headers else 'wb' with open(dest_path, mode) as f: for chunk in resp.iter_content(chunk_size=8192): f.write(chunk) # Verify size if expected_size and dest_path.stat().st_size != expected_size: raise ValueError(f"Size mismatch for {dest_path.name}") # Verify SHA‑1 if expected_sha1: sha1 = hashlib.sha1() with open(dest_path, 'rb') as f: for chunk in iter(lambda: f.read(65536), b''): sha1.update(chunk) if sha1.hexdigest() != expected_sha1: raise ValueError(f"SHA‑1 mismatch for {dest_path.name}") return True help="Output ISO path"
#!/usr/bin/env python3 """ UUPdump-style tool: Fetch UUP set, download files, convert to ISO. Requires: requests, python-gnupg (optional), plus external tools: cabextract, wimlib, mkisofs/genisoimage """ convert to ISO. Requires: requests