(opts: InstallResetOpts)
| 2809 | } |
| 2810 | |
| 2811 | pub(crate) async fn install_reset(opts: InstallResetOpts) -> Result<()> { |
| 2812 | let rootfs = &Dir::open_ambient_dir("/", cap_std::ambient_authority())?; |
| 2813 | if !opts.experimental { |
| 2814 | anyhow::bail!("This command requires --experimental"); |
| 2815 | } |
| 2816 | |
| 2817 | let prog: ProgressWriter = opts.progress.try_into()?; |
| 2818 | |
| 2819 | let sysroot = &crate::cli::get_storage().await?; |
| 2820 | let ostree = sysroot.get_ostree()?; |
| 2821 | let repo = &ostree.repo(); |
| 2822 | let (booted_ostree, _deployments, host) = crate::status::get_status_require_booted(ostree)?; |
| 2823 | |
| 2824 | let stateroots = list_stateroots(ostree)?; |
| 2825 | let target_stateroot = if let Some(s) = opts.stateroot { |
| 2826 | s |
| 2827 | } else { |
| 2828 | let now = chrono::Utc::now(); |
| 2829 | let r = allocate_new_stateroot(&ostree, &stateroots, now)?; |
| 2830 | r.name |
| 2831 | }; |
| 2832 | |
| 2833 | let booted_stateroot = booted_ostree.stateroot(); |
| 2834 | assert!(booted_stateroot.as_str() != target_stateroot); |
| 2835 | let (fetched, spec) = if let Some(target) = opts.target_opts.imageref()? { |
| 2836 | let mut new_spec = host.spec; |
| 2837 | new_spec.image = Some(target.into()); |
| 2838 | let fetched = crate::deploy::pull( |
| 2839 | repo, |
| 2840 | &new_spec.image.as_ref().unwrap(), |
| 2841 | None, |
| 2842 | opts.quiet, |
| 2843 | prog.clone(), |
| 2844 | None, |
| 2845 | ) |
| 2846 | .await?; |
| 2847 | (fetched, new_spec) |
| 2848 | } else { |
| 2849 | let imgstate = host |
| 2850 | .status |
| 2851 | .booted |
| 2852 | .map(|b| b.query_image(repo)) |
| 2853 | .transpose()? |
| 2854 | .flatten() |
| 2855 | .ok_or_else(|| anyhow::anyhow!("No image source specified"))?; |
| 2856 | (Box::new((*imgstate).into()), host.spec) |
| 2857 | }; |
| 2858 | let spec = crate::deploy::RequiredHostSpec::from_spec(&spec)?; |
| 2859 | |
| 2860 | // Compute the kernel arguments to inherit. By default, that's only those involved |
| 2861 | // in the root filesystem. |
| 2862 | let mut kargs = crate::bootc_kargs::get_kargs_in_root(rootfs, std::env::consts::ARCH)?; |
| 2863 | |
| 2864 | // Extend with root kargs |
| 2865 | if !opts.no_root_kargs { |
| 2866 | let bootcfg = booted_ostree |
| 2867 | .deployment |
| 2868 | .bootconfig() |
no test coverage detected