@@ -2251,7 +2251,7 @@ def machine_or_name(self) -> str:
22512251 return self .machine or self .image
22522252
22532253 def output_dir_or_cwd (self ) -> Path :
2254- return self .output_dir or Path .cwd ()
2254+ return self .output_dir or finalize_configdir ( Path . cwd ()) or Path .cwd ()
22552255
22562256 def workspace_dir_or_default (self ) -> Path :
22572257 if self .workspace_dir :
@@ -5137,7 +5137,7 @@ def want_new_history(args: Args) -> bool:
51375137 return True
51385138
51395139
5140- def have_history (args : Args ) -> bool :
5140+ def have_history (args : Args , historydir : Path ) -> bool :
51415141 if want_new_history (args ):
51425142 return False
51435143
@@ -5159,7 +5159,7 @@ def have_history(args: Args) -> bool:
51595159 if args .verb == Verb .build and not args .rerun_build_scripts :
51605160 return False
51615161
5162- return Path ( ".mkosi-private/history/ latest.json" ).exists ()
5162+ return ( historydir / " latest.json" ).exists ()
51635163
51645164
51655165def finalize_default_tools (
@@ -5330,6 +5330,11 @@ def want_default_initrd(config: Config) -> bool:
53305330 return Path ("default" ) in config .initrds
53315331
53325332
5333+ def finalize_historydir (args : Args ) -> Path :
5334+ configdir = finalize_configdir (args .directory )
5335+ return (configdir or Path .cwd ()) / ".mkosi-private/history"
5336+
5337+
53335338def parse_config (
53345339 argv : Sequence [str ] = (),
53355340 * ,
@@ -5379,8 +5384,11 @@ def parse_config(
53795384 if not args .verb .needs_config ():
53805385 return args , None , ()
53815386
5382- if have_history (args ):
5383- history = Config .from_partial_json (Path (".mkosi-private/history/latest.json" ).read_text ())
5387+ configdir = finalize_configdir (args .directory )
5388+ historydir = finalize_historydir (args )
5389+
5390+ if have_history (args , historydir ):
5391+ history = Config .from_partial_json ((historydir / "latest.json" ).read_text ())
53845392
53855393 # If we're operating on a previously built image (vm, boot, shell, ...), we're not rebuilding the
53865394 # image and the configuration of the latest build is available, we load the config that was used to
@@ -5413,8 +5421,6 @@ def parse_config(
54135421
54145422 context .config ["files" ] = []
54155423
5416- configdir = finalize_configdir (args .directory )
5417-
54185424 if (
54195425 ((args .auto_bump and args .verb .needs_build ()) or args .verb == Verb .bump )
54205426 and context .cli .get ("image_version" ) is None
@@ -5432,8 +5438,8 @@ def parse_config(
54325438 maincontext = copy .deepcopy (context )
54335439
54345440 if config ["history" ] and want_new_history (args ):
5435- Path ( ".mkosi-private/history" ) .mkdir (parents = True , exist_ok = True )
5436- Path ( ".mkosi-private/history/ latest.json" ).write_text (dump_json (Config .to_partial_dict (cli )))
5441+ historydir .mkdir (parents = True , exist_ok = True )
5442+ ( historydir / " latest.json" ).write_text (dump_json (Config .to_partial_dict (cli )))
54375443
54385444 tools = None
54395445 if config .get ("tools_tree" ) in (Path ("default" ), Path ("yes" )):
0 commit comments