|
23 | 23 | use anyhow::{anyhow, bail, Context, Result}; |
24 | 24 | use clap::{Args, Parser, Subcommand}; |
25 | 25 | use hyperlight_unikraft::pyhl::{ |
26 | | - copy_replace, discover_source_artifacts, extract_from_ghcr, GHCR_INITRD_IMAGE, |
27 | | - GHCR_KERNEL_IMAGE, |
| 26 | + copy_replace, discover_source_artifacts, extract_from_ghcr, ghcr_image_ref, GHCR_INITRD_REPO, |
| 27 | + GHCR_KERNEL_REPO, |
28 | 28 | }; |
29 | 29 | use hyperlight_unikraft::{AllowList, BlockList, ListenPorts, NetworkPolicy, Preopen, Sandbox}; |
30 | 30 | use std::fs; |
@@ -157,9 +157,14 @@ struct SetupArgs { |
157 | 157 | /// |
158 | 158 | /// Without --from, pyhl pulls the pre-published image from GHCR (requires |
159 | 159 | /// docker or podman on $PATH). |
160 | | - #[arg(long, value_name = "DIR")] |
| 160 | + #[arg(long, value_name = "DIR", conflicts_with = "tag")] |
161 | 161 | from: Option<PathBuf>, |
162 | 162 |
|
| 163 | + /// Pin a specific GHCR release tag (e.g., "v0.3.1") instead of |
| 164 | + /// pulling :latest. Ignored when --from is used. |
| 165 | + #[arg(long, value_name = "TAG", conflicts_with = "from")] |
| 166 | + tag: Option<String>, |
| 167 | + |
163 | 168 | /// Overwrite an existing installed image without prompting. |
164 | 169 | #[arg(long)] |
165 | 170 | force: bool, |
@@ -373,15 +378,18 @@ fn cmd_setup(args: SetupArgs) -> Result<()> { |
373 | 378 | // No --from: pull from GHCR. Uses docker or podman under the hood |
374 | 379 | // because that's the standard OCI client everyone has and avoids |
375 | 380 | // linking an oci-distribution client into pyhl. |
| 381 | + let tag = args.tag.as_deref(); |
| 382 | + let kernel_image = ghcr_image_ref(GHCR_KERNEL_REPO, tag); |
| 383 | + let initrd_image = ghcr_image_ref(GHCR_INITRD_REPO, tag); |
376 | 384 | eprintln!("pyhl: downloading image from GHCR…"); |
377 | 385 | let tmp = home.join(".pyhl.download"); |
378 | 386 | fs::create_dir_all(&tmp)?; |
379 | 387 | let kernel_path = tmp.join("kernel"); |
380 | 388 | let initrd_path = tmp.join("initrd.cpio"); |
381 | | - extract_from_ghcr(GHCR_KERNEL_IMAGE, "/kernel", &kernel_path)?; |
382 | | - extract_from_ghcr(GHCR_INITRD_IMAGE, "/initrd.cpio", &initrd_path)?; |
| 389 | + extract_from_ghcr(&kernel_image, "/kernel", &kernel_path)?; |
| 390 | + extract_from_ghcr(&initrd_image, "/initrd.cpio", &initrd_path)?; |
383 | 391 | ( |
384 | | - format!("{GHCR_KERNEL_IMAGE} + {GHCR_INITRD_IMAGE}"), |
| 392 | + format!("{kernel_image} + {initrd_image}"), |
385 | 393 | kernel_path, |
386 | 394 | initrd_path, |
387 | 395 | ) |
|
0 commit comments