From: Benedict Schlueter Date: Fri, 23 Dec 2022 15:41:50 +0000 (+0100) Subject: fix invalid cross-device link X-Git-Tag: v15~376 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=031fc4a3398e871f8292c760418a541df81f78c3;p=thirdparty%2Fmkosi.git fix invalid cross-device link when the workspace directory is on another filesystem (i.e. /tmp) mkosi fails. replace os.rename with shutil.move when we may cross filesystem boundaries. Furthermore, chown the resulting files if the flag is set accordingly. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index d6db0362f..6a702f049 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3867,12 +3867,14 @@ def build_stuff(config: MkosiConfig) -> None: for p in state.config.output_paths(): if state.staging.joinpath(p.name).exists(): - os.rename(str(state.staging / p.name), str(p)) + shutil.move(str(state.staging / p.name), str(p)) if p in (state.config.output, state.config.output_split_kernel): compress_output(state.config, p) + if state.config.chown and p.exists(): + chown_to_running_user(p) for p in state.staging.iterdir(): - os.rename(str(p), str(state.config.output.parent / p.name)) + shutil.move(str(p), str(state.config.output.parent / p.name)) if p.name.startswith(state.config.output.name): compress_output(state.config, p)