Compute the kernel arguments for the new deployment. This starts from the booted karg, but applies the diff between the bootc karg files in /usr/lib/bootc/kargs.d between the booted deployment and the new one.
(
sysroot: &Storage,
merge_deployment: &Deployment,
fetched: &ImageState,
)
| 198 | /// karg, but applies the diff between the bootc karg files in /usr/lib/bootc/kargs.d |
| 199 | /// between the booted deployment and the new one. |
| 200 | pub(crate) fn get_kargs( |
| 201 | sysroot: &Storage, |
| 202 | merge_deployment: &Deployment, |
| 203 | fetched: &ImageState, |
| 204 | ) -> Result<CmdlineOwned> { |
| 205 | let cancellable = gio::Cancellable::NONE; |
| 206 | let ostree = sysroot.get_ostree()?; |
| 207 | let repo = &ostree.repo(); |
| 208 | let sys_arch = std::env::consts::ARCH; |
| 209 | |
| 210 | // Get the kargs used for the merge in the bootloader config |
| 211 | let mut kargs = ostree::Deployment::bootconfig(merge_deployment) |
| 212 | .and_then(|bootconfig| { |
| 213 | ostree::BootconfigParser::get(&bootconfig, "options") |
| 214 | .map(|options| Cmdline::from(options.to_string())) |
| 215 | }) |
| 216 | .unwrap_or_default(); |
| 217 | |
| 218 | // Get the kargs in kargs.d of the merge |
| 219 | let merge_root = &crate::utils::deployment_fd(ostree, merge_deployment)?; |
| 220 | let existing_kargs = get_kargs_in_root(merge_root, sys_arch)?; |
| 221 | |
| 222 | // Get the kargs in kargs.d of the pending image |
| 223 | let (fetched_tree, _) = repo.read_commit(fetched.ostree_commit.as_str(), cancellable)?; |
| 224 | let fetched_tree = fetched_tree.resolve_relative_path(KARGS_PATH); |
| 225 | let fetched_tree = fetched_tree |
| 226 | .downcast::<ostree::RepoFile>() |
| 227 | .expect("downcast"); |
| 228 | // A special case: if there's no kargs.d directory in the pending (fetched) image, |
| 229 | // then we can just use the combined current kargs + kargs from booted |
| 230 | if !fetched_tree.query_exists(cancellable) { |
| 231 | kargs.extend(&existing_kargs); |
| 232 | return Ok(kargs); |
| 233 | } |
| 234 | |
| 235 | // Fetch the kernel arguments from the new root |
| 236 | let remote_kargs = get_kargs_from_ostree(repo, &fetched_tree, sys_arch)?; |
| 237 | |
| 238 | compute_apply_kargs_diff(&existing_kargs, &remote_kargs, &mut kargs); |
| 239 | |
| 240 | Ok(kargs) |
| 241 | } |
| 242 | |
| 243 | /// This parses a bootc kargs.d toml file, returning the resulting |
| 244 | /// vector of kernel arguments. Architecture matching is performed using |