Skip to content

Commit

Permalink
Improvements to messages during dependency updates (#1569)
Browse files Browse the repository at this point in the history
* Fix bugs causing spurious diffs on update

Solutions were the same, but some types internally where using pointers instead
of pointed objects for comparison.

WIP

* Don't attempt redundant system package installation

* Inform of pin checkouts/updates as for regular crates

* Ensure created folders remain the same

* Fix testsuite index for deterministic make version
  • Loading branch information
mosteo authored Feb 19, 2024
1 parent e2181ed commit 70cc522
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
12 changes: 12 additions & 0 deletions src/alire/alire-origins-deployers-system.ads
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ package Alire.Origins.Deployers.System is
function Platform_Deployer (Package_Name : String) return Deployer'Class is
(Platform_Deployer (Origins.New_System (Package_Name)));

-- Classwide facilities

function Already_Installed (This : Origins.Origin) return Boolean
with Pre => This.Is_System;

function Executable_Name return String;
-- Returns the simple name of the executable package manager on the system

Expand All @@ -81,4 +86,11 @@ private
Ask_Permission : Boolean := True;
end record;

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

function Already_Installed (This : Origins.Origin) return Boolean
is (Platform_Deployer (This).Already_Installed);

end Alire.Origins.Deployers.System;
31 changes: 21 additions & 10 deletions src/alire/alire-releases.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ with Alire.Directories;
with Alire.Defaults;
with Alire.Errors;
with Alire.Flags;
with Alire.Origins.Deployers;
with Alire.Origins.Deployers.System;
with Alire.Paths;
with Alire.Properties.Bool;
with Alire.Properties.Scenarios;
Expand Down Expand Up @@ -316,23 +316,34 @@ package body Alire.Releases is
Trace.Detail ("Skipping checkout of already available " &
This.Milestone.Image);

elsif This.Origin.Kind not in Origins.Deployable_Kinds then
Was_There := True;
Trace.Detail ("External requires no deployment for " &
This.Milestone.Image);

elsif This.Origin.Is_System
and then Origins.Deployers.System.Already_Installed (This.Origin)
then
Was_There := True;
Trace.Detail ("Skipping install of already available system origin " &
This.Milestone.Image);

else
Was_There := False;
Put_Info ("Deploying " & This.Milestone.TTY_Image & "...");
Alire.Origins.Deployers.Deploy (This, Folder).Assert;
end if;

-- For deployers that do nothing, we ensure the folder exists so all
-- dependencies leave a trace in the cache/dependencies folder, and
-- a place from where to run their actions by default.

Ada.Directories.Create_Path (Folder);
-- For deployers that do nothing, we ensure the folder exists so all
-- dependencies leave a trace in the cache/dependencies folder, and
-- a place from where to run their actions by default.

-- Backup a potentially packaged manifest, so our authoritative
-- manifest from the index is always used.
Ada.Directories.Create_Path (Folder);

Backup_Upstream_Manifest;
-- Backup a potentially packaged manifest, so our authoritative
-- manifest from the index is always used.

end if;
Backup_Upstream_Manifest;

-- Create manifest if requested

Expand Down
11 changes: 11 additions & 0 deletions src/alire/alire-user_pins.adb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ package body Alire.User_Pins is

-- Check out the branch or commit

Put_Info ("Deploying " & Utils.TTY.Name (Crate)
& (if Commit /= ""
then " commit " & TTY.URL (VCSs.Git.Short_Commit (Commit))
elsif Branch /= ""
then " branch " & TTY.URL (Branch)
else " default branch")
& "...");

if not
VCSs.Git.Handler.Clone
(From => URL (This) & (if Commit /= ""
Expand Down Expand Up @@ -207,6 +215,9 @@ package body Alire.User_Pins is
-- user in the manifest, the following call will also take care of
-- it.

Put_Info ("Pulling " & Utils.TTY.Name (Crate)
& " branch " & TTY.URL (Branch) & "...");

if not VCSs.Git.Handler.Update (Destination, Branch).Success then
Raise_Checked_Error
("Update of repository at " & TTY.URL (Destination)
Expand Down
3 changes: 3 additions & 0 deletions src/alire/alire-vcss-git.ads
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ package Alire.VCSs.Git is
function Git_Dir return Any_Path;
-- ".git" unless overridden by GIT_DIR

function Short_Commit (Commit : Git_Commit) return String
is (Commit (Commit'First .. Commit'First + 7));

type VCS (<>) is new VCSs.VCS with private;

function Handler return VCS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ maintainers-logins = ["mosteo"]

[[external]]
kind = "version-output"
# We look for make instead that should be always installed.
version-command = ["make", "--version"]
version-regexp = ".*Make ([\\d\\.]+).*"
version-command = ["echo", "1.0"]
version-regexp = "([\\d\\.]+).*"
provides = "gnat"

0 comments on commit 70cc522

Please sign in to comment.