saving progress with manual partitioning, not working yet

pull/2/head
axtlos 3 years ago
parent 60652ec436
commit 808482e21c
No known key found for this signature in database
GPG Key ID: A468AFD71DD51D4A

BIN
env

Binary file not shown.

@ -1,2 +1,3 @@
Chosen variant: normal
Disks:widget /dev/sda
/dev/nvme0n1

@ -0,0 +1,11 @@
class Partition {
final String partition;
String mountpoint;
String filesystem;
Partition({
this.partition = "",
this.mountpoint = "none",
this.filesystem = "",
});
}

@ -1,232 +1,57 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:jade_gui/functions/partitioning/auto.dart';
import 'package:jade_gui/functions/partitioning/manual.dart';
Future<void> getPartitionInfo(
currPartition, setState, runningInfo, setRunningInfo) async {
if (!runningInfo) {
final String partitionInfo = await Process.run(
"/opt/jade_gui/scripts/getPartitionInfo.sh", ['$currPartition'])
.then((ProcessResult results) {
return results.stdout;
});
setState(partitionInfo);
setRunningInfo();
}
}
Future<void> getPartitions(setState, runningPart, setRunningPart) async {
if (!runningPart) {
final String partitions =
await Process.run("/opt/jade_gui/scripts/getPartitions.sh", [])
.then((ProcessResult result) {
return result.stdout;
});
setState(partitions);
setRunningPart();
}
}
Widget partitionTemplate(
partition, setPartition, setPartitionInfo, runningInfo, setRunningInfo) {
if (partition != "") {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.black45),
color: const Color.fromARGB(255, 30, 30, 30),
),
child: ElevatedButton(
onPressed: () {
setPartition(partition);
getPartitionInfo(
partition, setPartitionInfo, runningInfo, setRunningInfo);
},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: const Color.fromARGB(0, 169, 0, 255),
shadowColor: const Color.fromARGB(0, 169, 0, 255),
padding: const EdgeInsets.all(10),
),
child: Text(
partition,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
const SizedBox(height: 10),
],
Widget partitioning(
disks,
setState,
setPartition,
next,
setPartitionInfo,
selectedPartition,
partitionInfo,
runningPart,
setRunningPart,
runningInfo,
setRunningInfo,
doManualPartitioning,
setManual,
runningPartMan,
runningInfoMan,
setRunningPartMan,
setRunningInfoMan,
setPartitions,
partitions,
setPartitionMountPoint,
) {
if (doManualPartitioning) {
setRunningInfoMan(false);
return manualPartitioning(
partitions,
setPartitions,
runningPartMan,
setRunningPartMan,
runningInfoMan,
setRunningInfoMan,
setPartitionMountPoint,
setManual,
next,
);
} else {
return const SizedBox(height: 0);
setRunningInfo(false);
setRunningPart(false);
return autoPartitioning(
disks,
setState,
setPartition,
next,
setPartitionInfo,
selectedPartition,
partitionInfo,
runningPart,
setRunningPart,
runningInfo,
setRunningInfo,
setManual);
}
}
Widget partitioning(
partitions,
setState,
setPartition,
next,
setPartitionInfo,
selectedPartition,
partitionInfo,
runningPart,
setRunningPart,
runningInfo,
setRunningInfo) {
return FutureBuilder(
future: getPartitions(setState, runningPart, setRunningPart),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Please select a disk to install to',
style: TextStyle(
fontSize: 50,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255)),
),
const SizedBox(height: 20),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(width: 100),
Expanded(
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.black),
color: const Color.fromARGB(255, 30, 30, 30),
boxShadow: const [
BoxShadow(
color: Colors.black,
blurRadius: 2,
offset: Offset(-2, 3),
),
],
),
child: SingleChildScrollView(
primary: false,
child: Column(
children: partitions
.split('\n')
.map<Widget>(
(partition) => partitionTemplate(
partition,
setPartition,
setPartitionInfo,
runningInfo,
setRunningInfo),
)
.toList(),
),
),
),
),
const SizedBox(width: 100),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.black),
color: const Color.fromARGB(255, 30, 30, 30),
boxShadow: const [
BoxShadow(
color: Colors.black,
blurRadius: 2,
offset: Offset(-2, 3),
),
],
),
child: Column(
children: [
const Text(
'Currently chosen Disk: ',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 10),
Text(
selectedPartition,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 5),
Text(
'Size: $partitionInfo',
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 5),
const Image(
image: AssetImage('assets/jade_logo.png')),
],
),
),
],
),
const SizedBox(width: 40),
],
),
),
const SizedBox(height: 20),
const SizedBox(width: 60),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Column(
children: [
TextButton(
onPressed: () {
next();
},
child: const Text(
'Next',
),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor:
const Color.fromARGB(255, 169, 0, 255),
minimumSize: const Size(100, 50),
padding: const EdgeInsets.all(10),
),
),
const SizedBox(height: 10),
],
),
const SizedBox(width: 30),
],
),
const SizedBox(height: 7)
],
),
],
);
},
);
}

