summarylogtreecommitdiffstats
path: root/xaprepare-arch.patch
blob: 8bd9f1c54dc44772fd43365eb34e19908285c433 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
diff --git a/build-tools/xaprepare/xaprepare/Application/Program.ArchLinux.cs b/build-tools/xaprepare/xaprepare/Application/Program.ArchLinux.cs
index 444a5075..7e59785f 100644
--- a/build-tools/xaprepare/xaprepare/Application/Program.ArchLinux.cs
+++ b/build-tools/xaprepare/xaprepare/Application/Program.ArchLinux.cs
@@ -11,19 +11,50 @@ namespace Xamarin.Android.Prepare
 
 		protected override bool CheckWhetherInstalled ()
 		{
-			throw new NotImplementedException ();
+			var runner = new ProcessRunner ("pacman", "-Q", "--", PackageName);
+
+			if (!runner.Run()) {
+				Log.Error ($"Check for package {PackageName} failed");
+				return false;
+			}
+
+			return runner.ExitCode == 0;
 		}
 
-#pragma warning disable CS1998
 		public override async Task<bool> Install ()
 		{
-			throw new NotImplementedException ();
+			var runner = new ProcessRunner ("sudo", "pacman", "-S", "--", PackageName) {
+				EchoStandardOutput = true,
+				EchoStandardError = true,
+				ProcessTimeout = TimeSpan.FromMinutes (30),
+			};
+
+			bool failed = await Task.Run (() => !runner.Run ());
+			if (failed) {
+				Log.Error ($"Installation of {PackageName} timed out");
+				failed = true;
+			}
+
+			if (runner.ExitCode != 0) {
+				Log.Error ($"Installation failed with error code {runner.ExitCode}");
+				failed = true;
+			}
+
+			return !failed;
 		}
-#pragma warning restore CS1998
 
 		protected override bool DeterminePackageVersion()
 		{
-			throw new NotImplementedException();
+			string currentVersion = Utilities.GetStringFromStdout ("pacman", "-Q", "--", PackageName);
+
+			int index = currentVersion.IndexOf (' ');
+			if (index < 0) {
+				Log.Error ($"Could not determine version of {PackageName}");
+				return false;
+			}
+
+			CurrentVersion = currentVersion.Substring (PackageName.Length + 1).Trim ();
+			return true;
 		}
 	}
 }
diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs
index 7faf8723..3a50773e 100644
--- a/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs
+++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/Linux.Arch.cs
@@ -53,8 +53,7 @@ namespace Xamarin.Android.Prepare
 			if (!base.InitOS ())
 				return false;
 
-			Log.Todo ("Implement");
-			return false;
+			return true;
 		}
 	};
 }