Skip to content

Commit

Permalink
Merge remote-tracking branch 'alire/master' into feat/publish-status
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Jul 18, 2023
2 parents 56d22fe + a3da766 commit 0914951
Show file tree
Hide file tree
Showing 26 changed files with 264 additions and 55 deletions.
6 changes: 3 additions & 3 deletions alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project-files = ["alr.gpr"]
executables = ["alr"]

[[depends-on]]
aaa = "~0.2.7"
aaa = "~0.3.0"
ada_toml = "~0.3"
ajunitgen = "^1.0.1"
ansiada = "^1.0"
Expand Down Expand Up @@ -45,9 +45,9 @@ windows = { ALIRE_OS = "windows" }

# Some dependencies require precise versions during the development cycle:
[[pins]]
aaa = { url = "https://github.com/mosteo/aaa", commit = "f60254934a7d6e39b72380b496527295602f75e3" }
aaa = { url = "https://github.com/mosteo/aaa", commit = "fbfffb1cb269a852201d172119d94f3024b617f2" }
ada_toml = { url = "https://github.com/mosteo/ada-toml", commit = "da4e59c382ceb0de6733d571ecbab7ea4919b33d" }
clic = { url = "https://github.com/alire-project/clic", commit = "8d26222de71014554999e48c821906fca0e3dc41" }
clic = { url = "https://github.com/alire-project/clic", commit = "6879b90876a1c918b4e112f59c6db0e25b713f52" }
gnatcoll = { url = "https://github.com/alire-project/gnatcoll-core.git", commit = "403efe11405113cf12ae3d014df474cf7a046176" }
minirest = { url = "https://github.com/mosteo/minirest.git", commit = "17fa789b71ccaf65e8c892816456c94a09a384d0" }
semantic_versioning = { url = "https://github.com/alire-project/semantic_versioning", commit = "2f23fc5f6b4855b836b599adf292fed9c0ed4144" }
Expand Down
2 changes: 1 addition & 1 deletion deps/clic
19 changes: 19 additions & 0 deletions src/alire/alire-config-edit.adb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ package body Alire.Config.Edit is
end case;
end Set;

-----------
-- Unset --
-----------

procedure Unset (Level : Config.Level;
Key : CLIC.Config.Config_Key)
is
begin
if CLIC.Config.Edit.Unset (Filepath (Level), Key, Quiet => True) then
Trace.Debug ("Config key " & Key & " unset from " & Level'Image
& "configuration at " & Filepath (Level));
Load_Config;
else
Trace.Debug ("Config key " & Key & " requested to be unset at level "
& Level'Image & " but it was already unset at "
& Filepath (Level));
end if;
end Unset;

-----------------
-- Set_Boolean --
-----------------
Expand Down
4 changes: 4 additions & 0 deletions src/alire/alire-config-edit.ads
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ package Alire.Config.Edit is
-- here all non-preelaborable things related to config loading. This
-- way, querying stays preelaborable.

procedure Unset (Level : Config.Level;
Key : CLIC.Config.Config_Key);
-- Unset a key at a level; silently succeed even if the key was undefined.

function Path return Absolute_Path;
-- The in-use global config folder path.
-- In order of decreasing precedence:
Expand Down
114 changes: 114 additions & 0 deletions src/alire/alire-origins-deployers-system-macports.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
with AAA.Strings; use AAA.Strings;

with Alire.OS_Lib.Subprocess;
with Alire.Errors;

package body Alire.Origins.Deployers.System.Macports is

-- Ada.Strings.Unbounded is use-visible via Alire.Origins.

package Subprocess renames Alire.OS_Lib.Subprocess;

-----------------------
-- Already_Installed --
-----------------------

overriding function Already_Installed (This : Deployer) return Boolean
is
Installed : AAA.Strings.Vector;
begin
Trace.Debug ("already_installed? " & This.Base.Package_Name);

if Subprocess.Unchecked_Spawn_And_Capture
("port",
Empty_Vector & "echo" & "installed",
Output => Installed,
Err_To_Out => True) /= 0
then
-- failed.
Trace.Debug ("port failed to find any installed packages");
return False;
end if;

-- We get a list of all the installed packages,
-- name {spaces} '@' version

