Skip to content

Commit

Permalink
Merge pull request #549 from cgwalters/minor-install
Browse files Browse the repository at this point in the history
install: A few minor patches
  • Loading branch information
jeckersb authored May 21, 2024
2 parents c69e132 + 88283c5 commit 559aca7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/src/bootloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ pub(crate) fn install_via_bootupd(
.chain(verbose)
.chain(bootupd_opts.iter().copied().flatten())
.chain([
"--src-root",
"/",
"--device",
device.as_str(),
rootfs.as_str(),
]);
Task::new_and_run("Running bootupctl to install bootloader", "bootupctl", args)
Task::new("Running bootupctl to install bootloader", "bootupctl")
.args(args)
.verbose()
.run()
}
9 changes: 5 additions & 4 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,11 @@ async fn initialize_ostree_root_from_self(
options.kargs = Some(kargs.as_slice());
options.target_imgref = Some(&state.target_imgref);
options.proxy_cfg = proxy_cfg;
println!("Deploying container image");
let imgstate =
ostree_container::deploy::deploy(&sysroot, stateroot, &src_imageref, Some(options)).await?;
println!("Deployment complete");
let imgstate = crate::utils::async_task_with_spinner(
"Deploying container image",
ostree_container::deploy::deploy(&sysroot, stateroot, &src_imageref, Some(options)),
)
.await?;

sysroot.load(cancellable)?;
let deployment = sysroot
Expand Down
1 change: 1 addition & 0 deletions lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ pub(crate) fn install_create_rootfs(
let espdev = &findpart(esp_partno)?;
Task::new("Creating ESP filesystem", "mkfs.fat")
.args([espdev.as_str(), "-n", "EFI-SYSTEM"])
.verbose()
.quiet_output()
.run()?;
let efifs_path = bootfs.join(crate::bootloader::EFI_DIR);
Expand Down
32 changes: 32 additions & 0 deletions lib/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::future::Future;
use std::io::Write;
use std::process::Command;
use std::time::Duration;

use anyhow::{Context, Result};
use ostree::glib;
Expand Down Expand Up @@ -87,6 +90,35 @@ pub(crate) fn medium_visibility_warning(s: &str) {
std::thread::sleep(std::time::Duration::from_secs(1));
}

/// Call an async task function, and write a message to stdout
/// with an automatic spinner to show that we're not blocked.
/// Note that generally the called function should not output
/// anything to stdout as this will interfere with the spinner.
pub(crate) async fn async_task_with_spinner<F, T>(msg: &'static str, f: F) -> T
where
F: Future<Output = T>,
{
let pb = indicatif::ProgressBar::new_spinner();
let style = indicatif::ProgressStyle::default_bar();
pb.set_style(style.template("{spinner} {msg}").unwrap());
pb.set_message(msg);
pb.enable_steady_tick(Duration::from_millis(150));
// We need to handle the case where we aren't connected to
// a tty, so indicatif would show nothing by default.
if pb.is_hidden() {
print!("{}...", msg);
std::io::stdout().flush().unwrap();
} else {
}
let r = f.await;
if pb.is_hidden() {
println!("done");
} else {
pb.finish_with_message(format!("{msg}: done"));
}
r
}

/// Given a possibly tagged image like quay.io/foo/bar:latest and a digest 0ab32..., return
/// the digested form quay.io/foo/bar:latest@sha256:0ab32...
/// If the image already has a digest, it will be replaced.
Expand Down

0 comments on commit 559aca7

Please sign in to comment.