From 785307c0e2da48c1f66f1170aa50177c9a2817cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20Kentt=C3=A4?= Date: Fri, 21 Mar 2025 19:33:31 +0200 Subject: [PATCH] Allow overriding ESP path --- README.md | 1 + src/Setup.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bce193b..1dcf4e4 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ The *shim* boot loader is maintained by Red Hat, Inc, and the included signed co * `uninstall` – disable and remove completely. * `show-boot-log` – show the debug log collected during boot (if `log=1` is set in `config.txt`). * `arch=...` – force architecture. + * `esp=...` – force EFI System Partition path. * `dry-run` – skip actual changes. * For example, run `setup.exe batch install allow-secure-boot enable-overwrite` to copy files and overwrite the MS boot loader regardless of Secure Boot status. diff --git a/src/Setup.cs b/src/Setup.cs index f89ba9f..6a5eba1 100644 --- a/src/Setup.cs +++ b/src/Setup.cs @@ -106,6 +106,9 @@ public class Setup { /** @var Dry run? */ protected bool DryRun; + /** @var User-defined ESP path */ + protected string UserEspPath; + /** @var Run in batch mode? */ protected bool Batch; @@ -289,6 +292,11 @@ public class Setup { if (DryRun) { Directory.CreateDirectory(Path.Combine("dry-run", "EFI")); Esp.TryPath("dry-run", false); + } else if (UserEspPath != null) { + WriteLine($"Using user-defined ESP path: {UserEspPath}"); + if (!Esp.TryPath(UserEspPath, false)) { + throw new SetupException("The ESP path doesn't look like an EFI System Partition."); + } } if (Esp.Location == null && !Esp.Find() && !Esp.Mount() && !Batch) { WriteLine("EFI System Partition was not found."); @@ -1045,7 +1053,7 @@ public class Setup { AllowSecureBoot = args.Contains("allow-secure-boot"); AllowBitLocker = args.Contains("allow-bitlocker"); SkipShim = args.Contains("skip-shim"); - ForwardArguments = String.Join(" ", args.Where(s => ForwardableArguments.Contains(s) || s.StartsWith("arch="))); + ForwardArguments = String.Join(" ", args.Where(s => ForwardableArguments.Contains(s) || s.StartsWith("arch=") || s.StartsWith("esp="))); try { if (!(Directory.Exists("efi") || Directory.Exists("efi-signed")) || !File.Exists("config.txt")) { WriteLine("This setup program is not in the correct directory!"); @@ -1053,6 +1061,7 @@ public class Setup { return 1; } SetArch(args.Where(s => s.StartsWith("arch=")).Select(s => s.Substring(5)).LastOrDefault()); + UserEspPath = args.Where(s => s.StartsWith("esp=")).Select(s => s.Substring(4)).LastOrDefault(); if (args.Contains("is-elevated") && !HasPrivileges() && !DryRun) { WriteLine("This installer needs to be run as administrator!"); return 1;