diff --git a/src/alire/alire-origins-deployers-system-unknown.ads b/src/alire/alire-origins-deployers-system-unknown.ads new file mode 100644 index 000000000..dbf117252 --- /dev/null +++ b/src/alire/alire-origins-deployers-system-unknown.ads @@ -0,0 +1,23 @@ +package Alire.Origins.Deployers.System.Unknown is + + type Deployer is new Deployers.System.Deployer with null record; + + overriding + function Already_Installed (This : Deployer) return Boolean + is (raise Program_Error with "Should be unreachable"); + + overriding + function Detect (This : Deployer) + return Version_Outcomes.Outcome + is (Version_Outcomes.Outcome_Failure + ("unknown distro, cannot detect versions of system packages")); + + overriding + function Install (This : Deployer) return Outcome + is (Outcome_Failure ("unknown distro, no system deployer")); + + overriding + function Executable_Name (This : Deployer) return String + is ("nonexistent-package-manager-that-alire-musnt-find"); + +end Alire.Origins.Deployers.System.Unknown; diff --git a/src/alire/alire-origins-deployers-system.adb b/src/alire/alire-origins-deployers-system.adb index 08666780d..545672e82 100644 --- a/src/alire/alire-origins-deployers-system.adb +++ b/src/alire/alire-origins-deployers-system.adb @@ -3,9 +3,9 @@ with Alire.Origins.Deployers.System.Homebrew; with Alire.Origins.Deployers.System.Macports; with Alire.Origins.Deployers.System.Pacman; with Alire.Origins.Deployers.System.RPM_Wrappers; +with Alire.Origins.Deployers.System.Unknown; with Alire.Origins.Deployers.System.Zypper; with Alire.OS_Lib; -with Alire.Platforms.Current; with CLIC.User_Input; @@ -87,9 +87,12 @@ package body Alire.Origins.Deployers.System is -- Platform_Deployer -- ----------------------- - function Platform_Deployer (From : Origins.Origin) return Deployer'Class is - (case Platforms.Distro_Manager (Platforms.Current.Distribution) is - when Platforms.Apt | Platforms.Packager_Unknown => + function Platform_Deployer + (From : Origins.Origin; + Distro : Platforms.Distributions := Platforms.Current.Distribution) + return Deployer'Class + is (case Platforms.Distro_Manager (Distro) is + when Platforms.Apt => System.Apt.Deployer'(Deployers.Deployer'(Base => From) with others => <>), when Platforms.Pacman => @@ -113,7 +116,11 @@ package body Alire.Origins.Deployers.System is with others => <>), when Platforms.Macports => System.Macports.Deployer'(Deployers.Deployer'(Base => From) - with others => <>)); + with others => <>), + when Platforms.Packager_Unknown => + System.Unknown.Deployer'(Deployers.Deployer'(Base => From) + with others => <>) + ); -- NOTE: add here other native package managers as they get -- implemented. @@ -135,7 +142,10 @@ package body Alire.Origins.Deployers.System is -- 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 Platform_Deployer (Make).Executable_Name; + return Platform_Deployer + (Make, + Distro => Platforms.Current.Detected_Distribution) + .Executable_Name; end Executable_Name; --------------------- diff --git a/src/alire/alire-origins-deployers-system.ads b/src/alire/alire-origins-deployers-system.ads index 1f2877e5c..c9d4c28c5 100644 --- a/src/alire/alire-origins-deployers-system.ads +++ b/src/alire/alire-origins-deployers-system.ads @@ -1,4 +1,5 @@ with Alire.Outcomes.Definite; +with Alire.Platforms.Current; with Semantic_Versioning; @@ -56,8 +57,13 @@ package Alire.Origins.Deployers.System is -- Factory -- ------------- - function Platform_Deployer (From : Origins.Origin) return Deployer'Class + function Platform_Deployer + (From : Origins.Origin; + Distro : Platforms.Distributions := Platforms.Current.Distribution) + return Deployer'Class with Pre => From.Is_System; + -- Returns the deployer for a current system. Defaults to current one, + -- unless distro detection is disabled. function Platform_Deployer (Package_Name : String) return Deployer'Class is (Platform_Deployer (Origins.New_System (Package_Name)));