Skip to content

Commit 398bf41

Browse files
authored
[xaprepare] Implement support for ArchLinux pacman (#5093)
This commit adds support for ArchLinux pacman package manager. It also implements the InitOS function in ConfigAndData/Dependencies/Linux.Arch.cs
1 parent f157f41 commit 398bf41

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

build-tools/xaprepare/xaprepare/Application/Program.ArchLinux.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,38 @@ public ArchLinuxProgram (string packageName, string? executableName = null)
1111

1212
protected override bool CheckWhetherInstalled ()
1313
{
14-
throw new NotImplementedException ();
14+
return Utilities.RunCommand ("pacman", "-Q", PackageName);
1515
}
1616

1717
#pragma warning disable CS1998
1818
public override async Task<bool> Install ()
1919
{
20-
throw new NotImplementedException ();
20+
var runner = new ProcessRunner ("sudo", "pacman", "-S", "--noconfirm", PackageName) {
21+
EchoStandardOutput = true,
22+
EchoStandardError = true,
23+
ProcessTimeout = TimeSpan.FromMinutes (30),
24+
};
25+
26+
bool failed = await Task.Run (() => !runner.Run ());
27+
if (failed) {
28+
Log.Error ($"Installation of {PackageName} timed out");
29+
failed = true;
30+
}
31+
32+
if (runner.ExitCode != 0) {
33+
Log.Error ($"Installation failed with error code {runner.ExitCode}");
34+
failed = true;
35+
}
36+
37+
return !failed;
2138
}
2239
#pragma warning restore CS1998
2340

2441
protected override bool DeterminePackageVersion()
2542
{
26-
throw new NotImplementedException();
43+
var output = Utilities.GetStringFromStdout ("pacman", "-Q", PackageName).Split(' ');
44+
CurrentVersion = output.Length == 2 ? output[1] : null;
45+
return !String.IsNullOrEmpty (CurrentVersion);
2746
}
2847
}
2948
}

build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ protected override bool InitOS ()
5353
if (!base.InitOS ())
5454
return false;
5555

56-
Log.Todo ("Implement");
57-
return false;
56+
return true;
5857
}
5958
};
6059
}

0 commit comments

Comments
 (0)