@ -0,0 +1,255 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
Future<void> getDiskInfo(
currPartition, setState, runningInfo, setRunningInfo) async {
if (!runningInfo) {
final String partitionInfo = await Process.run(
"/opt/jade_gui/scripts/getDiskInfo.sh", ['$currPartition'])
.then((ProcessResult results) {
return results.stdout;
});
setState(partitionInfo);
setRunningInfo(true);
}
}
Future<void> getDisk(setState, runningDisk, setRunningDisk) async {
if (!runningDisk) {
final String disks =
await Process.run("/opt/jade_gui/scripts/getDisks.sh", [])
.then((ProcessResult result) {
return result.stdout;
});
setState(disks);
setRunningDisk(true);
}
}
Widget diskTemplate(disk, setDisk, setDiskInfo, runningInfo, setRunningInfo) {
if (disk != "") {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.black45),
color: const Color.fromARGB(255, 30, 30, 30),
),
child: ElevatedButton(
onPressed: () {
setDisk(disk);
getDiskInfo(disk, setDiskInfo, runningInfo, setRunningInfo);
},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: const Color.fromARGB(0, 169, 0, 255),
shadowColor: const Color.fromARGB(0, 169, 0, 255),
padding: const EdgeInsets.all(10),
),
child: Text(
disk,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
const SizedBox(height: 10),
],
);
} else {
return const SizedBox(height: 0);
}
}
Widget autoPartitioning(
disks,
setState,
setDisk,
next,
setDiskInfo,
selectedPartition,
diskInfo,
runningPart,
setRunningPart,
runningInfo,
setRunningInfo,
setManual) {
return FutureBuilder(
future: getDisk(setState, runningPart, setRunningPart),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Please select a disk to install to',
style: TextStyle(
fontSize: 50,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255)),
),
const SizedBox(height: 20),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(width: 100),
Expanded(
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.black),
color: const Color.fromARGB(255, 30, 30, 30),
boxShadow: const [
BoxShadow(
color: Colors.black,
blurRadius: 2,
offset: Offset(-2, 3),
),
],
),
child: SingleChildScrollView(
primary: false,
child: Column(
children: disks
.split('\n')
.map<Widget>(
(disk) => diskTemplate(disk, setDisk, setDiskInfo,
runningInfo, setRunningInfo),
)
.toList(),
),
),
),
),
const SizedBox(width: 100),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.black),
color: const Color.fromARGB(255, 30, 30, 30),
boxShadow: const [
BoxShadow(
color: Colors.black,
blurRadius: 2,
offset: Offset(-2, 3),
),
],
),
child: Column(
children: [
const Text(
'Currently chosen Disk: ',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 10),
Text(
selectedPartition,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 5),
Text(
'Size: $diskInfo',
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 5),
const Image(
image: AssetImage('assets/jade_logo.png')),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.black45),
color: const Color.fromARGB(255, 30, 30, 30),
),
child: ElevatedButton(
onPressed: () {
setManual(true);
},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor:
const Color.fromARGB(0, 169, 0, 255),
shadowColor:
const Color.fromARGB(0, 169, 0, 255),
padding: const EdgeInsets.all(10),
),
child: const Text(
"Manual Partitioning",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
],
),
const SizedBox(width: 40),
],
),
),
const SizedBox(height: 20),
const SizedBox(width: 60),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Column(
children: [
TextButton(
onPressed: () {
next();
},
child: const Text(
'Next',
),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor:
const Color.fromARGB(255, 169, 0, 255),
minimumSize: const Size(100, 50),
padding: const EdgeInsets.all(10),
),
),
const SizedBox(height: 10),
],
),
const SizedBox(width: 30),
],
),
const SizedBox(height: 7)
],
),
],
);
},
);
}

