1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 15:45:53 +01:00

ostree-ext: Squash some unused warnings

In some cases rust-analyzer seems to be building without the `bootc`
feature which triggers some unused variable warnings here.

Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
Colin Walters
2025-05-14 12:51:36 -04:00
parent 233e24bbb9
commit 9e1d9eb9d1
2 changed files with 10 additions and 6 deletions

View File

@@ -75,6 +75,7 @@ CLIPPY_CONFIG = -A clippy::all -D clippy::correctness -D clippy::suspicious -Dun
validate-rust: validate-rust:
cargo fmt -- --check -l cargo fmt -- --check -l
cargo test --no-run cargo test --no-run
(cd ostree-ext && cargo check --no-default-features)
(cd lib && cargo check --no-default-features) (cd lib && cargo check --no-default-features)
cargo clippy -- $(CLIPPY_CONFIG) cargo clippy -- $(CLIPPY_CONFIG)
env RUSTDOCFLAGS='-D warnings' cargo doc --lib env RUSTDOCFLAGS='-D warnings' cargo doc --lib

View File

@@ -1,14 +1,11 @@
//! Perform initial setup for a container image based system root //! Perform initial setup for a container image based system root
use std::collections::HashSet; use std::collections::HashSet;
#[cfg(feature = "bootc")]
use std::os::fd::BorrowedFd; use std::os::fd::BorrowedFd;
use std::process::Command;
use anyhow::Result; use anyhow::Result;
use bootc_utils::CommandRunExt;
use cap_std_ext::cmdext::CapStdExtCommandExt;
use fn_error_context::context; use fn_error_context::context;
use ocidir::cap_std::fs::Dir;
use ostree::glib; use ostree::glib;
use super::store::{gc_image_layers, LayeredImageState}; use super::store::{gc_image_layers, LayeredImageState};
@@ -58,6 +55,7 @@ pub struct DeployOpts<'a> {
// Access the file descriptor for a sysroot // Access the file descriptor for a sysroot
#[allow(unsafe_code)] #[allow(unsafe_code)]
#[cfg(feature = "bootc")]
pub(crate) fn sysroot_fd(sysroot: &ostree::Sysroot) -> BorrowedFd { pub(crate) fn sysroot_fd(sysroot: &ostree::Sysroot) -> BorrowedFd {
unsafe { BorrowedFd::borrow_raw(sysroot.fd()) } unsafe { BorrowedFd::borrow_raw(sysroot.fd()) }
} }
@@ -72,7 +70,6 @@ pub async fn deploy(
imgref: &OstreeImageReference, imgref: &OstreeImageReference,
options: Option<DeployOpts<'_>>, options: Option<DeployOpts<'_>>,
) -> Result<Box<LayeredImageState>> { ) -> Result<Box<LayeredImageState>> {
let sysroot_dir = &Dir::reopen_dir(&sysroot_fd(sysroot))?;
let cancellable = ostree::gio::Cancellable::NONE; let cancellable = ostree::gio::Cancellable::NONE;
let options = options.unwrap_or_default(); let options = options.unwrap_or_default();
let repo = &sysroot.repo(); let repo = &sysroot.repo();
@@ -147,9 +144,15 @@ pub async fn deploy(
// doesn't try to invoke this, as that won't work right now. // doesn't try to invoke this, as that won't work right now.
#[cfg(feature = "bootc")] #[cfg(feature = "bootc")]
if !options.skip_completion { if !options.skip_completion {
use bootc_utils::CommandRunExt;
use cap_std_ext::cmdext::CapStdExtCommandExt;
use ocidir::cap_std::fs::Dir;
let sysroot_dir = &Dir::reopen_dir(&sysroot_fd(sysroot))?;
// Note that the sysroot is provided as `.` but we use cwd_dir to // Note that the sysroot is provided as `.` but we use cwd_dir to
// make the process current working directory the sysroot. // make the process current working directory the sysroot.
let st = Command::new("/proc/self/exe") let st = std::process::Command::new("/proc/self/exe")
.args(["internals", "bootc-install-completion", ".", stateroot]) .args(["internals", "bootc-install-completion", ".", stateroot])
.cwd_dir(sysroot_dir.try_clone()?) .cwd_dir(sysroot_dir.try_clone()?)
.lifecycle_bind() .lifecycle_bind()