From f1fb4524d481ae4becb075b0bd22f1c9f1c56f2f Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 30 Jan 2024 09:53:34 -0500 Subject: [PATCH] composepost: Constantify `local-fs.target.requires` path Follow-up from #4728. --- rust/src/composepost.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rust/src/composepost.rs b/rust/src/composepost.rs index 5f2e3229e5..ed770f6176 100644 --- a/rust/src/composepost.rs +++ b/rust/src/composepost.rs @@ -54,6 +54,8 @@ pub(crate) const RPMOSTREE_RPMDB_LOCATION: &str = "usr/share/rpm"; const RPMOSTREE_SYSIMAGE_RPMDB: &str = "usr/lib/sysimage/rpm"; pub(crate) const TRADITIONAL_RPMDB_LOCATION: &str = "var/lib/rpm"; +const SD_LOCAL_FS_TARGET_REQUIRES: &str = "usr/lib/systemd/system/local-fs.target.requires"; + #[context("Moving {}", name)] fn dir_move_if_exists(src: &cap_std::fs::Dir, dest: &cap_std::fs::Dir, name: &str) -> Result<()> { if src.symlink_metadata(name).is_ok() { @@ -635,7 +637,7 @@ fn compose_postprocess_state_overlays(rootfs_dfd: &Dir) -> Result<()> { let mut db = cap_std::fs::DirBuilder::new(); db.recursive(true); db.mode(0o755); - let localfs_requires = Path::new("usr/lib/systemd/system/local-fs.target.requires"); + let localfs_requires = Path::new(SD_LOCAL_FS_TARGET_REQUIRES); rootfs_dfd.ensure_dir_with(localfs_requires, &db)?; const UNITS: &[&str] = &[ @@ -1013,9 +1015,8 @@ fn convert_path_to_tmpfiles_d_recurse( } fn state_overlay_enabled(rootfs_dfd: &cap_std::fs::Dir, state_overlay: &str) -> Result { - let linkname = format!( - "usr/lib/systemd/system/local-fs.target.requires/ostree-state-overlay@{state_overlay}.service" - ); + let linkname = + format!("{SD_LOCAL_FS_TARGET_REQUIRES}/ostree-state-overlay@{state_overlay}.service"); match rootfs_dfd.symlink_metadata_optional(&linkname)? { Some(meta) if meta.is_symlink() => Ok(true), Some(_) => Err(anyhow!("{linkname} is not a symlink")),