Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6acdf9b
Add Gentoo and Portage into the platforms and package managers.
Lucretia Jul 31, 2025
00d0492
Add a new package to support portage on Gentoo.
Lucretia Jul 31, 2025
24357e3
Hook in Gentoo/Portage into the Deployers
Lucretia Jul 31, 2025
ba4154d
dev: check templates are up to date (#1995)
mosteo Aug 15, 2025
9f400ff
dev: guidelines for automatic Copilot reviews (#1998)
mosteo Aug 16, 2025
949aa16
fix: pass GH token in Docker tests too (#1999)
mosteo Aug 16, 2025
4ae0f4e
dev: placeholder for ignoring known future properties (#2000)
mosteo Aug 17, 2025
4c31954
fix: typos in `catalog-format-spec.md` (#2002)
mgrojo Sep 3, 2025
c021b26
fix: workflow on aarch64 linux, macOS 14 instead of latest (#2003)
AldanTanneo Sep 4, 2025
e1fe270
feat: prevent incidental output breaking structured output (#2005)
Seb-MCaw Sep 6, 2025
ff77496
Add documentation for Gentoo.
Lucretia Sep 13, 2025
89697c6
Merge branch 'master' into add-gentoo
Lucretia Sep 13, 2025
7345f7a
Simplify the expression.
Lucretia Sep 13, 2025
bdea4b0
Fix indexing error.
Lucretia Sep 27, 2025
c0bf7b9
feat: validation of GH PATs (#1994)
mosteo Sep 15, 2025
6b3e60a
Merge branch 'master' into add-gentoo
Lucretia Sep 27, 2025
8dd254d
Merge remote-tracking branch 'upstream/master' into add-gentoo
Lucretia Nov 28, 2025
60705e7
Correct the package manager's name to emerge.
Lucretia Nov 28, 2025
395b759
Change the log level to Detail.
Lucretia Nov 28, 2025
7a54348
Change Info -> Debug.
Lucretia Nov 28, 2025
25737fb
Add the comment box.
Lucretia Nov 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions doc/user-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ stay on top of `alr` new features.

## Release `3.0`

### Gentoo support

Add Gentoo's Portage support via sudo, if the base package contains a section for gentoo, see libsdl2 for example, emerge will be called if the package is not installed.

### New `--github` switch for `alr init` command

PR [#1972](https://github.com/alire-project/alire/pull/1972)
Expand Down Expand Up @@ -81,9 +85,9 @@ easily. It takes several optional command line flags:

- `--location=<path/to/alr>` to specify where to install the new binary
- `--release=<version>` to download and install a specific version (provided
that Alire builds binaries for this version on your platform)
that Alire builds binaries for this version on your platform)
- `--nightly` to install a pre-release version of Alire.

**Disclaimer**: nightly versions may have incomplete features, unresolved
bugs and may delete features or break compatibility without warning.

Expand Down
148 changes: 148 additions & 0 deletions src/alire/alire-origins-deployers-system-portage.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
with Ada.Characters.Latin_1;
with AAA.Strings; use AAA.Strings;

with Alire.Errors;
with Alire.OS_Lib.Subprocess;
-- with Alire.Utils.Regex;

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

package L1 renames Ada.Characters.Latin_1;
package Subprocess renames Alire.OS_Lib.Subprocess;

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

overriding function Already_Installed (This : Deployer) return Boolean
is
-- The following call is faster than using emerge.
Output : constant AAA.Strings.Vector :=
Subprocess.Checked_Spawn_And_Capture
("eix",
Empty_Vector & "-ce" & This.Base.Package_Name,
-- Check the category (A),
-- whether it is installed (I) and
-- match against the exact string (e).
-- i.e. "app-editors/zed"
Valid_Exit_Codes => (1, 0), -- returns 1 when not found
Err_To_Out => True);

Indicator : constant String := "[I]";
Line : constant String := AAA.Strings.First_Element (Output);
begin
Trace.Detail ("Already_Installed: " & This.Base.Package_Name);

if Line'Length >= Indicator'Length then
return
Line (Line'First .. Line'First + Indicator'Length - 1) = Indicator;
end if;

return False;
end Already_Installed;

-------------------------
-- To_Semantic_Version --
-------------------------

function To_Semantic_Version (Gentoo_Version : String) return String is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing subprogram box here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean "box?"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment with the name of the function inside a "box":

   -------------------------
   -- To_Semantic_Version --
   -------------------------

GNAT Studio has a command to automate this process. Look in the shortcut settings.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in vscode.

Tmp : String := Gentoo_Version;
begin
for C in Tmp'Range loop
-- Format: 0.0.0_release-rc9
if Tmp (C) = L1.Low_Line then
Tmp (C) := L1.Hyphen;

Trace.Debug ("To_Semantic_Version: " & Tmp);

return Tmp;
end if;
end loop;

Trace.Debug ("To_Semantic_Version: " & Tmp);

return Tmp;
end To_Semantic_Version;

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

overriding
function Detect (This : Deployer) return Version_Outcomes.Outcome
is
function Split_Version (Gentoo_Package_Version : String) return String is
begin
for Index in Gentoo_Package_Version'Range loop
if Gentoo_Package_Version (Index) = L1.Hyphen then
return Gentoo_Package_Version
(Index + 1 .. Gentoo_Package_Version'Last);
end if;
end loop;

return "";
end Split_Version;
pragma Unreferenced (Split_Version);

PortageQ_Output : constant AAA.Strings.Vector :=
Subprocess.Checked_Spawn_And_Capture
("portageq",
Empty_Vector & "best_visible" & "/" &
This.Base.Package_Name,
Valid_Exit_Codes => (0, 1), -- Returned when not found
Err_To_Out => True);
-- portageq should *always* produce zero or one line result.

Output : constant AAA.Strings.Vector :=
Subprocess.Checked_Spawn_And_Capture
("qatom",
Empty_Vector & "-F%{PVR}" &
First_Element (PortageQ_Output),
Valid_Exit_Codes => (0, 1), -- Returned when not found
Err_To_Out => True);
Gentoo_Version : constant String := First_Element (Output);

-- Regexp : constant String :=
-- "[0-9]+(\.[0-9]+)*[a-z](_[a-z]+[0-9]?)*(-r[0-9]*)*";
-- From the pms.pdf.
begin
if Gentoo_Version /= "" then
Trace.Info ("Detect: " & This.Base.Package_Name & " - " &
Gentoo_Version & " - " & To_Semantic_Version (Gentoo_Version) &
" => " & Semantic_Versioning.Parse
(To_Semantic_Version (Gentoo_Version),
Relaxed => True).Image);

return
Version_Outcomes.New_Result
(Semantic_Versioning.Parse
(To_Semantic_Version (Gentoo_Version), Relaxed => True));
end if;

Trace.Debug ("System deployer could not detect: " & This.Base.Image);
return Version_Outcomes.Outcome_Failure ("could not be detected",
Report => False);
end Detect;

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

overriding
function Install (This : Deployer) return Outcome is
begin
Trace.Info ("Install: " & This.Base.Package_Name);

Subprocess.Checked_Spawn
("sudo", Empty_Vector &
"emerge" &
"-av" &
This.Base.Package_Name);

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

end Alire.Origins.Deployers.System.Portage;
18 changes: 18 additions & 0 deletions src/alire/alire-origins-deployers-system-portage.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package Alire.Origins.Deployers.System.Portage 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;

overriding
function Executable_Name (This : Deployer) return String is ("emerge");

end Alire.Origins.Deployers.System.Portage;
5 changes: 5 additions & 0 deletions src/alire/alire-origins-deployers-system.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
with Alire.Origins.Deployers.System.Apt;
with Alire.Origins.Deployers.System.Portage;
with Alire.Origins.Deployers.System.Homebrew;
with Alire.Origins.Deployers.System.Macports;
with Alire.Origins.Deployers.System.Pacman;
Expand All @@ -11,6 +12,7 @@ with Alire.Toolchains;
with CLIC.User_Input;

with GNAT.IO;
-- with System;

package body Alire.Origins.Deployers.System is

Expand Down Expand Up @@ -118,6 +120,9 @@ package body Alire.Origins.Deployers.System is
when Platforms.Macports =>
System.Macports.Deployer'(Deployers.Deployer'(Base => From)
with others => <>),
when Platforms.Portage =>
System.Portage.Deployer'(Deployers.Deployer'(Base => From)
with others => <>),
when Platforms.Packager_Unknown =>
System.Unknown.Deployer'(Deployers.Deployer'(Base => From)
with others => <>)
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 @@ -44,6 +44,7 @@ package Alire.Platforms with Preelaborate is
Suse,
Homebrew,
Macports,
Gentoo,
Distribution_Unknown);

subtype Known_Distributions is
Expand All @@ -61,6 +62,7 @@ package Alire.Platforms with Preelaborate is
Zypper,
Homebrew,
Macports,
Portage,
Packager_Unknown);

Distro_Manager : constant array (Distributions) of Package_Managers :=
Expand All @@ -71,6 +73,7 @@ package Alire.Platforms with Preelaborate is
Suse => Zypper,
Homebrew => Homebrew,
Macports => Macports,
Gentoo => Portage,
Distribution_Unknown => Packager_Unknown);

type Toolchains is (System,
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-utils-tools.adb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ package body Alire.Utils.Tools is
return "";

when Msys2 | Debian | Ubuntu | Arch | Centos | Fedora | Rhel | Suse
| Homebrew | Macports =>
| Homebrew | Macports | Gentoo =>
return (case Tool is
when Easy_Graph =>
(if Distribution in Centos | Fedora | Rhel | Suse
Expand Down
Loading