Skip to content

Commit

Permalink
Support also Alire 1.x and bump new version
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrojo committed Mar 12, 2024
1 parent 1810340 commit 2b0ecff
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ There are two prerequisites for your project to work with this tool:
has to be the main application program.
- It must be installable using Alire, including all the needed resources.


`alr_appimage` will use the following command for installing it (this requires Alire 2.0):
```shell
alr install
```
Or it will run `gprinstall` inside `alr exec`, if the former fails (Alire 1.x).

If you simply run the tool inside an Alire crate, it will read the
metadata from your `alire.toml` file and create a default AppImage
Expand Down
3 changes: 2 additions & 1 deletion alire.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "alr_appimage"
description = "Tool to create an AppImage executable from an Alire crate"
version = "0.9.0"
version = "0.9.1"
website = "https://github.com/mgrojo/alr-appimage"
long-description = """
There are two prerequisites for your project to work with this tool:
Expand All @@ -12,6 +12,7 @@ There are two prerequisites for your project to work with this tool:
```shell
alr install
```
Or it will run `gprinstall` inside `alr exec`, if the former fails (Alire 1.x).
If you simply run the tool inside an Alire crate, it will read the
metadata from your `alire.toml` file and create a default AppImage
Expand Down
52 changes: 46 additions & 6 deletions src/runner.adb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,42 @@ package body Runner is

end Run_Copy_Icon;

-- Run gprinstall inside "alr exec". This is the fallback when running under
-- a version of Alire without the "install" subcommand (1.x versions).
--
procedure Run_Gprinstall (Install_Prefix : String;
Success : out Boolean)
is

Arg_1 : aliased Spoon.Argument := Spoon.To_Argument ("exec");
Arg_2 : aliased Spoon.Argument := Spoon.To_Argument ("-P");
Arg_3 : aliased Spoon.Argument := Spoon.To_Argument ("--");
Arg_4 : aliased Spoon.Argument := Spoon.To_Argument ("gprinstall");
Arg_5 : aliased Spoon.Argument
:= Spoon.To_Argument ("--prefix=" & Install_Prefix);
Arg_6 : aliased Spoon.Argument := Spoon.To_Argument ("--create-missing-dirs");
Arg_7 : aliased Spoon.Argument := Spoon.To_Argument ("--mode=usage");
Arg_8 : aliased Spoon.Argument := Spoon.To_Argument ("-f");

Result : constant Spoon.Result :=
Spoon.Spawn (Executable => "alr",
Arguments => (Arg_1'Unchecked_Access,
Arg_2'Unchecked_Access,
Arg_3'Unchecked_Access,
Arg_4'Unchecked_Access,
Arg_5'Unchecked_Access,
Arg_6'Unchecked_Access,
Arg_7'Unchecked_Access,
Arg_8'Unchecked_Access),
Kind => Spoon.Name);
begin

Ada.Text_IO.Put_Line ("Finished: fallback command: ""alr exec ... gprinstall ...""");

Report_State (Result, Success);

end Run_Gprinstall;

function Run_Alr_Install (Icon : String) return String
is

Expand All @@ -85,10 +121,15 @@ package body Runner is
Kind => Spoon.Name);
begin

Ada.Text_IO.Put_Line ("Running ""alr install""");
Ada.Text_IO.Put_Line ("Finished: ""alr install""");

Report_State (Result, Success);

if not Success then
-- "alr install" failed. Let's try with the fallback command.
Run_Gprinstall (Install_Prefix, Success);
end if;

if Success then
Run_Copy_Icon (Icon, Install_Prefix, Success);
end if;
Expand Down Expand Up @@ -130,7 +171,7 @@ package body Runner is
Linuxdeploy_URL_Argument'Access),
Kind => Spoon.Name);
begin
Ada.Text_IO.Put_Line ("Running curl...");
Ada.Text_IO.Put_Line ("Finished: curl...");
Report_State (Result, Success);
end;

Expand All @@ -148,7 +189,7 @@ package body Runner is
Kind => Spoon.Name);
begin

Ada.Text_IO.Put_Line ("Running wget...");
Ada.Text_IO.Put_Line ("Finished: wget...");
Report_State (Result, Success);
end;

Expand All @@ -168,7 +209,7 @@ package body Runner is
Arg_2'Unchecked_Access),
Kind => Spoon.Name);
begin
Ada.Text_IO.Put_Line ("Running ""chmod +x "
Ada.Text_IO.Put_Line ("Finished: ""chmod +x "
& Linuxdeploy_Program & """");
Report_State (Result, Success);
end Run_Change_Mode;
Expand Down Expand Up @@ -237,7 +278,6 @@ package body Runner is
return Ada.Strings.Unbounded.To_String (Found_Filename);
end Find_Executable;


procedure Run_Linuxdeploy (App_Dir, Executable, Icon_File : String;
Success : out Boolean) is

Expand Down Expand Up @@ -267,7 +307,7 @@ package body Runner is
return;
end if;

Ada.Text_IO.Put_Line ("Running ""./" & Linuxdeploy_Program & " "
Ada.Text_IO.Put_Line ("Running: ""./" & Linuxdeploy_Program & " "
& Arg_String_1 & " "
& Arg_String_2 & " "
& Arg_String_3 & " "
Expand Down

0 comments on commit 2b0ecff

Please sign in to comment.