diff --git a/lib/src/chunking.rs b/lib/src/chunking.rs index 3d41fdf1..8b9ad4c9 100644 --- a/lib/src/chunking.rs +++ b/lib/src/chunking.rs @@ -30,6 +30,7 @@ pub(crate) struct Chunk { pub(crate) name: String, pub(crate) content: ChunkMapping, pub(crate) size: u64, + pub(crate) packages: Vec, } #[derive(Debug, Deserialize, Serialize)] @@ -312,6 +313,7 @@ impl Chunking { n => Cow::Owned(format!("{n} components")), }; let mut chunk = Chunk::new(&*name); + chunk.packages = bin.iter().map(|v| String::from(&*v.meta.name)).collect(); for szmeta in bin { for &obj in rmap.get(&szmeta.meta.identifier).unwrap() { self.remainder.move_obj(&mut chunk, obj.as_str()); diff --git a/lib/src/container/encapsulate.rs b/lib/src/container/encapsulate.rs index b1cdd319..b193daaa 100644 --- a/lib/src/container/encapsulate.rs +++ b/lib/src/container/encapsulate.rs @@ -102,7 +102,7 @@ fn export_chunks( ociw: &mut OciDir, chunks: Vec, opts: &ExportOpts, -) -> Result> { +) -> Result)>> { chunks .into_iter() .enumerate() @@ -111,7 +111,7 @@ fn export_chunks( ostree_tar::export_chunk(repo, commit, chunk.content, &mut w) .with_context(|| format!("Exporting chunk {i}"))?; let w = w.into_inner()?; - Ok((w.complete()?, chunk.name)) + Ok((w.complete()?, chunk.name, chunk.packages)) }) .collect() } @@ -155,10 +155,26 @@ fn export_chunked( .clone(); // Add the ostree layer - ociw.push_layer(manifest, imgcfg, ostree_layer, description); + let mut annotation_ostree_layer = HashMap::new(); + annotation_ostree_layer.insert("Content".to_string(), "ostree_commit".to_string()); + ociw.push_layer( + manifest, + imgcfg, + ostree_layer, + description, + Some(annotation_ostree_layer), + ); // Add the component/content layers - for (layer, name) in layers { - ociw.push_layer(manifest, imgcfg, layer, name.as_str()); + for (layer, name, packages) in layers { + let mut annotation_component_layer = HashMap::new(); + annotation_component_layer.insert("Content".to_string(), packages.join(",")); + ociw.push_layer( + manifest, + imgcfg, + layer, + name.as_str(), + Some(annotation_component_layer), + ); } // This label (mentioned above) points to the last layer that is part of // the ostree commit. diff --git a/lib/src/container/ocidir.rs b/lib/src/container/ocidir.rs index 7ba759d6..a4a91338 100644 --- a/lib/src/container/ocidir.rs +++ b/lib/src/container/ocidir.rs @@ -202,8 +202,8 @@ impl OciDir { config: &mut oci_image::ImageConfiguration, layer: Layer, description: &str, + annotations: Option>, ) { - let annotations: Option> = None; self.push_layer_annotated(manifest, config, layer, annotations, description); }