Skip to content

Commit 0c118cb

Browse files
authored
Merge pull request bootc-dev#673 from cgwalters/import-generic-prep
Import generic prep
2 parents 993a583 + 8e19d6e commit 0c118cb

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

lib/src/container/encapsulate.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub const LEGACY_VERSION_LABEL: &str = "version";
2727
/// The label which indicates where the ostree layers stop, and the
2828
/// derived ones start.
2929
pub const DIFFID_LABEL: &str = "ostree.final-diffid";
30+
/// The label for bootc.
31+
pub const BOOTC_LABEL: &str = "containers.bootc";
3032

3133
/// Annotation injected into the layer to say that this is an ostree commit.
3234
/// However, because this gets lost when converted to D2S2 https://docs.docker.com/registry/spec/manifest-v2-2/
@@ -68,7 +70,7 @@ fn commit_meta_to_labels<'a>(
6870
#[allow(clippy::explicit_auto_deref)]
6971
if let Some(v) = meta.lookup::<bool>(*ostree::METADATA_KEY_BOOTABLE)? {
7072
labels.insert(ostree::METADATA_KEY_BOOTABLE.to_string(), v.to_string());
71-
labels.insert("containers.bootc".into(), "1".into());
73+
labels.insert(BOOTC_LABEL.into(), "1".into());
7274
}
7375
// Handle any other string-typed values here.
7476
for k in &[&ostree::METADATA_KEY_LINUX] {

lib/src/container/store.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,9 @@ impl ImageImporter {
584584
let config_labels = super::labels_of(&config);
585585
if self.require_bootable {
586586
let bootable_key = *ostree::METADATA_KEY_BOOTABLE;
587-
let bootable = config_labels.map_or(false, |l| l.contains_key(bootable_key));
587+
let bootable = config_labels.map_or(false, |l| {
588+
l.contains_key(bootable_key) || l.contains_key(BOOTC_LABEL)
589+
});
588590
if !bootable {
589591
anyhow::bail!("Target image does not have {bootable_key} label");
590592
}

lib/src/tar/write.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,12 @@ fn normalize_validate_path<'a>(
182182
ret.push(camino::Utf8Component::CurDir);
183183
}
184184
let mut found_first = false;
185+
let mut excluded = false;
185186
for part in components {
186187
let part = part?;
188+
if excluded {
189+
return Ok(NormalizedPathResult::Filtered(part.as_str()));
190+
}
187191
if !found_first {
188192
if let Utf8Component::Normal(part) = part {
189193
found_first = true;
@@ -203,7 +207,10 @@ fn normalize_validate_path<'a>(
203207
}
204208
}
205209
o if EXCLUDED_TOPLEVEL_PATHS.contains(&o) => {
206-
return Ok(NormalizedPathResult::Filtered(part));
210+
// We don't want to actually drop the toplevel, but mark
211+
// *children* of it as excluded.
212+
excluded = true;
213+
ret.push(part)
207214
}
208215
_ if config.allow_nonusr => ret.push(part),
209216
_ => {
@@ -516,6 +523,8 @@ mod tests {
516523
("usr///share/.//blah", "./usr/share/blah"),
517524
("var/lib/blah", "./usr/share/factory/var/lib/blah"),
518525
("./var/lib/blah", "./usr/share/factory/var/lib/blah"),
526+
("dev", "./dev"),
527+
("/proc", "./proc"),
519528
("./", "."),
520529
];
521530
let valid_nonusr = &[("boot", "./boot"), ("opt/puppet/blah", "./opt/puppet/blah")];

lib/tests/it/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,9 @@ async fn test_tar_write() -> Result<()> {
395395
.run()?;
396396
assert_eq!(r.filtered.len(), 1);
397397
assert!(r.filtered.get("var").is_none());
398-
assert_eq!(*r.filtered.get("run").unwrap(), 2);
398+
// TODO: change filter_tar to properly make this run/somefile, but eh...we're
399+
// just going to accept this stuff in the future but ignore it anyways.
400+
assert_eq!(*r.filtered.get("somefile").unwrap(), 1);
399401

400402
Ok(())
401403
}

0 commit comments

Comments
 (0)