From 8996b85ec3b6b474171fd6a1015b75f5de71e4ab Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Wed, 28 Feb 2024 19:21:38 +0100 Subject: [PATCH] Make msys live inside overridden config path by default (#1589) * Don't run OS initialization during elaboration As this makes impossible to tweak such initialization with `alr config`. * Make msys live inside overriden config path by default * Better explanation in alr.py * Fix config loading before Windows builtins --- src/alire/alire-config-edit-early_load.adb | 2 ++ src/alire/alire-config-edit-early_load.ads | 2 +- src/alire/alire-platforms-folders.ads | 4 ++++ .../os_windows/alire-config-builtins-windows.ads | 6 ++++-- testsuite/drivers/alr.py | 11 +++++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/alire/alire-config-edit-early_load.adb b/src/alire/alire-config-edit-early_load.adb index 039df26f0..e0df70e51 100644 --- a/src/alire/alire-config-edit-early_load.adb +++ b/src/alire/alire-config-edit-early_load.adb @@ -9,4 +9,6 @@ package body Alire.Config.Edit.Early_Load is Alire.Config.Edit.Load_Config; end Load_Config; +begin + Load_Config; end Alire.Config.Edit.Early_Load; diff --git a/src/alire/alire-config-edit-early_load.ads b/src/alire/alire-config-edit-early_load.ads index fbb8af507..73656602e 100644 --- a/src/alire/alire-config-edit-early_load.ads +++ b/src/alire/alire-config-edit-early_load.ads @@ -1,4 +1,4 @@ -package Alire.Config.Edit.Early_Load is +package Alire.Config.Edit.Early_Load with Elaborate_Body is procedure Load_Config; -- For internal use of Alire_Early_Elaboration, DO NOT CALL otherwise. diff --git a/src/alire/alire-platforms-folders.ads b/src/alire/alire-platforms-folders.ads index 768313865..456866be4 100644 --- a/src/alire/alire-platforms-folders.ads +++ b/src/alire/alire-platforms-folders.ads @@ -2,6 +2,10 @@ package Alire.Platforms.Folders is -- This spec must be fulfilled by bodies for each different OS we support + -- IMPORTANT NOTE: these are not intended to be used directly in most + -- cases; instead, use the ones in Alire.Config.Edit that take into + -- account user overriding of the config location. + function Config return Absolute_Path; -- Folder where alire will store its global configuration, indexes, and -- any other global data. Deleting it is akin to running alr afresh for diff --git a/src/alire/os_windows/alire-config-builtins-windows.ads b/src/alire/os_windows/alire-config-builtins-windows.ads index c787506f2..ef3d2b422 100644 --- a/src/alire/os_windows/alire-config-builtins-windows.ads +++ b/src/alire/os_windows/alire-config-builtins-windows.ads @@ -1,4 +1,6 @@ -with Alire.Platforms.Folders; +-- Ensure config is loaded for some defaults below +with Alire.Config.Edit.Early_Load; +pragma Unreferenced (Alire.Config.Edit.Early_Load); package Alire.Config.Builtins.Windows is @@ -19,7 +21,7 @@ package Alire.Config.Builtins.Windows is Msys2_Install_Dir : constant Builtin := New_Builtin (Key => "msys2.install_dir", Kind => Cfg_Absolute_Path, - Def => Platforms.Folders.Cache / "msys64", + Def => Config.Edit.Cache_Path / "msys64", Help => "Directory where Alire will detect and/or install" & " msys2 system package manager. (Windows only)"); diff --git a/testsuite/drivers/alr.py b/testsuite/drivers/alr.py index 7afcc207b..a4d0c5fdf 100644 --- a/testsuite/drivers/alr.py +++ b/testsuite/drivers/alr.py @@ -47,6 +47,17 @@ def prepare_env(config_dir, env): # We pass config location explicitly in the following calls since env is # not yet applied (it's just a dict to be passed later to subprocess) + if platform.system() == "Windows": + # Disable msys inadvertent installation + run_alr("-c", config_dir, "config", "--global", + "--set", "msys2.do_not_install", "true") + + # And configure the one set up in the environment so it is used by + # tests that need it. + run_alr("-c", config_dir, "config", "--global", + "--set", "msys2.install_dir", + os.path.join(os.environ.get("LocalAppData"), "alire", "msys64")) + # Disable autoconfig of the community index, to prevent unintended use of # it in tests, besides the overload of fetching it run_alr("-c", config_dir, "config", "--global",