-
Notifications
You must be signed in to change notification settings - Fork 26
/
sync_with_nix_os.dart
64 lines (60 loc) · 2.41 KB
/
sync_with_nix_os.dart
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
import 'dart:io';
import 'tools/is_supported.dart';
import 'tools/add_linux_to_support.dart';
void main() async {
int numberOfCovered = 0;
int numberOfNotCovered = 0;
List<String> listOfNotCovered = [];
Directory cacheDir = Directory(".cache/NixOSSync");
if (cacheDir.existsSync()) {
cacheDir.deleteSync(recursive: true);
}
cacheDir.createSync(recursive: true);
stdout.write("Clonning https://github.com/NixOS/mobile-nixos.git...");
Process.runSync("git", ["clone", "https://github.com/NixOS/mobile-nixos.git", cacheDir.path]);
stdout.write("OK\n");
for (FileSystemEntity entry in Directory("${cacheDir.path}/devices").listSync().toList()) {
print(entry.path);
if(entry is Directory) {
if (!entry.path.endsWith("families")) {
File file = File("${entry.path}/default.nix");
String content = await file.readAsString();
List<String> lines = content.split("\n");
String deviceName = "";
String deviceSupportLevel = "";
for (String line in lines) {
String inside = line.trim();
if (inside.startsWith("mobile.device.name")) {
deviceName = inside.replaceAll("mobile.device.name", "").replaceAll("=", "").replaceAll("\"", "").replaceAll(";", "").trim();
}
if (inside.startsWith("mobile.device.supportLevel")) {
deviceSupportLevel = inside.replaceAll("mobile.device.supportLevel", "").replaceAll("=", "").replaceAll("\"", "").replaceAll(";", "").trim();
}
}
if (deviceSupportLevel == "") {
deviceSupportLevel = "Unsupported";
}
if (isSupported(extendedCodename: deviceName)) {
numberOfCovered += 1;
addLinuxToSupport(
extendedCodename: deviceName,
distributionName: "Mobile NixOS",
distributionSupport: true,
distributionState: deviceSupportLevel.replaceRange(0, 1, deviceSupportLevel[0].toUpperCase()),
distributionWebpage: "https://mobile.nixos.org/index.html",
deviceWebpage: "https://mobile.nixos.org/devices/$deviceName.html"
);
}
else {
numberOfNotCovered += 1;
listOfNotCovered += [deviceName];
}
}
}
}
stdout.write("Covered: $numberOfCovered\n");
stdout.write("Not covered: $numberOfNotCovered\n");
for (var deviceNotCovered in listOfNotCovered) {
stdout.write("$deviceNotCovered\n");
}
}