Skip to content

Commit 5498363

Browse files
committed
reinstall: Pull podman image early
This splits the `podman pull <image>` and the `podman ... bootc install to-existing` command to prepare for future features that will require inspecting the image before constructing the bootc install command. Signed-off-by: ckyrouac <[email protected]>
1 parent b26d5ca commit 5498363

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

system-reinstall-bootc/src/main.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ fn run() -> Result<()> {
2020

2121
let config = config::ReinstallConfig::load().context("loading config")?;
2222

23+
podman::ensure_podman_installed()?;
24+
25+
//pull image early so it can be inspected, e.g. to check for cloud-init
26+
let mut pull_image_command = podman::pull_image_command(&config.bootc_image);
27+
pull_image_command
28+
.run_with_cmd_context()
29+
.context(format!("pulling image {}", &config.bootc_image))?;
30+
31+
println!();
32+
2333
let ssh_key_file = tempfile::NamedTempFile::new()?;
2434
let ssh_key_file_path = ssh_key_file
2535
.path()
@@ -30,18 +40,14 @@ fn run() -> Result<()> {
3040

3141
prompt::get_ssh_keys(ssh_key_file_path)?;
3242

33-
let mut reinstall_podman_command = podman::command(&config.bootc_image, ssh_key_file_path);
43+
let mut reinstall_podman_command =
44+
podman::reinstall_command(&config.bootc_image, ssh_key_file_path);
3445

3546
println!();
36-
3747
println!("Going to run command {:?}", reinstall_podman_command);
3848

3949
prompt::temporary_developer_protection_prompt()?;
4050

41-
// At this poihnt, the user has already given us permission to reinstall their system, so we
42-
// feel confident with just installing podman without any further user interaction.
43-
podman::ensure_podman_installed()?;
44-
4551
reinstall_podman_command
4652
.run_with_cmd_context()
4753
.context("running reinstall command")?;

system-reinstall-bootc/src/podman.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bootc_utils::CommandRunExt;
44
use std::process::Command;
55
use which::which;
66

7-
pub(crate) fn command(image: &str, ssh_key_file: &str) -> Command {
7+
pub(crate) fn reinstall_command(image: &str, ssh_key_file: &str) -> Command {
88
let mut podman_command_and_args = [
99
// We use podman to run the bootc container. This might change in the future to remove the
1010
// podman dependency.
@@ -62,6 +62,12 @@ pub(crate) fn command(image: &str, ssh_key_file: &str) -> Command {
6262
command
6363
}
6464

65+
pub(crate) fn pull_image_command(image: &str) -> Command {
66+
let mut command = Command::new("podman");
67+
command.args(["pull", image]);
68+
command
69+
}
70+
6571
/// Path to the podman installation script. Can be influenced by the build
6672
/// SYSTEM_REINSTALL_BOOTC_INSTALL_PODMAN_PATH parameter to override. Defaults
6773
/// to /usr/lib/system-reinstall-bootc/install-podman

0 commit comments

Comments
 (0)