@ -0,0 +1,273 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:jade_gui/classes/partition.dart';
Future<void> getPartition(setState, runningPart, setRunningPart) async {
if (!runningPart) {
final String partitions =
await Process.run("/opt/jade_gui/scripts/getPartitions.sh", [])
.then((ProcessResult result) {
return result.stdout;
});
var parts = <Partition>[];
for (int i = 0; i < partitions.split("\n").length; i++) {
if (partitions.split("\n")[i] != "") {
parts.add(Partition(partition: partitions.split("\n")[i]));
}
}
setState(parts);
setRunningPart(true);
}
}
Widget partitionTemplate(Partition partition, runningInfo, setRunningInfo,
mountpoints, setPartitionMountpoint) {
String mount = "none";
if (partition != "") {
print(partition.mountpoint);
print(partition.mountpoint);
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.black45),
color: const Color.fromARGB(255, 30, 30, 30),
),
child: Row(
children: [
Text(
partition.partition,
style: const TextStyle(
fontWeight: FontWeight.bold, color: Colors.white),
),
Expanded(
child: Container(),
),
DropdownButton<String>(
value: mount,
icon: const Icon(Icons.arrow_downward),
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String? newValue) {
setPartitionMountpoint(
partition, newValue == "" ? "none" : newValue);
mount = newValue == "" ? "none" : newValue!;
},
items:
mountpoints.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
],
)),
const SizedBox(height: 10),
],
);
} else {
return const SizedBox(height: 0);
}
}
Widget manualPartitioning(partitions, setState, runningPart, setRunningPart,
runningInfo, setRunningInfo, setPartitionMountpoint, setManual, next) {
var mountpoints = <String>[
"none",
"/",
"/boot",
"/efi",
"/boot/efi",
"/home",
"/opt",
"/tmp",
"/usr",
"/var"
];
return FutureBuilder(
future: getPartition(setState, runningPart, setRunningPart),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Please select a disk to install to',
style: TextStyle(
fontSize: 50,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255)),
),
const SizedBox(height: 20),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(width: 100),
Expanded(
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.black),
color: const Color.fromARGB(255, 30, 30, 30),
boxShadow: const [
BoxShadow(
color: Colors.black,
blurRadius: 2,
offset: Offset(-2, 3),
),
],
),
child: SingleChildScrollView(
primary: false,
child: Column(
children: partitions
.map<Widget>(
(partition) => partitionTemplate(
partition,
runningInfo,
setRunningInfo,
mountpoints,
setPartitionMountpoint,
),
)
.toList(),
),
),
),
),
const SizedBox(width: 100),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.black),
color: const Color.fromARGB(255, 30, 30, 30),
boxShadow: const [
BoxShadow(
color: Colors.black,
blurRadius: 2,
offset: Offset(-2, 3),
),
],
),
child: Column(
children: [
const Text(
'Currently chosen Disk: ',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 10),
const Text(
"selectedPartition",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 5),
const Text(
'Size: diskInfo',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 169, 0, 255),
),
),
const SizedBox(height: 5),
const Image(
image: AssetImage('assets/jade_logo.png')),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.black45),
color: const Color.fromARGB(255, 30, 30, 30),
),
child: ElevatedButton(
onPressed: () {
setManual(false);
},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor:
const Color.fromARGB(0, 169, 0, 255),
shadowColor:
const Color.fromARGB(0, 169, 0, 255),
padding: const EdgeInsets.all(10),
),
child: const Text(
"Auto Partitioning",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
],
),
const SizedBox(width: 40),
],
),
),
const SizedBox(height: 20),
const SizedBox(width: 60),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Column(
children: [
TextButton(
onPressed: () {
next();
},
child: const Text(
'Next',
),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor:
const Color.fromARGB(255, 169, 0, 255),
minimumSize: const Size(100, 50),
padding: const EdgeInsets.all(10),
),
),
const SizedBox(height: 10),
],
),
const SizedBox(width: 30),
],
),
const SizedBox(height: 7)
],
),
],
);
},
);
}