Trace.Debug (Installed.Length'Image & " installed packages");

for P of Installed loop
Trace.Debug ("Checking '" & P & "'");
if AAA.Strings.Head (P, ' ') = This.Base.Package_Name then
Trace.Debug ("found '" & P & "'");
return True;
end if;
end loop;

return False; -- until we've implemented Install
end Already_Installed;

------------
-- Detect --
------------

-- Returns the package version, if the package exists, whether or
-- not it's installed.
--
-- If it's not installed, what you get is the version that would
-- be installed.

overriding
function Detect (This : Deployer) return Version_Outcomes.Outcome
is
Info : AAA.Strings.Vector;
begin
Trace.Debug ("detect? " & This.Base.Package_Name);

if Subprocess.Unchecked_Spawn_And_Capture
("port",
Empty_Vector & "info" & "--version" & This.Base.Package_Name,
Output => Info,
Err_To_Out => True) /= 0
then
-- failed.
Trace.Debug ("port failed to find " & This.Base.Package_Name);
return Version_Outcomes.Outcome_Failure
("no candidate version found",
Report => False);
end if;

if Integer (Info.Length) /= 1 then
raise Constraint_Error
with "port info --version returned" & Info.Length'Image & " lines.";
end if;

Trace.Debug ("port info output: " & Info (Info.First));
declare
Version : constant String := Trim (Tail (Info (Info.First), ':'));
begin
Trace.Debug (" -> version: '" & Version & "'");
return Version_Outcomes.New_Result (Semantic_Versioning.Parse
(Version,
Relaxed => True));
end;

end Detect;

-------------
-- Install --
-------------

overriding
function Install (This : Deployer) return Outcome is
begin
Trace.Debug ("hoping to install: " & This.Base.Image);
Subprocess.Checked_Spawn
("sudo",
Empty_Vector & "port" & "install" & This.Base.Package_Name);

return Outcome_Success;
exception
when E : others =>
return Alire.Errors.Get (E);
end Install;

end Alire.Origins.Deployers.System.Macports;
15 changes: 15 additions & 0 deletions src/alire/alire-origins-deployers-system-macports.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package Alire.Origins.Deployers.System.Macports is

type Deployer is new Deployers.System.Deployer with null record;

overriding
function Already_Installed (This : Deployer) return Boolean;

overriding
function Detect (This : Deployer)
return Version_Outcomes.Outcome;

overriding
function Install (This : Deployer) return Outcome;

end Alire.Origins.Deployers.System.Macports;
4 changes: 4 additions & 0 deletions src/alire/alire-origins-deployers-system.adb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
with Alire.Origins.Deployers.System.Apt;
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.Zypper;
Expand Down Expand Up @@ -108,6 +109,9 @@ package body Alire.Origins.Deployers.System is
with others => <>),
when Platforms.Homebrew =>
System.Homebrew.Deployer'(Deployers.Deployer'(Base => From)
with others => <>),
when Platforms.Macports =>
System.Macports.Deployer'(Deployers.Deployer'(Base => From)
with others => <>));
-- NOTE: add here other native package managers as they get
-- implemented.
Expand Down
14 changes: 11 additions & 3 deletions src/alire/alire-origins.ads
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ package Alire.Origins is
subtype Archive_Kinds is Kinds
with Static_Predicate => Archive_Kinds in Binary_Archive | Source_Archive;

subtype Deployable_Kinds is Kinds
with Static_Predicate => Deployable_Kinds not in External;
-- Origins that require deployment

subtype External_Kinds is Kinds
with Static_Predicate => External_Kinds in External | System;

subtype Source_Kinds is Kinds range Filesystem .. Source_Archive;
-- These are kinds that have actual sources that are deployed and built

subtype VCS_Kinds is Kinds range Git .. SVN;

type Source_Archive_Format is (Unknown, Tarball, Zip_Archive);
Expand Down Expand Up @@ -100,10 +107,11 @@ package Alire.Origins is
function Package_Name (This : Origin) return String
with Pre => This.Kind = System;

function Is_Regular (This : Origin) return Boolean is
function Is_Index_Provided (This : Origin) return Boolean is
(This.Kind not in External | System);
-- A regular origin is one that is compiled from sources, instead of coming
-- from external definitions (detected or not).
-- One that is deployed via built sources or fetched binaries pointed to by
-- an index, instead of coming from locally detected executables or system
-- packages.

function Short_Unique_Id (This : Origin) return String with
Pre => This.Kind in Git | Hg | Archive_Kinds;
Expand Down
3 changes: 3 additions & 0 deletions src/alire/alire-platforms.ads
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ package Alire.Platforms with Preelaborate is
Fedora,
Suse,
Homebrew,
Macports,
Distro_Unknown);

