From d680bdc2703f732ec312f3ad5746b68198e6d3c7 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Thu, 15 Feb 2024 17:13:45 +0100 Subject: [PATCH] Also report distro detection disabling --- src/alire/alire-origins-deployers-system.adb | 16 ++++++++++++---- src/alire/alire-origins-deployers-system.ads | 7 +++++-- src/alire/alire-os_lib.ads | 3 ++- src/alr/alr-commands-version.adb | 20 ++++++++++++++++---- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/alire/alire-origins-deployers-system.adb b/src/alire/alire-origins-deployers-system.adb index 6eac279d8..08666780d 100644 --- a/src/alire/alire-origins-deployers-system.adb +++ b/src/alire/alire-origins-deployers-system.adb @@ -127,16 +127,24 @@ package body Alire.Origins.Deployers.System is end Dont_Ask_Permission; --------------------- - -- Executable_Path -- + -- Executable_Name -- --------------------- - function Executable_Path return Optional_Absolute_Path is + function Executable_Name return String is Make : constant Origin := New_System ("make"); -- We use a mock system package to be able to obtain a deployer. It -- doesn't matter if this system package doesn't exist. begin - return OS_Lib.Locate_Exec_On_Path - (Platform_Deployer (Make).Executable_Name); + return Platform_Deployer (Make).Executable_Name; + end Executable_Name; + + --------------------- + -- Executable_Path -- + --------------------- + + function Executable_Path return Optional_Absolute_Path is + begin + return OS_Lib.Locate_Exec_On_Path (Executable_Name); end Executable_Path; end Alire.Origins.Deployers.System; diff --git a/src/alire/alire-origins-deployers-system.ads b/src/alire/alire-origins-deployers-system.ads index 1367b9ed4..1f2877e5c 100644 --- a/src/alire/alire-origins-deployers-system.ads +++ b/src/alire/alire-origins-deployers-system.ads @@ -62,9 +62,12 @@ package Alire.Origins.Deployers.System is function Platform_Deployer (Package_Name : String) return Deployer'Class is (Platform_Deployer (Origins.New_System (Package_Name))); + function Executable_Name return String; + -- Returns the simple name of the executable package manager on the system + function Executable_Path return Optional_Absolute_Path; - -- Identifies the package manager executable being called in the current - -- platform, or "" if none found. + -- Identifies the full path to the package manager executable found in the + -- current platform, even if distro detection is disabled. private diff --git a/src/alire/alire-os_lib.ads b/src/alire/alire-os_lib.ads index 81f99d538..6d7d0f12f 100644 --- a/src/alire/alire-os_lib.ads +++ b/src/alire/alire-os_lib.ads @@ -17,6 +17,7 @@ package Alire.OS_Lib with Preelaborate is procedure Setenv (Name : String; Value : String); function Locate_Exec_On_Path (Exec_Name : String) return String; - -- Return the location of an executable if found on PATH, or "" otherwise + -- Return the location of an executable if found on PATH, or "" otherwise. + -- On Windows, no need to append ".exe" as it will be found without it. end Alire.OS_Lib; diff --git a/src/alr/alr-commands-version.adb b/src/alr/alr-commands-version.adb index 51c4cf9d5..4feba80ab 100644 --- a/src/alr/alr-commands-version.adb +++ b/src/alr/alr-commands-version.adb @@ -117,10 +117,22 @@ package body Alr.Commands.Version is end loop; end; - Table - .Append ("system package manager:") - .Append (Alire.Origins.Deployers.System.Executable_Path) - .New_Row; + declare + System_Manager : constant String := + Origins.Deployers.System.Executable_Path; + begin + Table + .Append ("system package manager:") + .Append (if System_Manager /= "" + then System_Manager + else "not found: `" + & Origins.Deployers.System.Executable_Name & "`") + .New_Row; + Table + .Append ("distro detection disabled:") + .Append (Platforms.Current.Disable_Distribution_Detection'Image) + .New_Row; + end; Table.Append ("").New_Row; Table.Append ("WORKSPACE").New_Row;