@ -11,6 +11,7 @@ import 'package:jade_gui/functions/install.dart';
import 'package:jade_gui/classes/keymap.dart';
import 'package:jade_gui/classes/desktop.dart';
import 'package:jade_gui/desktops/desktops.dart';
import 'package:jade_gui/classes/partition.dart';
import 'package:window_size/window_size.dart';
import 'dart:io';
@ -98,9 +99,12 @@ class _JadeguiState extends State<Jadegui> {
bool ipv6 = false;
bool enableTimeshift = true;
bool connected = false;
bool manualPartitioning = false;
bool running = false;
bool runningInfo = false;
bool runningPart = false;
bool runningInfoMan = false;
bool runningPartMan = false;
bool runningSum = false;
bool runningEfi = false;
String clearPass = "";
@ -111,12 +115,13 @@ class _JadeguiState extends State<Jadegui> {
String confirmRootPass = "";
String disks = "";
String selectedDisk = "";
String partitionInfo = "";
String diskInfo = "";
String _diskType = "";
String hostname = "";
String output = "";
Desktop currDesktop = desktops[0];
Keymap chosenLayout = Keymap();
List<Partition> partitions = [];
@override
Widget build(BuildContext context) {
@ -565,22 +570,60 @@ class _JadeguiState extends State<Jadegui> {
},
(value) {
setState(() {
partitionInfo = value;
writeToLog("Partition info: $partitionInfo");
diskInfo = value;
writeToLog("Partition info: $diskInfo");
});
},
selectedDisk,
partitionInfo,
diskInfo,
runningPart,
() {
(value) {
setState(() {
runningPart = true;
runningPart = value;
});
},
runningInfo,
() {
(value) {
setState(() {
runningInfo = value;
});
},
manualPartitioning,
(value) {
setState(() {
manualPartitioning = value;
});
},
runningInfoMan,
runningPartMan,
(value) {
setState(() {
runningPartMan = value;
});
},
(value) {
setState(() {
runningInfoMan = value;
});
},
(value) {
setState(() {
partitions = value;
});
},
partitions,
(partition, value) {
setState(() {
runningInfo = true;
/*for (int i = 0; i < partitions.length; i++) {
if (partitions[i].partition == partition.partition) {
partitions[i].mountpoint = value;
print("moutnpoint: ${partitions[i].mountpoint}");
print("partition: ${partitions[i].partition}");
}
}*/
partition.mountpoint = value;
print("moutnpoint: ${partition.mountpoint}");
print("partition: ${partition.partition}");
});
},
),
@ -624,11 +667,10 @@ class _JadeguiState extends State<Jadegui> {
ipv6,
enableTimeshift,
_diskType,
partitionInfo,
diskInfo,
(value) {
setState(() {
_diskType = value;
//writeToLog("diskType: $_diskType");
});
},
() {

@ -0,0 +1 @@
/nix/store/mi38zzxcylfc1jwnbbjyln959k1yjl9b-coreutils-9.0/bin/env

@ -0,0 +1,2 @@
#!/usr/bin/bash
lsblk -pdo name | grep -v zram | grep -v NAME | grep -v loop | grep -v sr

@ -1,2 +1,2 @@
#!/usr/bin/bash
lsblk -pdo name | grep -v zram | grep -v NAME | grep -v loop | grep -v sr
blkid -o device | grep -v zram | grep -v loop | grep -v sr
Loading…
Cancel
Save