subtype Known_Distributions is
Expand All @@ -58,6 +59,7 @@ package Alire.Platforms with Preelaborate is
Dnf,
Zypper,
Homebrew,
Macports,
Packager_Unknown);

Distro_Manager : constant array (Distributions) of Package_Managers :=
Expand All @@ -67,6 +69,7 @@ package Alire.Platforms with Preelaborate is
Centos | Fedora => Dnf,
Suse => Zypper,
Homebrew => Homebrew,
Macports => Macports,
Distro_Unknown => Packager_Unknown);

type Toolchains is (System,
Expand Down
8 changes: 4 additions & 4 deletions src/alire/alire-roots.adb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ package body Alire.Roots is

-- Relocate to the release folder
CD : Directories.Guard
(if State.Has_Release and then State.Release.Origin.Is_Regular
then Directories.Enter (This.Release_Base (State.Crate))
else Directories.Stay) with Unreferenced;
(if State.Has_Release and then State.Release.Origin.Is_Index_Provided
then Directories.Enter (This.Release_Base (State.Crate))
else Directories.Stay) with Unreferenced;

---------------------------
-- Run_Pre_Build_Actions --
Expand Down Expand Up @@ -696,7 +696,7 @@ package body Alire.Roots is
-- Binary releases are always installed as shared releases
Shared.Share (Rel);

elsif Dep.Is_Shared and then not Rel.Origin.Is_Regular then
elsif Dep.Is_Shared and then not Rel.Origin.Is_Index_Provided then

-- Externals shouldn't leave a trace in the binary cache
Trace.Debug ("deploy: skip shared external");
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-roots.ads
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private
Crate : Crate_Name)
return Any_Path;
-- The path at which dependencies have to be deployed, which for regular
-- releases is simply ./alire/cache/dependencies, unless overriden by the
-- releases is simply ./alire/cache/dependencies, unless overridden by the
-- config option `dependencies.dir`

end Alire.Roots;
4 changes: 2 additions & 2 deletions src/alire/alire-shared.adb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ package body Alire.Shared is
for Release of Index.Releases_Satisfying (Toolchains.Any_Tool (Tool),
Root.Platform_Properties)
loop
if not Release.Origin.Is_Regular then
if not Release.Origin.Is_Index_Provided then
Result.Include (Release);
end if;
end loop;
Expand Down Expand Up @@ -220,7 +220,7 @@ package body Alire.Shared is
Path : constant Absolute_Path :=
Shared.Path / Release.Deployment_Folder;
begin
if not Release.Origin.Is_Regular then
if not Release.Origin.Is_Index_Provided then
Raise_Checked_Error
("Only regular releases deployed through Alire can be removed.");
end if;
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-solutions-diffs.adb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ package body Alire.Solutions.Diffs is
when Unpinned => TTY.Emph (U ("🎈")), -- alts: 𐩒🎈
when Unchanged => TTY.OK (U ("=")),
when Missing => TTY.Error (U ("")), -- alts: ⚠️❗‼️
when Shared => TTY.Emph (U ("♻️ ")), -- alts: ♻️♼
when Shared => TTY.Emph (U ("♻️ ")), -- alts: ♻♻️♼🫴
when Binary => TTY.Warn (U ("📦")))
else
(case Change is
Expand Down
4 changes: 2 additions & 2 deletions src/alire/alire-solver.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1040,11 +1040,11 @@ package body Alire.Solver is

else

-- The crate plainly doesn't exist in our loaded catalog, so
-- The crate plainly doesn't exist in our loaded index, so
-- mark it as missing an move on:

Trace.Debug
("SOLVER: catalog LACKS the crate " & Raw_Dep.Image
("SOLVER: index LACKS the crate " & Raw_Dep.Image
& " when the search tree was "
& Image_One_Line (State));

Expand Down
4 changes: 2 additions & 2 deletions src/alire/alire-solver.ads
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ package Alire.Solver is

---------------------
-- Basic queries --
-- Merely check the catalog
-- Merely check the index

function Exists (Name : Alire.Crate_Name;
Version : Semantic_Versioning.Version;
Expand Down Expand Up @@ -123,7 +123,7 @@ package Alire.Solver is

-----------------------
-- Advanced queries --
-- They may need to travel the full catalog, with multiple individual
-- They may need to travel the full index, with multiple individual
-- availability checks.

type Query_Options is record
Expand Down
Loading

0 comments on commit 0914951

Please sign in to comment.