Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Move /var content to /usr/share/factory/var #569

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/src/tar/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,17 @@ fn normalize_validate_path(path: &Utf8Path) -> Result<NormalizedPathResult<'_>>
if !found_first {
if let Utf8Component::Normal(part) = part {
found_first = true;
// Now, rewrite /etc -> /usr/etc, and discard everything not in /usr.
match part {
// We expect all the OS content to live in usr in general
"usr" => ret.push(part),
// ostree has special support for /etc
"etc" => {
ret.push("usr/etc");
}
// Content in /var will get copied by a systemd tmpfiles.d unit
"var" => {
ret.push("usr/share/factory/var");
}
o => return Ok(NormalizedPathResult::Filtered(o)),
}
} else {
Expand Down Expand Up @@ -401,6 +406,8 @@ mod tests {
("usr/bin/blah", "./usr/bin/blah"),
("usr///share/.//blah", "./usr/share/blah"),
("./", "."),
("var/lib/blah", "./usr/share/factory/var/lib/blah"),
("./var/lib/blah", "./usr/share/factory/var/lib/blah"),
];
for &(k, v) in valid {
let r = normalize_validate_path(k.into()).unwrap();
Expand All @@ -413,11 +420,7 @@ mod tests {
}
}
}
let filtered = &[
("/boot/vmlinuz", "boot"),
("var/lib/blah", "var"),
("./var/lib/blah", "var"),
];
let filtered = &[("/boot/vmlinuz", "boot")];
for &(k, v) in filtered {
match normalize_validate_path(k.into()).unwrap() {
NormalizedPathResult::Filtered(f) => {
Expand Down
6 changes: 3 additions & 3 deletions lib/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ async fn test_tar_write() -> Result<()> {
)
.ignore_stdout()
.run()?;
assert_eq!(r.filtered.len(), 2);
assert_eq!(*r.filtered.get("var").unwrap(), 4);
assert_eq!(r.filtered.len(), 1);
assert!(r.filtered.get("var").is_none());
assert_eq!(*r.filtered.get("boot").unwrap(), 1);

Ok(())
Expand Down Expand Up @@ -943,7 +943,7 @@ async fn test_container_var_content() -> Result<()> {
assert!(
store::image_filtered_content_warning(fixture.destrepo(), &derived_imgref.imgref)
.unwrap()
.is_some()
.is_none()
);

Ok(())
Expand Down
Loading