Skip to content

Commit 581488c

Browse files
committed
composefs-backend: Check for /var symlink before creating to fix issue with bootc switch on other distros.
Coauthored-by: Tulip Blossom <[email protected]> Signed-off-by: Kyle Gospodnetich <[email protected]>
1 parent a64ae89 commit 581488c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

crates/lib/src/bootc_composefs/state.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,16 @@ pub(crate) fn write_composefs_state(
123123

124124
let actual_var_path = root_path.join(SHARED_VAR_PATH);
125125
create_dir_all(&actual_var_path)?;
126-
127-
symlink(
128-
path_relative_to(state_path.as_std_path(), actual_var_path.as_std_path())
129-
.context("Getting var symlink path")?,
130-
state_path.join("var"),
131-
)
132-
.context("Failed to create symlink for /var")?;
126+
127+
let var_symlink_target = path_relative_to(state_path.as_std_path(), actual_var_path.as_std_path())
128+
.context("Getting var symlink path")?;
129+
130+
let var_symlink_path = state_path.join("var");
131+
132+
if !var_symlink_path.exists() {
133+
symlink(&var_symlink_target, &var_symlink_path)
134+
.context("Failed to create symlink for /var")?;
135+
}
133136

134137
let ImageReference {
135138
image: image_name,

0 commit comments

Comments
 (0)