Skip to content

Commit

Permalink
Release 1.2.2 (#1289)
Browse files Browse the repository at this point in the history
* Update msys2 installer (#1284)

* Update msys2 installer

* Follow updated MSYS2 first install instructions

* Show proper error message if msys2 update fails

* Fix the command to query for pending updates

* Don't scare-warn needlessly during msys2 update

Co-authored-by: Alejandro R. Mosteo <[email protected]>

* Bump version to 1.2.2

Co-authored-by: Fabien Chouteau <[email protected]>
  • Loading branch information
mosteo and Fabien-Chouteau authored Jan 12, 2023
1 parent a126091 commit afac3fc
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/alire/alire-version.ads
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package Alire.Version with Preelaborate is

-- Remember to update Alire.Index branch if needed too

Current : constant String := "1.2.1";
Current : constant String := "1.2.2";
-- 1.2.2: update and fix first update method of msys2 on Windows
-- 1.2.1: build switches fix and other minor assorted fixes
-- 1.2.0: rpm speed-up, silence propagation warning, early switch parse
-- 1.2.0-rc1: release candidate for 1.2
Expand Down
75 changes: 59 additions & 16 deletions src/alire/os_windows/alire-platforms-current__windows.adb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package body Alire.Platforms.Current is

package Cfg renames Config;

Default_Msys2_Installer : constant String := "msys2-x86_64-20220503.exe";
Default_Msys2_Installer : constant String := "msys2-x86_64-20221216.exe";
Default_Msys2_Installer_URL : constant String :=
"https://github.com/msys2/msys2-installer/releases/download/2022-05-03/"
"https://github.com/msys2/msys2-installer/releases/download/2022-12-16/"
& Default_Msys2_Installer;

-- Windows implementation
Expand Down Expand Up @@ -303,7 +303,8 @@ package body Alire.Platforms.Current is
end if;

-- Load msys2 environment to attempt first full update according to
-- official setup instructions.
-- official setup instructions at:
-- https://www.msys2.org/wiki/MSYS2-installation/
declare
Default_Install_Dir : constant Alire.Absolute_Path :=
Platforms.Folders.Cache / "msys64";
Expand All @@ -315,19 +316,61 @@ package body Alire.Platforms.Current is
Set_Msys2_Env (Cfg_Install_Dir);
end;

-- First update for the index and core packages
Alire.OS_Lib.Subprocess.Checked_Spawn
("pacman",
AAA.Strings.Empty_Vector
& "--noconfirm"
& "-Syu");

-- Second update for remaining packages
Alire.OS_Lib.Subprocess.Checked_Spawn
("pacman",
AAA.Strings.Empty_Vector
& "--noconfirm"
& "-Su");
-- Run full updates until nothing pending, according to docs.
-- If something fails we can force going ahead in case we don't need
-- msys2, and this will enable a first run to "succeed".
declare
Update_Attempts : Natural := 1;
Max_Attempts : constant := 5;
begin
loop
Trace.Info ("Updating MSYS2 after installation...");
Alire.OS_Lib.Subprocess.Checked_Spawn
("pacman",
AAA.Strings.Empty_Vector
& "--noconfirm"
& "-Syuu");

-- Exit when no updates pending. This command may fail with exit
-- code /= 0 even though there is no real error, when there is
-- a missing database that will be fetched properly by the next
-- update.
Trace.Info ("Querying MSYS2 for pending updates...");
declare
Output : AAA.Strings.Vector;
Code : constant Integer :=
Alire.OS_Lib.Subprocess.Unchecked_Spawn_And_Capture
("pacman",
AAA.Strings.Empty_Vector
& "--noconfirm"
& "-Qu",
Output,
Err_To_Out => True
);
begin
-- So not to unnecessarily worry users, as this is expected and
-- benign in some cases, we don't show it unless this is the
-- last attempt before bailing out:
if Code /= 0 then
Trace.Log ("MSYS2 ended with non-zero exit status: "
& AAA.Strings.Trim (Code'Image),
(if Update_Attempts > Max_Attempts
then Trace.Warning
else Trace.Debug));
end if;

exit when Update_Attempts > Max_Attempts -- safeguard JIC
or else AAA.Strings.Trim (Output.Flatten) = "";
end;

Update_Attempts := Update_Attempts + 1;
end loop;
exception
when E : Checked_Error =>
Log_Exception (E);
Recoverable_Error ("While updating msys2 after installation: "
& Errors.Get (E, Clear => False));
end;

return Alire.Outcome_Success;
end Install_Msys2;
Expand Down

0 comments on commit afac3fc

Please sign in to comment.