mirror of
https://github.com/Metabolix/HackBGRT.git
synced 2026-09-25 21:41:22 -07:00
Support dry run in the installer
This commit is contained in:
@@ -48,6 +48,8 @@ If you need it for other systems as well:
|
|||||||
* Run `setup.exe`, install files.
|
* Run `setup.exe`, install files.
|
||||||
* Set `\EFI\HackBGRT\loader.efi` as your default boot loader with `efibootmgr` or some other EFI boot manager tool.
|
* Set `\EFI\HackBGRT\loader.efi` as your default boot loader with `efibootmgr` or some other EFI boot manager tool.
|
||||||
|
|
||||||
|
To install purely on Linux, you can install with `setup.exe dry-run` and then manually copy files from `dry-run/EFI` to your `[EFI System Partition]/EFI`. For further instructions, consult the documentation of your own Linux system.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
The configuration options are described in `config.txt`, which the installer copies into `[EFI System Partition]\EFI\HackBGRT\config.txt`.
|
The configuration options are described in `config.txt`, which the installer copies into `[EFI System Partition]\EFI\HackBGRT\config.txt`.
|
||||||
|
|||||||
+14
-3
@@ -59,6 +59,9 @@ public class Setup: SetupHelper {
|
|||||||
/** @var The EFI architecture identifier. */
|
/** @var The EFI architecture identifier. */
|
||||||
protected string EfiArch;
|
protected string EfiArch;
|
||||||
|
|
||||||
|
/** @var Dry run? */
|
||||||
|
protected bool DryRun;
|
||||||
|
|
||||||
/** @var Run in batch mode? */
|
/** @var Run in batch mode? */
|
||||||
protected bool Batch;
|
protected bool Batch;
|
||||||
|
|
||||||
@@ -66,6 +69,10 @@ public class Setup: SetupHelper {
|
|||||||
* Find or mount or manually choose the EFI System Partition.
|
* Find or mount or manually choose the EFI System Partition.
|
||||||
*/
|
*/
|
||||||
protected void InitEspPath() {
|
protected void InitEspPath() {
|
||||||
|
if (DryRun) {
|
||||||
|
Directory.CreateDirectory(Path.Combine("dry-run", "EFI"));
|
||||||
|
Esp.TryPath("dry-run", false);
|
||||||
|
}
|
||||||
if (Esp.Location == null && !Esp.Find() && !Esp.Mount() && !Batch) {
|
if (Esp.Location == null && !Esp.Find() && !Esp.Mount() && !Batch) {
|
||||||
Console.WriteLine("EFI System Partition was not found.");
|
Console.WriteLine("EFI System Partition was not found.");
|
||||||
Console.WriteLine("Press enter to exit, or give ESP path here: ");
|
Console.WriteLine("Press enter to exit, or give ESP path here: ");
|
||||||
@@ -276,7 +283,7 @@ public class Setup: SetupHelper {
|
|||||||
RestoreMsLoader();
|
RestoreMsLoader();
|
||||||
try {
|
try {
|
||||||
Directory.Delete(InstallPath, true);
|
Directory.Delete(InstallPath, true);
|
||||||
Console.WriteLine("HackBGRT has been removed.");
|
Console.WriteLine($"HackBGRT has been removed from {InstallPath}.");
|
||||||
} catch {
|
} catch {
|
||||||
throw new SetupException($"The directory {InstallPath} couldn't be removed.");
|
throw new SetupException($"The directory {InstallPath} couldn't be removed.");
|
||||||
}
|
}
|
||||||
@@ -425,13 +432,14 @@ public class Setup: SetupHelper {
|
|||||||
* @param args The arguments.
|
* @param args The arguments.
|
||||||
*/
|
*/
|
||||||
protected int Run(string[] args) {
|
protected int Run(string[] args) {
|
||||||
|
DryRun = args.Contains("dry-run");
|
||||||
Batch = args.Contains("batch");
|
Batch = args.Contains("batch");
|
||||||
try {
|
try {
|
||||||
if (args.Contains("is-elevated") && !HasPrivileges()) {
|
if (args.Contains("is-elevated") && !HasPrivileges() && !DryRun) {
|
||||||
Console.WriteLine("This installer needs to be run as administrator!");
|
Console.WriteLine("This installer needs to be run as administrator!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!HasPrivileges()) {
|
if (!HasPrivileges() && !DryRun) {
|
||||||
var self = Assembly.GetExecutingAssembly().Location;
|
var self = Assembly.GetExecutingAssembly().Location;
|
||||||
return RunElevated(self, String.Join(" ", args.Prepend("is-elevated")));
|
return RunElevated(self, String.Join(" ", args.Prepend("is-elevated")));
|
||||||
}
|
}
|
||||||
@@ -457,6 +465,9 @@ public class Setup: SetupHelper {
|
|||||||
Console.WriteLine("If this is the most current release, please report this bug.");
|
Console.WriteLine("If this is the most current release, please report this bug.");
|
||||||
return 1;
|
return 1;
|
||||||
} finally {
|
} finally {
|
||||||
|
if (DryRun) {
|
||||||
|
Console.WriteLine("This was a dry run, your system was not actually modified.");
|
||||||
|
}
|
||||||
if (!Batch) {
|
if (!Batch) {
|
||||||
Console.WriteLine("Press any key to quit.");
|
Console.WriteLine("Press any key to quit.");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
|
|||||||
Reference in New Issue
Block a user