diff --git a/src/alire/alire-origins-deployers-system-apt.ads b/src/alire/alire-origins-deployers-system-apt.ads index 613762d0d..3f382dd7a 100644 --- a/src/alire/alire-origins-deployers-system-apt.ads +++ b/src/alire/alire-origins-deployers-system-apt.ads @@ -12,4 +12,7 @@ package Alire.Origins.Deployers.System.Apt is overriding function Install (This : Deployer) return Outcome; + overriding + function Executable_Name (This : Deployer) return String is ("apt"); + end Alire.Origins.Deployers.System.Apt; diff --git a/src/alire/alire-origins-deployers-system-homebrew.ads b/src/alire/alire-origins-deployers-system-homebrew.ads index 2cff8fae2..2a7ca44da 100644 --- a/src/alire/alire-origins-deployers-system-homebrew.ads +++ b/src/alire/alire-origins-deployers-system-homebrew.ads @@ -12,4 +12,7 @@ package Alire.Origins.Deployers.System.Homebrew is overriding function Install (This : Deployer) return Outcome; + overriding + function Executable_Name (This : Deployer) return String is ("brew"); + end Alire.Origins.Deployers.System.Homebrew; diff --git a/src/alire/alire-origins-deployers-system-macports.ads b/src/alire/alire-origins-deployers-system-macports.ads index 7c7fc92d3..ad9c50cb9 100644 --- a/src/alire/alire-origins-deployers-system-macports.ads +++ b/src/alire/alire-origins-deployers-system-macports.ads @@ -12,4 +12,7 @@ package Alire.Origins.Deployers.System.Macports is overriding function Install (This : Deployer) return Outcome; + overriding + function Executable_Name (This : Deployer) return String is ("port"); + end Alire.Origins.Deployers.System.Macports; diff --git a/src/alire/alire-origins-deployers-system-pacman.ads b/src/alire/alire-origins-deployers-system-pacman.ads index d2fed362a..273df11dd 100644 --- a/src/alire/alire-origins-deployers-system-pacman.ads +++ b/src/alire/alire-origins-deployers-system-pacman.ads @@ -12,4 +12,7 @@ package Alire.Origins.Deployers.System.Pacman is overriding function Install (This : Deployer) return Outcome; + overriding + function Executable_Name (This : Deployer) return String is ("pacman"); + end Alire.Origins.Deployers.System.Pacman; diff --git a/src/alire/alire-origins-deployers-system-rpm_wrappers.adb b/src/alire/alire-origins-deployers-system-rpm_wrappers.adb index 9c615ed56..3ab389a9c 100644 --- a/src/alire/alire-origins-deployers-system-rpm_wrappers.adb +++ b/src/alire/alire-origins-deployers-system-rpm_wrappers.adb @@ -18,6 +18,14 @@ package body Alire.Origins.Deployers.System.RPM_Wrappers is when Dnf => "dnf", when Yum => "yum"); + --------------------- + -- Executable_Name -- + --------------------- + + overriding + function Executable_Name (This : Deployer) return String + is (This.Wrapper_Command); + ------------------------------ -- Package_Name_With_Archit -- ------------------------------ diff --git a/src/alire/alire-origins-deployers-system-rpm_wrappers.ads b/src/alire/alire-origins-deployers-system-rpm_wrappers.ads index 2b4fc452b..6b4871bf5 100644 --- a/src/alire/alire-origins-deployers-system-rpm_wrappers.ads +++ b/src/alire/alire-origins-deployers-system-rpm_wrappers.ads @@ -16,4 +16,7 @@ package Alire.Origins.Deployers.System.RPM_Wrappers is overriding function Install (This : Deployer) return Outcome; + overriding + function Executable_Name (This : Deployer) return String; + end Alire.Origins.Deployers.System.RPM_Wrappers; diff --git a/src/alire/alire-origins-deployers-system-zypper.ads b/src/alire/alire-origins-deployers-system-zypper.ads index 63ae43f3b..cadc3ffb4 100644 --- a/src/alire/alire-origins-deployers-system-zypper.ads +++ b/src/alire/alire-origins-deployers-system-zypper.ads @@ -12,4 +12,7 @@ package Alire.Origins.Deployers.System.Zypper is overriding function Install (This : Deployer) return Outcome; + overriding + function Executable_Name (This : Deployer) return String is ("zypper"); + end Alire.Origins.Deployers.System.Zypper; diff --git a/src/alire/alire-origins-deployers-system.adb b/src/alire/alire-origins-deployers-system.adb index efecf97c8..6eac279d8 100644 --- a/src/alire/alire-origins-deployers-system.adb +++ b/src/alire/alire-origins-deployers-system.adb @@ -4,6 +4,7 @@ with Alire.Origins.Deployers.System.Macports; with Alire.Origins.Deployers.System.Pacman; with Alire.Origins.Deployers.System.RPM_Wrappers; with Alire.Origins.Deployers.System.Zypper; +with Alire.OS_Lib; with Alire.Platforms.Current; with CLIC.User_Input; @@ -125,4 +126,17 @@ package body Alire.Origins.Deployers.System is This.Ask_Permission := False; end Dont_Ask_Permission; + --------------------- + -- Executable_Path -- + --------------------- + + function Executable_Path return Optional_Absolute_Path 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); + 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 2be0ee58f..1367b9ed4 100644 --- a/src/alire/alire-origins-deployers-system.ads +++ b/src/alire/alire-origins-deployers-system.ads @@ -46,6 +46,12 @@ package Alire.Origins.Deployers.System is -- This procedure tells the deployer not to ask user permission before -- deployment. + not overriding + function Executable_Name (This : Deployer) return String is abstract; + -- Must return the name of the executable used for installations (apt, + -- pacman, etc). For platforms that use several, the top-most wrapper + -- should be returned (i.e., apt instead of dpkg, yum instead of rpm...). + ------------- -- Factory -- ------------- @@ -56,6 +62,10 @@ 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_Path return Optional_Absolute_Path; + -- Identifies the package manager executable being called in the current + -- platform, or "" if none found. + private type Deployer is abstract new Deployers.Deployer with record diff --git a/src/alire/alire.ads b/src/alire/alire.ads index 26773475a..d18789a00 100644 --- a/src/alire/alire.ads +++ b/src/alire/alire.ads @@ -149,6 +149,11 @@ package Alire with Preelaborate is function Absolute_Path_Image (Path : Absolute_Path) return String; -- Needed for later instantiations + subtype Optional_Absolute_Path is Any_Path + with Dynamic_Predicate => + Optional_Absolute_Path = "" or else + Check_Absolute_Path (Optional_Absolute_Path); + subtype Unbounded_Absolute_Path is UString with Dynamic_Predicate => +Unbounded_Absolute_Path = "" or else diff --git a/src/alr/alr-commands-version.adb b/src/alr/alr-commands-version.adb index b40674833..51c4cf9d5 100644 --- a/src/alr/alr-commands-version.adb +++ b/src/alr/alr-commands-version.adb @@ -4,6 +4,7 @@ with Alire.Directories; with Alire.Index; with Alire.Index_On_Disk.Loading; with Alire.Milestones; +with Alire.Origins.Deployers.System; with Alire.Paths.Vault; with Alire.Platforms.Folders; with Alire.Properties; @@ -116,6 +117,11 @@ package body Alr.Commands.Version is end loop; end; + Table + .Append ("system package manager:") + .Append (Alire.Origins.Deployers.System.Executable_Path) + .New_Row; + Table.Append ("").New_Row; Table.Append ("WORKSPACE").New_Row;