add logging (locale is excluded because it doesn't work properly and will have to be redone)

pull/2/head
axtlos 3 years ago
parent 11e45199c5
commit a381c1cf39
No known key found for this signature in database
GPG Key ID: A468AFD71DD51D4A

@ -0,0 +1,24 @@
Chosen layout: at
Chosen variant: normal
Username: s
Enable sudo: true
Desktop: KDE Plasma
Hostname: n
Disks: /dev/sda
/dev/nvme0n1
Selected disk: /dev/nvme0n1
Partition info: 476.9G
Is efi: true
Json config: {"partition":{"device":"nvme0n1","mode":"auto","efi":true},"bootloader":{"type":"grub-efi","location":"/boot/efi"},"locale":{"locale":["en_US.UTF-8 UTF-8"],"keymap":"Af","timezone":"America"},"networking":{"hostname":"n","ipv6":false},"users":[{"name":"s","password":"$1$KRz8vYrK$mTO2iNwmZnkHTpevyAcHN0\n","hasroot":true}],"rootpass":"","desktop":"KDE Plasma","timeshift":true,"extra_packages":["firefox"]}
[LOG] doing thing
[ERROR] failed doing thing
[LOG]
[ERROR]
Installation finished! You may reboot now!

@ -24,7 +24,7 @@ List<Desktop> desktops = const [
//imageurl: '', //imageurl: '',
), ),
Desktop( Desktop(
name: "KDE Plasma", name: "Kde",
displayManager: "sddm", displayManager: "sddm",
packages: [ packages: [
"plasma", "plasma",

@ -5,12 +5,14 @@ import 'package:jade_gui/classes/location.dart';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
test(setOutput, running, setRunning, config) async { test(setOutput, running, setRunning, config, writeToLog) async {
if (!running) { if (!running) {
const filename = "/tmp/jade.json"; const filename = "/tmp/jade.json";
await File(filename).writeAsString(config); await File(filename).writeAsString(config);
writeToLog("Json config: $config");
var process = var process =
await Process.start('pkexec', ['jade', 'config', '/tmp/jade.json']); //await Process.start('pkexec', ['jade', 'config', '/tmp/jade.json']);
await Process.start('/opt/jade_gui/scripts/jadeemu.sh', []);
process.stdout.transform(utf8.decoder).forEach(setOutput); process.stdout.transform(utf8.decoder).forEach(setOutput);
setRunning(true); setRunning(true);
} }
@ -35,6 +37,7 @@ Widget install(
output, output,
running, running,
setRunning, setRunning,
writeToLog,
) { ) {
InstallPrefs prefs = InstallPrefs( InstallPrefs prefs = InstallPrefs(
locale: locale, locale: locale,
@ -55,7 +58,7 @@ Widget install(
); );
String jsonPrefs = jsonEncode(prefs.toJson()); String jsonPrefs = jsonEncode(prefs.toJson());
//writeConfig(jsonPrefs); //writeConfig(jsonPrefs);
test(setOutput, running, setRunning, jsonPrefs); test(setOutput, running, setRunning, jsonPrefs, writeToLog);
return Column( return Column(
children: [ children: [
Text( Text(

@ -13,7 +13,7 @@ String getChosenLayout() {
return chosenLayout.backLayout; return chosenLayout.backLayout;
} }
Widget variantTemplate(variant, chosenLayout, nextPage) { Widget variantTemplate(variant, chosenLayout, nextPage, writeToLog) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@ -28,6 +28,7 @@ Widget variantTemplate(variant, chosenLayout, nextPage) {
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
chosenVariant = variant; chosenVariant = variant;
writeToLog("Chosen variant: $chosenVariant");
nextPage(); nextPage();
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
@ -49,7 +50,7 @@ Widget variantTemplate(variant, chosenLayout, nextPage) {
); );
} }
Widget layoutTemplate(keymap, setChosenLayout) { Widget layoutTemplate(keymap, setChosenLayout, writeToLog) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@ -64,6 +65,7 @@ Widget layoutTemplate(keymap, setChosenLayout) {
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
setChosenLayout(keymap); setChosenLayout(keymap);
writeToLog("Chosen layout: ${keymap.backLayout}");
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
primary: Colors.white, primary: Colors.white,
@ -84,8 +86,8 @@ Widget layoutTemplate(keymap, setChosenLayout) {
); );
} }
Widget keyboard( Widget keyboard(nextPage, showVariant, choseLayout, setChosenLayout,
nextPage, showVariant, choseLayout, setChosenLayout, chosenLayout) { chosenLayout, writeToLog) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -121,8 +123,8 @@ Widget keyboard(
primary: false, primary: false,
child: Column( child: Column(
children: keymaps children: keymaps
.map<Widget>( .map<Widget>((keymap) =>
(keymap) => layoutTemplate(keymap, setChosenLayout)) layoutTemplate(keymap, setChosenLayout, writeToLog))
.toList(), .toList(),
), ),
), ),
@ -148,8 +150,8 @@ Widget keyboard(
primary: false, primary: false,
child: Column( child: Column(
children: chosenLayout.variant children: chosenLayout.variant
.map<Widget>((map) => .map<Widget>((map) => variantTemplate(
variantTemplate(map, chosenLayout, nextPage)) map, chosenLayout, nextPage, writeToLog))
.toList(), .toList(),
), ),
), ),

@ -1,25 +0,0 @@
import 'package:flutter/material.dart';
Widget layout(keymap, chosenLayout, showVariant) {
return Container(
color: const Color.fromARGB(100, 169, 0, 255),
padding: const EdgeInsets.all(8),
child: ElevatedButton(
onPressed: () {
chosenLayout = keymap;
showVariant();
},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: const Color.fromARGB(100, 169, 0, 255),
padding: const EdgeInsets.all(10),
),
child: Text(
keymap.layout,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
),
);
}

@ -1,43 +0,0 @@
import 'package:flutter/material.dart';
String chosenVariant = "none";
String getChosenVariant() {
return chosenVariant;
}
Widget variantButton(variant, nextPage) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ElevatedButton(
onPressed: () {
chosenVariant = variant;
nextPage();
},
child: Text(variant),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: const Color.fromARGB(100, 169, 0, 255),
),
),
const SizedBox(height: 10),
],
);
}
Widget variant(keymap, nextPage) {
return Container(
padding: const EdgeInsets.all(8),
color: const Color.fromARGB(100, 169, 0, 255),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: keymap.variant
.map<Widget>((variant) => variantButton(variant, nextPage))
.toList()),
),
);
}

@ -3,7 +3,7 @@ import 'package:jade_gui/functions/location/region.dart';
import 'package:jade_gui/functions/location/location.dart'; import 'package:jade_gui/functions/location/location.dart';
import 'package:jade_gui/locales/locales.dart'; import 'package:jade_gui/locales/locales.dart';
Widget locale(next, nextPage, selectlocation, isnextpage) { Widget locale(next, nextPage, selectlocation, isnextpage, writeToLog) {
Widget widget; Widget widget;
selectlocation(getSelectedRegion()); selectlocation(getSelectedRegion());
String selectedregion = getSelectedRegion(); String selectedregion = getSelectedRegion();

@ -2,25 +2,33 @@ import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
Future<void> getPartitionInfo(currPartition, setState) async { Future<void> getPartitionInfo(
final String partitionInfo = await Process.run( currPartition, setState, runningInfo, setRunningInfo) async {
"/opt/jade_gui/scripts/getPartitionInfo.sh", ['$currPartition']) if (!runningInfo) {
.then((ProcessResult results) { final String partitionInfo = await Process.run(
return results.stdout; "/opt/jade_gui/scripts/getPartitionInfo.sh", ['$currPartition'])
}); .then((ProcessResult results) {
setState(partitionInfo); return results.stdout;
});
setState(partitionInfo);
setRunningInfo();
}
} }
Future<void> getPartitions(setState) async { Future<void> getPartitions(setState, runningPart, setRunningPart) async {
final String partitions = if (!runningPart) {
await Process.run("/opt/jade_gui/scripts/getPartitions.sh", []) final String partitions =
.then((ProcessResult result) { await Process.run("/opt/jade_gui/scripts/getPartitions.sh", [])
return result.stdout; .then((ProcessResult result) {
}); return result.stdout;
setState(partitions); });
setState(partitions);
setRunningPart();
}
} }
Widget partitionTemplate(partition, setPartition, setPartitionInfo) { Widget partitionTemplate(
partition, setPartition, setPartitionInfo, runningInfo, setRunningInfo) {
if (partition != "") { if (partition != "") {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -36,7 +44,8 @@ Widget partitionTemplate(partition, setPartition, setPartitionInfo) {
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
setPartition(partition); setPartition(partition);
getPartitionInfo(partition, setPartitionInfo); getPartitionInfo(
partition, setPartitionInfo, runningInfo, setRunningInfo);
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
primary: Colors.white, primary: Colors.white,
@ -60,10 +69,20 @@ Widget partitionTemplate(partition, setPartition, setPartitionInfo) {
} }
} }
Widget partitioning(partitions, setState, setPartition, next, setPartitionInfo, Widget partitioning(
selectedPartition, partitionInfo) { partitions,
setState,
setPartition,
next,
setPartitionInfo,
selectedPartition,
partitionInfo,
runningPart,
setRunningPart,
runningInfo,
setRunningInfo) {
return FutureBuilder( return FutureBuilder(
future: getPartitions(setState), future: getPartitions(setState, runningPart, setRunningPart),
builder: (BuildContext context, AsyncSnapshot snapshot) { builder: (BuildContext context, AsyncSnapshot snapshot) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -101,8 +120,14 @@ Widget partitioning(partitions, setState, setPartition, next, setPartitionInfo,
child: Column( child: Column(
children: partitions children: partitions
.split('\n') .split('\n')
.map<Widget>((partition) => partitionTemplate( .map<Widget>(
partition, setPartition, setPartitionInfo)) (partition) => partitionTemplate(
partition,
setPartition,
setPartitionInfo,
runningInfo,
setRunningInfo),
)
.toList(), .toList(),
), ),
), ),

@ -14,13 +14,16 @@ Widget infoTextTemplate(infoSection, infoText) {
); );
} }
Future<void> getDiskType(setState, disk) async { Future<void> getDiskType(setState, disk, running, setRunning) async {
final String partitions = if (!running) {
await Process.run("/opt/jade_gui/scripts/getDiskType.sh", [disk]) final String partitions =
.then((ProcessResult result) { await Process.run("/opt/jade_gui/scripts/getDiskType.sh", [disk])
return result.stdout; .then((ProcessResult result) {
}); return result.stdout;
setState(partitions); });
setState(partitions);
setRunning();
}
} }
String diskType(String disk, String diskType) { String diskType(String disk, String diskType) {
@ -40,24 +43,27 @@ String diskType(String disk, String diskType) {
} }
Widget summary( Widget summary(
Location locale, Location locale,
String keymap, String keymap,
String layout, String layout,
String username, String username,
bool enableSudo, bool enableSudo,
bool enableRoot, bool enableRoot,
Desktop desktop, Desktop desktop,
String disk, String disk,
bool isEfi, bool isEfi,
String bootloader, String bootloader,
String hostname, String hostname,
bool ipv6, bool ipv6,
bool enableTimeshift, bool enableTimeshift,
String rotational, String rotational,
String diskSize, String diskSize,
setDiskType, setDiskType,
nextPage) { nextPage,
getDiskType(setDiskType, disk); running,
setRunning,
) {
getDiskType(setDiskType, disk, running, setRunning);
return Column( return Column(
children: [ children: [
const Text( const Text(

@ -15,19 +15,31 @@ import 'package:jade_gui/desktops/desktops.dart';
import 'dart:io'; import 'dart:io';
Future<void> checkIsEfi(setState) async { Future<void> checkIsEfi(
final String scriptOutput = setState,
await Process.run("/opt/jade_gui/scripts/checkEfi.sh", []) runningEfi,
.then((ProcessResult result) { setRunningEfi,
return result.stdout; ) async {
}); if (!runningEfi) {
bool isEfi = scriptOutput == "UEFI\n" ? true : false; final String scriptOutput =
debugPrint(isEfi.toString()); await Process.run("/opt/jade_gui/scripts/checkEfi.sh", [])
debugPrint(scriptOutput); .then((ProcessResult result) {
setState(isEfi); return result.stdout;
});
bool isEfi = scriptOutput == "UEFI\n" ? true : false;
debugPrint(isEfi.toString());
debugPrint(scriptOutput);
setState(isEfi);
setRunningEfi();
}
} }
void writeToLog() {} Future<void> writeToLog(String message) async {
await File('/var/log/jade_log.txt').readAsString().then((String contents) {
File("/var/log/jade_log.txt").writeAsString(contents + "\n" + message);
});
}
void main() => runApp( void main() => runApp(
const MaterialApp( const MaterialApp(
@ -54,6 +66,7 @@ class Jadegui extends StatefulWidget {
} }
class _JadeguiState extends State<Jadegui> { class _JadeguiState extends State<Jadegui> {
var file = File("jade_log.txt").writeAsString("");
int _selectedIndex = 0; int _selectedIndex = 0;
bool nextpage = false; bool nextpage = false;
bool choseLayout = false; bool choseLayout = false;
@ -63,6 +76,10 @@ class _JadeguiState extends State<Jadegui> {
bool ipv6 = false; bool ipv6 = false;
bool enableTimeshift = true; bool enableTimeshift = true;
bool running = false; bool running = false;
bool runningInfo = false;
bool runningPart = false;
bool runningSum = false;
bool runningEfi = false;
String clearPass = ""; String clearPass = "";
String password = ""; String password = "";
String confirmPassword = ""; String confirmPassword = "";
@ -276,25 +293,35 @@ class _JadeguiState extends State<Jadegui> {
}); });
break; break;
case 1: case 1:
widget = locale(() { widget = locale(
setState(() { () {
_selectedIndex = _selectedIndex + 1;
});
}, () {
setState(() {
nextpage = true;
});
}, (region) {
if (region != "") {
setState(() { setState(() {
nextpage = false; _selectedIndex = _selectedIndex + 1;
}); });
} else { },
() {
setState(() { setState(() {
nextpage = true; nextpage = true;
}); });
} },
}, nextpage); (region) {
if (region != "") {
setState(() {
nextpage = false;
});
} else {
setState(() {
nextpage = true;
});
}
},
nextpage,
(value) {
writeToLog(value);
},
);
//writeToLog("locale: $region");
break; break;
case 2: case 2:
widget = keyboard( widget = keyboard(
@ -315,6 +342,9 @@ class _JadeguiState extends State<Jadegui> {
}); });
}, },
chosenLayout, chosenLayout,
(value) {
writeToLog(value);
},
); );
break; break;
case 3: case 3:
@ -322,6 +352,7 @@ class _JadeguiState extends State<Jadegui> {
(value) { (value) {
setState(() { setState(() {
enableSudo = value; enableSudo = value;
writeToLog("Enable sudo: $enableSudo");
}); });
}, },
enableSudo, enableSudo,
@ -347,12 +378,14 @@ class _JadeguiState extends State<Jadegui> {
(value) { (value) {
setState(() { setState(() {
username = value; username = value;
writeToLog("Username: $username");
}); });
}, },
username, username,
(value) { (value) {
setState(() { setState(() {
enableRoot = value; enableRoot = value;
writeToLog("Enable root: $enableRoot");
}); });
}, },
enableRoot, enableRoot,
@ -376,6 +409,7 @@ class _JadeguiState extends State<Jadegui> {
}); });
}, },
); );
break; break;
case 4: case 4:
debugPrint(password); debugPrint(password);
@ -384,6 +418,7 @@ class _JadeguiState extends State<Jadegui> {
(selectedDesktop) { (selectedDesktop) {
setState(() { setState(() {
currDesktop = selectedDesktop; currDesktop = selectedDesktop;
writeToLog("Desktop: ${selectedDesktop.name}");
}); });
}, },
() { () {
@ -398,16 +433,19 @@ class _JadeguiState extends State<Jadegui> {
(value) { (value) {
setState(() { setState(() {
ipv6 = value; ipv6 = value;
writeToLog("IPv6: $ipv6");
}); });
}, },
(value) { (value) {
setState(() { setState(() {
hostname = value; hostname = value;
writeToLog("Hostname: $hostname");
}); });
}, },
(value) { (value) {
setState(() { setState(() {
enableTimeshift = value; enableTimeshift = value;
writeToLog("Enable timeshift: $enableTimeshift");
}); });
}, },
ipv6, ipv6,
@ -426,11 +464,13 @@ class _JadeguiState extends State<Jadegui> {
(value) { (value) {
setState(() { setState(() {
disks = value; disks = value;
writeToLog("Disks: $disks");
}); });
}, },
(value) { (value) {
setState(() { setState(() {
selectedDisk = value; selectedDisk = value;
writeToLog("Selected disk: $selectedDisk");
}); });
}, },
() { () {
@ -441,18 +481,39 @@ class _JadeguiState extends State<Jadegui> {
(value) { (value) {
setState(() { setState(() {
partitionInfo = value; partitionInfo = value;
writeToLog("Partition info: $partitionInfo");
}); });
}, },
selectedDisk, selectedDisk,
partitionInfo, partitionInfo,
runningPart,
() {
setState(() {
runningPart = true;
});
},
runningInfo,
() {
setState(() {
runningInfo = true;
});
},
); );
break; break;
case 7: case 7:
checkIsEfi((value) { checkIsEfi(
setState(() { (value) {
isEfi = value; setState(() {
}); isEfi = value;
}); });
writeToLog("Is efi: $isEfi");
},
runningEfi,
() {
setState(() {
runningEfi = true;
});
});
widget = summary( widget = summary(
getSelectedLocPack(), getSelectedLocPack(),
getChosenLayout(), getChosenLayout(),
@ -472,6 +533,7 @@ class _JadeguiState extends State<Jadegui> {
(value) { (value) {
setState(() { setState(() {
_diskType = value; _diskType = value;
//writeToLog("diskType: $_diskType");
}); });
}, },
() { () {
@ -479,36 +541,47 @@ class _JadeguiState extends State<Jadegui> {
_selectedIndex = _selectedIndex + 1; _selectedIndex = _selectedIndex + 1;
}); });
}, },
runningSum,
() {
setState(() {
runningSum = true;
});
},
); );
break; break;
case 8: case 8:
widget = install( widget = install(
getSelectedLocPack(), getSelectedLocPack(),
getChosenLayout(), getChosenLayout(),
getChosenVariant(), getChosenVariant(),
username, username,
password, password,
enableSudo, enableSudo,
rootPass, rootPass,
currDesktop, currDesktop,
selectedDisk, selectedDisk,
isEfi, isEfi,
isEfi ? "grub-efi" : "grub-legacy", isEfi ? "grub-efi" : "grub-legacy",
hostname, hostname,
ipv6, ipv6,
enableTimeshift, enableTimeshift,
(value) { (value) {
setState(() { setState(() {
output = output + "\n" + value; if (value.compareTo(output) == 1) {
}); writeToLog(value.replaceAll(output, ""));
}, }
output, output = output + "\n" + value;
running, });
(value) { },
setState(() { output,
running = value; running,
}); (value) {
setState(() {
running = value;
}); });
},
writeToLog,
);
break; break;
default: default:
widget = const Text( widget = const Text(
@ -524,6 +597,4 @@ class _JadeguiState extends State<Jadegui> {
// Finally returning a Widget // Finally returning a Widget
return widget; return widget;
} }
void selectlocation(region) {}
} }

Loading…
Cancel
Save