mirror of
https://github.com/Metabolix/HackBGRT.git
synced 2025-12-06 17:15:42 -08: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.
|
||||
* 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
|
||||
|
||||
The configuration options are described in `config.txt`, which the installer copies into `[EFI System Partition]\EFI\HackBGRT\config.txt`.
|
||||
|
||||
17
src/Setup.cs
17
src/Setup.cs
@@ -59,6 +59,9 @@ public class Setup: SetupHelper {
|
||||
/** @var The EFI architecture identifier. */
|
||||
protected string EfiArch;
|
||||
|
||||
/** @var Dry run? */
|
||||
protected bool DryRun;
|
||||
|
||||
/** @var Run in batch mode? */
|
||||
protected bool Batch;
|
||||
|
||||
@@ -66,6 +69,10 @@ public class Setup: SetupHelper {
|
||||
* Find or mount or manually choose the EFI System Partition.
|
||||
*/
|
||||
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) {
|
||||
Console.WriteLine("EFI System Partition was not found.");
|
||||
Console.WriteLine("Press enter to exit, or give ESP path here: ");
|
||||
@@ -276,7 +283,7 @@ public class Setup: SetupHelper {
|
||||
RestoreMsLoader();
|
||||
try {
|
||||
Directory.Delete(InstallPath, true);
|
||||
Console.WriteLine("HackBGRT has been removed.");
|
||||
Console.WriteLine($"HackBGRT has been removed from {InstallPath}.");
|
||||
} catch {
|
||||
throw new SetupException($"The directory {InstallPath} couldn't be removed.");
|
||||
}
|
||||
@@ -425,13 +432,14 @@ public class Setup: SetupHelper {
|
||||
* @param args The arguments.
|
||||
*/
|
||||
protected int Run(string[] args) {
|
||||
DryRun = args.Contains("dry-run");
|
||||
Batch = args.Contains("batch");
|
||||
try {
|
||||
if (args.Contains("is-elevated") && !HasPrivileges()) {
|
||||
if (args.Contains("is-elevated") && !HasPrivileges() && !DryRun) {
|
||||
Console.WriteLine("This installer needs to be run as administrator!");
|
||||
return 1;
|
||||
}
|
||||
if (!HasPrivileges()) {
|
||||
if (!HasPrivileges() && !DryRun) {
|
||||
var self = Assembly.GetExecutingAssembly().Location;
|
||||
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.");
|
||||
return 1;
|
||||
} finally {
|
||||
if (DryRun) {
|
||||
Console.WriteLine("This was a dry run, your system was not actually modified.");
|
||||
}
|
||||
if (!Batch) {
|
||||
Console.WriteLine("Press any key to quit.");
|
||||
Console.ReadKey();
|
||||
|
||||
Reference in New Issue
Block a user