Skip to content

Commit

Permalink
Report the system package manager in alr version
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Feb 15, 2024
1 parent 5500eac commit ec724e6
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/alire/alire-origins-deployers-system-apt.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 3 additions & 0 deletions src/alire/alire-origins-deployers-system-homebrew.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 3 additions & 0 deletions src/alire/alire-origins-deployers-system-macports.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 3 additions & 0 deletions src/alire/alire-origins-deployers-system-pacman.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
8 changes: 8 additions & 0 deletions src/alire/alire-origins-deployers-system-rpm_wrappers.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
------------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/alire/alire-origins-deployers-system-rpm_wrappers.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 3 additions & 0 deletions src/alire/alire-origins-deployers-system-zypper.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
14 changes: 14 additions & 0 deletions src/alire/alire-origins-deployers-system.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
10 changes: 10 additions & 0 deletions src/alire/alire-origins-deployers-system.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
-------------
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/alire/alire.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/alr/alr-commands-version.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit ec724e6

Please sign in to comment.