Skip to content

Commit

Permalink
bugfix: the wrong folder was searched for nested crates
Browse files Browse the repository at this point in the history
We were attempting to enter a folder that not always will exist.
  • Loading branch information
mosteo committed Oct 10, 2023
1 parent c74a253 commit c3bae46
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/alire/alire-releases.adb
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,16 @@ package body Alire.Releases is
Paths.Working_Folder_Inside_Root
/ (Paths.Crate_File_Name & ".upstream");
begin
-- Backup if already there
Alire.Directories.Backup_If_Existing
(Upstream_File,
Base_Dir => Paths.Working_Folder_Inside_Root);
-- Remove just backed up file
if Directories.Is_File (Upstream_File) then
Directories.Delete_Tree
(Directories.Full_Name (Upstream_File));
end if;
-- And rename the original manifest into upstream
Ada.Directories.Rename
(Old_Name => Paths.Crate_File_Name,
New_Name => Upstream_File);
Expand All @@ -299,9 +306,12 @@ package body Alire.Releases is
Trace.Debug ("Deploying " & This.Milestone.TTY_Image
& " into " & TTY.URL (Folder));

-- Deploy if the target dir is not already there
-- Deploy if the target dir is not already there. We only skip for
-- releases that require a folder to be deployed; system releases
-- require the deploy attempt as the installation check is done by
-- the deployer.

if Completed.Exists then
if This.Origin.Is_Index_Provided and then Completed.Exists then
Was_There := True;
Trace.Detail ("Skipping checkout of already available " &
This.Milestone.Image);
Expand Down
10 changes: 6 additions & 4 deletions src/alire/alire-roots.adb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ with Ada.Unchecked_Deallocation;
with Alire.Builds;
with Alire.Conditional;
with Alire.Dependencies.Containers;
with Alire.Directories;
with Alire.Environment.Loading;
with Alire.Errors;
with Alire.Flags;
Expand Down Expand Up @@ -757,9 +756,12 @@ package body Alire.Roots is
);

-- If the release was newly deployed, we can inform about its
-- nested crates now.
-- nested crates now (if it has its own folder where nested
-- crates could be found).

if not Was_There and then not CLIC.User_Input.Not_Interactive
if Rel.Origin.Is_Index_Provided
and then not Was_There
and then not CLIC.User_Input.Not_Interactive
then
Print_Nested_Crates (This.Release_Base (Rel.Name,
For_Deploy));
Expand Down Expand Up @@ -1435,7 +1437,7 @@ package body Alire.Roots is
Rel : constant Releases.Release := Release (This, Crate);
begin
if not This.Requires_Build_Sync (Rel) then
return This.Release_Parent (Rel, For_Build) / Rel.Base_Folder;
return This.Release_Parent (Rel, For_Deploy) / Rel.Base_Folder;
else
case Usage is
when For_Deploy =>
Expand Down
4 changes: 3 additions & 1 deletion src/alire/alire-roots.ads
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ private with Alire.Builds.Hashes;
with Alire.Containers;
with Alire.Crate_Configuration;
with Alire.Dependencies.States;
with Alire.Directories;
limited with Alire.Environment;
private with Alire.Lockfiles;
with Alire.Paths;
Expand Down Expand Up @@ -333,7 +334,8 @@ package Alire.Roots is
-- overwrite even if existing (so `alr update` can deal with any
-- corner case).

procedure Print_Nested_Crates (Path : Any_Path);
procedure Print_Nested_Crates (Path : Any_Path)
with Pre => Directories.Is_Directory (Path);
-- Look for nested crates below the given path and print a summary of
-- path/milestone:description for each one found. Won't enter `alire` dirs.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
description = "GNAT is a compiler for the Ada programming language"
name = "gnat_external"

maintainers = ["[email protected]"]
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\\.]+).*"
provides = "gnat"
1 change: 1 addition & 0 deletions testsuite/fixtures/system_index/index.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "1.1"
9 changes: 9 additions & 0 deletions testsuite/fixtures/system_index/ma/make/make-external.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description = "Utility for directing compilation"
name = "make"
maintainers = ["[email protected]"]
maintainers-logins = ["mylogin"]

[[external]]
kind = "version-output"
version-command = ["make", "--version"]
version-regexp = ".*Make ([\\d\\.]+).*"
10 changes: 10 additions & 0 deletions testsuite/tests/with/system-crate/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Check that a system crate dependency can be added without issue
"""

from drivers.alr import init_local_crate, run_alr

init_local_crate()
run_alr("with", "make")

print("SUCCESS")
4 changes: 4 additions & 0 deletions testsuite/tests/with/system-crate/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: python-script
build_mode: both # one of shared, sandboxed, both (default)
indexes:
system_index: {}

0 comments on commit c3bae46

Please sign in to comment.