Skip to content

Commit 875b25f

Browse files
committed
remove cache type requirement in ghcr path
1 parent 0db7b25 commit 875b25f

4 files changed

Lines changed: 25 additions & 22 deletions

File tree

sbuild-meta/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ async fn cmd_generate(
301301
&manifest,
302302
&ghcr_info.ghcr_path,
303303
&arch,
304+
&ghcr_info.cache_type,
304305
);
305306
}
306307
}

sbuild-meta/src/manifest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ mod tests {
210210
}
211211
],
212212
"annotations": {
213-
"dev.pkgforge.soar.ghcr_pkg": "ghcr.io/pkgforge/bincache/mybin:v1.0"
213+
"dev.pkgforge.soar.ghcr_pkg": "ghcr.io/pkgforge/mybin:v1.0"
214214
}
215215
}"#;
216216

217217
let manifest = OciManifest::from_json(json).unwrap();
218218
assert_eq!(manifest.schema_version, 2);
219219
assert_eq!(manifest.layers.len(), 1);
220-
assert_eq!(manifest.ghcr_pkg(), Some("ghcr.io/pkgforge/bincache/mybin:v1.0"));
220+
assert_eq!(manifest.ghcr_pkg(), Some("ghcr.io/pkgforge/mybin:v1.0"));
221221
assert_eq!(manifest.filenames(), vec!["mybin"]);
222222
}
223223

