From 4c26ae4da7f41d10188cfa61837da000b2716afe Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 12 Dec 2024 16:54:10 -0500 Subject: [PATCH] Update to 1.1.3 Also add BR skopeo, ostree for tests Related: #RHEL-66200 Signed-off-by: Colin Walters --- .gitignore | 2 + ...de-Use-cap-std-ext-is_mountpoint-API.patch | 132 ++++++++++++++++++ bootc.spec | 8 +- sources | 4 +- 4 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 0001-tree-wide-Use-cap-std-ext-is_mountpoint-API.patch diff --git a/.gitignore b/.gitignore index f2055cf..f377c75 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ /bootc-1.1.0-vendor.tar.zstd /bootc-1.1.2.tar.zstd /bootc-1.1.2-vendor.tar.zstd +/bootc-1.1.3-vendor.tar.zstd +/bootc-1.1.3.tar.zstd diff --git a/0001-tree-wide-Use-cap-std-ext-is_mountpoint-API.patch b/0001-tree-wide-Use-cap-std-ext-is_mountpoint-API.patch new file mode 100644 index 0000000..9cd7ad5 --- /dev/null +++ b/0001-tree-wide-Use-cap-std-ext-is_mountpoint-API.patch @@ -0,0 +1,132 @@ +From 5013d45effbbb9c6ca0a6405fca894c8dc06e767 Mon Sep 17 00:00:00 2001 +From: Colin Walters +Date: Fri, 20 Dec 2024 09:27:30 -0500 +Subject: [PATCH] tree-wide: Use cap-std-ext is_mountpoint() API + +I moved it there a while ago, now we can drop the copy of it +here. + +Signed-off-by: Colin Walters +--- + lib/src/install.rs | 2 +- + ostree-ext/src/commit.rs | 3 +- + ostree-ext/src/lib.rs | 1 - + ostree-ext/src/mountutil.rs | 60 ------------------------------------- + 4 files changed, 2 insertions(+), 64 deletions(-) + delete mode 100644 ostree-ext/src/mountutil.rs + +diff --git a/lib/src/install.rs b/lib/src/install.rs +index 5929e4cd..d591672b 100644 +--- a/lib/src/install.rs ++++ b/lib/src/install.rs +@@ -1711,7 +1711,7 @@ pub(crate) async fn install_to_filesystem( + + tracing::debug!("Root filesystem: {root_path}"); + +- if let Some(false) = ostree_ext::mountutil::is_mountpoint(&rootfs_fd, ".")? { ++ if let Some(false) = rootfs_fd.is_mountpoint(".")? { + anyhow::bail!("Not a mountpoint: {root_path}"); + } + rootfs_fd +diff --git a/ostree-ext/src/commit.rs b/ostree-ext/src/commit.rs +index babe9017..31571d1e 100644 +--- a/ostree-ext/src/commit.rs ++++ b/ostree-ext/src/commit.rs +@@ -3,7 +3,6 @@ + //! + + use crate::container_utils::require_ostree_container; +-use crate::mountutil::is_mountpoint; + use anyhow::Context; + use anyhow::Result; + use cap_std::fs::Dir; +@@ -60,7 +59,7 @@ fn clean_subdir(root: &Dir, rootdev: u64) -> Result<()> { + } + // Also ignore bind mounts, if we have a new enough kernel with statx() + // that will tell us. +- if is_mountpoint(root, &path)?.unwrap_or_default() { ++ if root.is_mountpoint(&path)?.unwrap_or_default() { + tracing::trace!("Skipping mount point {path:?}"); + continue; + } +diff --git a/ostree-ext/src/lib.rs b/ostree-ext/src/lib.rs +index b962c8d6..97ec80de 100644 +--- a/ostree-ext/src/lib.rs ++++ b/ostree-ext/src/lib.rs +@@ -39,7 +39,6 @@ pub mod diff; + pub mod ima; + pub mod keyfileext; + pub(crate) mod logging; +-pub mod mountutil; + pub mod ostree_prepareroot; + pub mod refescape; + #[doc(hidden)] +diff --git a/ostree-ext/src/mountutil.rs b/ostree-ext/src/mountutil.rs +deleted file mode 100644 +index f73cbba2..00000000 +--- a/ostree-ext/src/mountutil.rs ++++ /dev/null +@@ -1,60 +0,0 @@ +-//! Helpers for interacting with mounts. +- +-use std::os::fd::AsFd; +-use std::path::Path; +- +-use anyhow::Result; +-use cap_std::fs::Dir; +-use cap_std_ext::cap_std; +- +-// Fix musl support +-#[cfg(target_env = "gnu")] +-use libc::STATX_ATTR_MOUNT_ROOT; +-#[cfg(target_env = "musl")] +-const STATX_ATTR_MOUNT_ROOT: libc::c_int = 0x2000; +- +-fn is_mountpoint_impl_statx(root: &Dir, path: &Path) -> Result> { +- // https://github.com/systemd/systemd/blob/8fbf0a214e2fe474655b17a4b663122943b55db0/src/basic/mountpoint-util.c#L176 +- use rustix::fs::{AtFlags, StatxFlags}; +- +- // SAFETY(unwrap): We can infallibly convert an i32 into a u64. +- let mountroot_flag: u64 = STATX_ATTR_MOUNT_ROOT.try_into().unwrap(); +- match rustix::fs::statx( +- root.as_fd(), +- path, +- AtFlags::NO_AUTOMOUNT | AtFlags::SYMLINK_NOFOLLOW, +- StatxFlags::empty(), +- ) { +- Ok(r) => { +- let present = (r.stx_attributes_mask & mountroot_flag) > 0; +- Ok(present.then_some(r.stx_attributes & mountroot_flag > 0)) +- } +- Err(e) if e == rustix::io::Errno::NOSYS => Ok(None), +- Err(e) => Err(e.into()), +- } +-} +- +-/// Try to (heuristically) determine if the provided path is a mount root. +-pub fn is_mountpoint(root: &Dir, path: impl AsRef) -> Result> { +- is_mountpoint_impl_statx(root, path.as_ref()) +-} +- +-#[cfg(test)] +-mod tests { +- use super::*; +- use cap_std_ext::cap_tempfile; +- +- #[test] +- fn test_is_mountpoint() -> Result<()> { +- let root = cap_std::fs::Dir::open_ambient_dir("/", cap_std::ambient_authority())?; +- let supported = is_mountpoint(&root, Path::new("/")).unwrap(); +- match supported { +- Some(r) => assert!(r), +- // If the host doesn't support statx, ignore this for now +- None => return Ok(()), +- } +- let tmpdir = cap_tempfile::TempDir::new(cap_std::ambient_authority())?; +- assert!(!is_mountpoint(&tmpdir, Path::new(".")).unwrap().unwrap()); +- Ok(()) +- } +-} +-- +2.47.0 + diff --git a/bootc.spec b/bootc.spec index d650189..d953553 100644 --- a/bootc.spec +++ b/bootc.spec @@ -2,7 +2,7 @@ %bcond_with ostree_ext Name: bootc -Version: 1.1.2 +Version: 1.1.3 Release: %{autorelease} Summary: Bootable container system @@ -19,6 +19,10 @@ URL: https://github.com/containers/bootc Source0: %{url}/releases/download/v%{version}/bootc-%{version}.tar.zstd Source1: %{url}/releases/download/v%{version}/bootc-%{version}-vendor.tar.zstd +# Because old mock doesn't have / be a mountpoint, and this breaks +# a test case. +Patch0: 0001-tree-wide-Use-cap-std-ext-is_mountpoint-API.patch + # https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval ExcludeArch: %{ix86} @@ -32,6 +36,8 @@ BuildRequires: rust-toolset BuildRequires: cargo-rpm-macros >= 25 %endif BuildRequires: systemd +# For tests +BuildRequires: skopeo ostree # Backing storage tooling https://github.com/containers/composefs/issues/125 Requires: composefs diff --git a/sources b/sources index 708f097..98fd378 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (bootc-1.1.2.tar.zstd) = 56d96521d848fd2897f9288122e0104e7ee4e3e6b9307f627491ed810c634f5aee42b5b18630dba31b32eaa211dd4509afbc70832a69fd5094d2aceb41009c74 -SHA512 (bootc-1.1.2-vendor.tar.zstd) = a563dbbdcdd6cb36fd5c6a262447c34d16a2308efbdb8e2b8bfd7cb01032552b582c13a0ccdd8f3908ab60c3293da4f59ab1335ff40bbac7aa076ebad8e73270 +SHA512 (bootc-1.1.3-vendor.tar.zstd) = 40666f9da2ff59a85446f7137da5be5704537a82d80c581bceeec1714176ef2edccf0800ce03a5f2689d083c66686cc31973c33ef0db96ee9439492a6b563b0e +SHA512 (bootc-1.1.3.tar.zstd) = cf19102897f3f9736fe5979ff1e3be486f8d9d5e8de9f14d00555ad333f3acb61dbf3184d9453ad92cd5ac58da4384f8eef5bde16d5bdbfc83e17443c757330b