Package_Managers

This commit is contained in:
Alejandro R Mosteo
2018-03-01 16:50:17 +01:00
parent 4a3da5cc54
commit 46965aea00
5 changed files with 63 additions and 17 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ package Alire.Index.LibGNUTLS is
Register (Name,
V ("3.5.8"),
Desc,
Apt ("libgnutls28-dev"),
Native ("libgnutls28-dev"),
Available_When =>
Distribution_Is (Debian_Buster) or
Distribution_Is (Ubuntu_Artful));
+36
View File
@@ -0,0 +1,36 @@
with Alire.Properties;
with Alire.Requisites;
generic
type Values is private;
package Alire.Conditional is
type Conditional_Value (<>) is tagged private;
function New_Conditional (If_X : Requisites.Tree;
Then_X : Values;
Else_X : Values) return Conditional_Value;
function Evaluate (This : Conditional_Value; Against : Properties.Vector) return Values;
private
type Conditional_Value is tagged record
Condition : Requisites.Tree;
Then_Value : Values;
Else_Value : Values;
end record;
function Evaluate (This : Conditional_Value; Against : Properties.Vector) return Values is
(if This.Condition.Check (Against)
then This.Then_Value
else This.Else_Value);
function New_Conditional (If_X : Requisites.Tree;
Then_X : Values;
Else_X : Values) return Conditional_Value is
(Condition => If_X,
Then_Value => Then_X,
Else_Value => Else_X);
end Alire.Conditional;
+1 -1
View File
@@ -63,7 +63,7 @@ package Alire.Index is
-- Shortcuts for common origins:
function Apt (Pack : String ) return Origins.Origin renames Origins.New_Apt;
function Native (Pack : String ) return Origins.Origin renames Origins.New_Native;
function Git (URL : Alire.URL; Commit : Origins.Git_Commit) return Origins.Origin renames Origins.New_Git;
function Hg (URL : Alire.URL; Commit : Origins.Hg_Commit) return Origins.Origin renames Origins.New_Hg;
+17 -15
View File
@@ -7,10 +7,10 @@ package Alire.Origins with Preelaborate is
-- The actual capabilities for check-outs or fetches are in alr proper
type Kinds is (Apt, -- Native platform package
Filesystem, -- Not really an origin, but a working copy of a project
type Kinds is (Filesystem, -- Not really an origin, but a working copy of a project
Git, -- Remote git repo
Hg -- Remote hg repo
Hg, -- Remote hg repo
Native -- Native platform package
);
type Origin is tagged private;
@@ -21,7 +21,7 @@ package Alire.Origins with Preelaborate is
function Id (This : Origin) return String;
function Is_Native (This : Origin) return Boolean;
function Is_Native (This : Origin) return Boolean is (This.Kind = Native);
-- Helper types
@@ -30,7 +30,7 @@ package Alire.Origins with Preelaborate is
-- Constructors
function New_Filesystem (URL_As_Path : String) return Origin;
function New_Filesystem (Path : String) return Origin;
function New_Git (URL : Alire.URL;
Id : Git_Commit)
@@ -40,7 +40,10 @@ package Alire.Origins with Preelaborate is
Id : Hg_Commit)
return Origin;
function New_Apt (Id_As_Package_Name : String) return Origin;
function New_Native (Package_Name : String) return Origin;
function Native_Package (This : Origin) return String
with Pre => This.Kind = Native;
function Image (This : Origin) return String;
@@ -54,10 +57,10 @@ private
Id : Unbounded_String;
end record;
function New_Filesystem (URL_As_Path : String) return Origin is
function New_Filesystem (Path : String) return Origin is
(Filesystem,
Id => Null_Unbounded_String,
URL => To_Unbounded_String (URL_As_Path));
URL => To_Unbounded_String (Path));
function New_Git (URL : Alire.URL;
Id : Git_Commit)
@@ -73,9 +76,9 @@ private
URL => To_Unbounded_String (URL),
Id => To_Unbounded_String (Id));
function New_Apt (Id_As_Package_Name : String) return Origin is
(Apt,
Id => To_Unbounded_String (Id_As_Package_Name),
function New_Native (Package_Name : String) return Origin is
(Native,
Id => To_Unbounded_String (Package_Name),
URL => Null_Unbounded_String);
function Kind (This : Origin) return Kinds is (This.Kind);
@@ -84,15 +87,14 @@ private
function Id (This : Origin) return String is (To_String (This.Id));
function Is_Native (This : Origin) return Boolean is
(This.Kind in Apt);
function Native_Package (This : Origin) return String renames Id;
function S (Str : Unbounded_String) return String is (To_String (Str));
function Image (This : Origin) return String is
(case This.Kind is
when Git | Hg => "commit " & S (This.Id) & " from " & S (This.URL),
when Apt => "package " & S (This.Id) & " from native package manager (apt)",
when Git | Hg => "commit " & S (This.Id) & " from " & S (This.URL),
when Native => "package " & S (This.Id) & " from platform software manager",
when Filesystem => "path " & S (This.Id));
+8
View File
@@ -17,4 +17,12 @@ package Alire.Platforms with Preelaborate is
-- It turns out that Debian uses no numbers for its non-stable releases, so we'll prefer the codename
-- These are important mostly to tie platform package names to releases
type Package_Managers is (Apt,
Unsupported);
function Package_Manager (D : Distributions) return Package_Managers is
(case D is
when Debian_Buster .. Ubuntu_Artful => Apt,
when others => Unsupported);
end Alire.Platforms;