Skip to content

Commit 3f9dc5e

Browse files
committed
fix snapshot and ghcr_pkg handling
1 parent cf97c6d commit 3f9dc5e

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

sbuild-linter/src/build_config/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub struct BuildConfig {
4646
pub src_url: Vec<String>,
4747
pub tag: Option<Vec<String>>,
4848
pub ghcr_pkg: Option<String>,
49+
pub snapshots: Option<Vec<String>>,
4950
pub x_exec: XExec,
5051
}
5152

@@ -230,6 +231,9 @@ impl BuildConfig {
230231
if let Some(val) = values.get("ghcr_pkg") {
231232
config.ghcr_pkg = val.as_str().map(String::from);
232233
}
234+
if let Some(val) = values.get("snapshots") {
235+
config.snapshots = to_string_vec(val);
236+
}
233237
config.x_exec = XExec::deserialize(values.get("x_exec").unwrap()).unwrap();
234238

235239
config
@@ -407,6 +411,14 @@ impl BuildConfig {
407411
}
408412
}
409413

414+
write_field_comments(writer, "snapshots")?;
415+
if let Some(ref snapshots) = self.snapshots {
416+
writeln!(writer, "{}snapshots:", indent_str)?;
417+
for s in snapshots {
418+
writeln!(writer, "{} - \"{}\"", indent_str, s)?;
419+
}
420+
}
421+
410422
write_field_comments(writer, "x_exec")?;
411423
writeln!(writer, "{}x_exec:", indent_str)?;
412424
self.x_exec.write_yaml(writer, indent + 2)?;

sbuild-linter/src/validator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,7 @@ pub const FIELD_VALIDATORS: &[FieldValidator] = &[
14191419
FieldValidator::new("src_url", FieldType::StringArray, true),
14201420
FieldValidator::new("tag", FieldType::StringArray, false),
14211421
FieldValidator::new("ghcr_pkg", FieldType::String, false),
1422+
FieldValidator::new("snapshots", FieldType::StringArray, false),
14221423
FieldValidator::new("x_exec", FieldType::XExec, true),
14231424
];
14241425

sbuild/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,10 @@ async fn post_build_processing(
661661
// Sanitize package name for OCI compatibility (e.g., c++filt -> c-filt)
662662
let sanitized_pkg_name = sanitize_oci_name(pkg_name_dir);
663663
// Use ghcr_pkg if specified, otherwise use auto-generated path
664+
// Extract owner from base_repo (first path component)
665+
let owner = base_repo.split('/').next().unwrap_or(base_repo);
664666
let full_repo = if let Some(ref custom_base) = metadata.ghcr_pkg {
665-
format!("{}/{}", custom_base, sanitized_pkg_name)
667+
format!("{}/{}/{}", owner, custom_base, sanitized_pkg_name)
666668
} else {
667669
format!("{}/{}/{}/{}", base_repo, pkg_family, recipe_name, sanitized_pkg_name)
668670
};
@@ -785,8 +787,10 @@ async fn post_build_processing(
785787
for binary_name in &binaries_to_push {
786788
// Sanitize binary name for OCI compatibility
787789
let sanitized_binary_name = sanitize_oci_name(binary_name);
790+
// Extract owner from base_repo (first path component)
791+
let owner = base_repo.split('/').next().unwrap_or(base_repo);
788792
let full_repo = if let Some(ref custom_base) = metadata.ghcr_pkg {
789-
format!("{}/{}", custom_base, sanitized_binary_name)
793+
format!("{}/{}/{}", owner, custom_base, sanitized_binary_name)
790794
} else {
791795
format!("{}/{}/{}/{}", base_repo, pkg_family, recipe_name, sanitized_binary_name)
792796
};

0 commit comments

Comments
 (0)