sbuild-meta/src/metadata.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,16 @@ impl PackageMetadata {
254254

255255
/// Enrich metadata with OCI manifest data
256256
///
257-
/// `ghcr_path` is the repository path (e.g., "pkgforge/bincache/hello/static")
257+
/// `ghcr_path` is the repository path (e.g., "pkgforge/hello/static")
258258
/// `arch` is the target architecture (e.g., "x86_64-Linux")
259-
pub fn enrich_from_manifest(&mut self, manifest: &OciManifest, ghcr_path: &str, arch: &str) {
259+
/// `cache_type` is the cache type ("bincache" or "pkgcache")
260+
pub fn enrich_from_manifest(
261+
&mut self,
262+
manifest: &OciManifest,
263+
ghcr_path: &str,
264+
arch: &str,
265+
cache_type: &str,
266+
) {
260267
// Get embedded JSON if available
261268
if let Ok(Some(pkg_json)) = manifest.get_package_json() {
262269
self.merge_from_json(&pkg_json);
@@ -299,11 +306,6 @@ impl PackageMetadata {
299306

300307
// Generate GitHub Actions URL if we have a build ID
301308
if let Some(ref id) = build_id {
302-
let cache_type = if ghcr_path.contains("pkgcache") {
303-
"pkgcache"
304-
} else {
305-
"bincache"
306-
};
307309
self.build_gha = Some(format!(
308310
"https://github.com/pkgforge/{}/actions/runs/{}",
309311
cache_type, id

sbuild-meta/src/recipe.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl SBuildRecipe {
334334

335335
/// Get the GHCR package path for this recipe (simple version)
336336
pub fn ghcr_package(&self) -> String {
337-
format!("bincache/{}", self.pkg)
337+
self.pkg.clone()
338338
}
339339

340340
/// Extract unique package names from provides field
@@ -413,13 +413,13 @@ impl SBuildRecipe {
413413
// Sanitize package name for OCI compatibility (e.g., c++filt -> c-filt)
414414
let sanitized_pkg_name = sanitize_oci_name(&pkg_name);
415415
// Use custom ghcr_pkg if specified, otherwise auto-generate path
416-
// GHCR path: {owner}/{ghcr_pkg}/{pkg_name} or {owner}/{cache}/{pkg_family}/{recipe_name}/{pkg_name}
416+
// GHCR path: {owner}/{ghcr_pkg}/{pkg_name} or {owner}/{pkg_family}/{recipe_name}/{pkg_name}
417417
let ghcr_path = if let Some(ref custom_base) = self.ghcr_pkg {
418418
format!("{}/{}/{}", ghcr_owner, custom_base, sanitized_pkg_name)
419419
} else {
420420
format!(
421-
"{}/{}/{}/{}/{}",
422-
ghcr_owner, cache_type, pkg_family, recipe_name, sanitized_pkg_name
421+
"{}/{}/{}/{}",
422+
ghcr_owner, pkg_family, recipe_name, sanitized_pkg_name
423423
)
424424
};
425425

@@ -557,8 +557,8 @@ provides:
557557

558558
// bat==batcat means bat is the package, batcat is symlink - only 1 entry
559559
assert_eq!(packages.len(), 1);
560-
// GHCR path: {owner}/{cache}/{pkg_family}/{recipe_name}/{pkg_name}
561-
assert_eq!(packages[0].ghcr_path, "pkgforge/bincache/bat/static/bat");
560+
// GHCR path: {owner}/{pkg_family}/{recipe_name}/{pkg_name}
561+
assert_eq!(packages[0].ghcr_path, "pkgforge/bat/static/bat");
562562
assert_eq!(packages[0].pkg_name, "bat");
563563
assert_eq!(packages[0].recipe_name, "static");
564564
}
@@ -578,8 +578,8 @@ provides:
578578

579579
// Two separate packages - each with its own GHCR path
580580
assert_eq!(packages.len(), 2);
581-
assert_eq!(packages[0].ghcr_path, "pkgforge/bincache/myapp/static/app1");
582-
assert_eq!(packages[1].ghcr_path, "pkgforge/bincache/myapp/static/app2");
581+
assert_eq!(packages[0].ghcr_path, "pkgforge/myapp/static/app1");
582+
assert_eq!(packages[1].ghcr_path, "pkgforge/myapp/static/app2");
583583
}
584584

585585
#[test]
@@ -598,7 +598,7 @@ provides:
598598

599599
// All entries refer to busybox - should deduplicate to 1
600600
assert_eq!(packages.len(), 1);
601-
assert_eq!(packages[0].ghcr_path, "pkgforge/bincache/busybox/static/busybox");
601+
assert_eq!(packages[0].ghcr_path, "pkgforge/busybox/static/busybox");
602602
assert_eq!(packages[0].pkg_name, "busybox");
603603
}
604604

@@ -615,8 +615,8 @@ provides:
615615
let packages = recipe.ghcr_packages_from_path(path, "pkgforge");
616616

617617
assert_eq!(packages.len(), 1);
618-
// GHCR path: {owner}/{cache}/{pkg_family}/{recipe_name}/{pkg_name}
619-
assert_eq!(packages[0].ghcr_path, "pkgforge/pkgcache/0ad/appimage.0ad-matters.stable/0ad");
618+
// GHCR path: {owner}/{pkg_family}/{recipe_name}/{pkg_name}
619+
assert_eq!(packages[0].ghcr_path, "pkgforge/0ad/appimage.0ad-matters.stable/0ad");
620620
assert_eq!(packages[0].pkg_name, "0ad");
621621
assert_eq!(packages[0].cache_type, "pkgcache");
622622
assert_eq!(packages[0].recipe_name, "appimage.0ad-matters.stable");
@@ -698,10 +698,10 @@ provides:
698698

699699
assert_eq!(packages.len(), 2);
700700
// c++filt should be sanitized to cppfilt in the path
701-
assert_eq!(packages[0].ghcr_path, "pkgforge/bincache/binutils/static/cppfilt");
701+
assert_eq!(packages[0].ghcr_path, "pkgforge/binutils/static/cppfilt");
702702
assert_eq!(packages[0].pkg_name, "c++filt"); // Original name preserved
703703
// ld.gold is valid, no change
704-
assert_eq!(packages[1].ghcr_path, "pkgforge/bincache/binutils/static/ld.gold");
704+
assert_eq!(packages[1].ghcr_path, "pkgforge/binutils/static/ld.gold");
705705
assert_eq!(packages[1].pkg_name, "ld.gold");
706706
}
707707
}

0 commit comments

Comments
 (0)