|
| 1 | +From e37bd5d256c02f2a7693ec220322cf131e8e5274 Mon Sep 17 00:00:00 2001 |
| 2 | +From: jbtrystram < [email protected]> |
| 3 | +Date: Thu, 17 Jul 2025 15:59:27 +0200 |
| 4 | +Subject: [PATCH] stages/ignition: parametrize the path to boot |
| 5 | + |
| 6 | +Allow passing a mount to specify where to write the igntion.firstboot |
| 7 | +file. |
| 8 | +This keeps the default `tree:///` value to not break existing stages. |
| 9 | +--- |
| 10 | + stages/org.osbuild.ignition | 13 ++++++++----- |
| 11 | + stages/org.osbuild.ignition.meta.json | 5 +++++ |
| 12 | + 2 files changed, 13 insertions(+), 5 deletions(-) |
| 13 | + |
| 14 | +diff --git a/stages/org.osbuild.ignition b/stages/org.osbuild.ignition |
| 15 | +index 23f91c48..4466cabf 100755 |
| 16 | +--- a/stages/org.osbuild.ignition |
| 17 | ++++ b/stages/org.osbuild.ignition |
| 18 | +@@ -2,18 +2,17 @@ |
| 19 | + import sys |
| 20 | + |
| 21 | + import osbuild.api |
| 22 | ++from osbuild.util import parsing |
| 23 | + |
| 24 | + |
| 25 | +-def main(tree, options): |
| 26 | +- network = options.get("network", []) |
| 27 | +- |
| 28 | ++def main(network, location): |
| 29 | + # grub, when detecting the '/boot/ignition.firstboot' file |
| 30 | + # will set the "ignition_firstboot" option so that ignition |
| 31 | + # gets triggered during that boot. Additionally, the file |
| 32 | + # itself will be sourced this the 'ignition_network_kcmdline' |
| 33 | + # that is also in the "ignition_firstboot" variable can be |
| 34 | + # overwritten with the contents of `network` |
| 35 | +- with open(f"{tree}/boot/ignition.firstboot", "w", encoding="utf8") as f: |
| 36 | ++ with open(f"{location}/ignition.firstboot", "w", encoding="utf8") as f: |
| 37 | + if network: |
| 38 | + netstr = " ".join(network) |
| 39 | + f.write(f"set ignition_network_kcmdline='{netstr}'") |
| 40 | +@@ -23,5 +22,9 @@ def main(tree, options): |
| 41 | + |
| 42 | + if __name__ == '__main__': |
| 43 | + args = osbuild.api.arguments() |
| 44 | +- r = main(args["tree"], args.get("options", {})) |
| 45 | ++ options = args.get("options", {}) |
| 46 | ++ target = options.get("target", "tree:///boot") |
| 47 | ++ location = parsing.parse_location(target, args) |
| 48 | ++ network = options.get("network", []) |
| 49 | ++ r = main(network, location) |
| 50 | + sys.exit(r) |
| 51 | +diff --git a/stages/org.osbuild.ignition.meta.json b/stages/org.osbuild.ignition.meta.json |
| 52 | +index 612d59c7..dd295c24 100644 |
| 53 | +--- a/stages/org.osbuild.ignition.meta.json |
| 54 | ++++ b/stages/org.osbuild.ignition.meta.json |
| 55 | +@@ -22,6 +22,11 @@ |
| 56 | + "items": { |
| 57 | + "type": "string" |
| 58 | + } |
| 59 | ++ }, |
| 60 | ++ "target": { |
| 61 | ++ "type": "string", |
| 62 | ++ "description": "Location to write the 'ignition.firstboot' file.", |
| 63 | ++ "default": "tree:///boot" |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | +-- |
| 68 | +2.50.1 |
| 69 | + |
0 commit comments