@@ -82,22 +82,8 @@ const PREPPN: u32 = 1;
82
82
#[ cfg( target_arch = "ppc64" ) ]
83
83
const RESERVEDPN : u32 = 1 ;
84
84
85
- /// Perform an upgrade operation
86
- #[ derive( Debug , Clone , clap:: Parser ) ]
87
- pub ( crate ) struct InstallOpts {
88
- /// Target block device for installation. The entire device will be wiped.
89
- pub ( crate ) device : Utf8PathBuf ,
90
-
91
- /// Automatically wipe all existing data on device
92
- #[ clap( long) ]
93
- pub ( crate ) wipe : bool ,
94
-
95
- /// Size of the root partition (default specifier: M). Allowed specifiers: M (mebibytes), G (gibibytes), T (tebibytes).
96
- ///
97
- /// By default, all remaining space on the disk will be used.
98
- #[ clap( long) ]
99
- pub ( crate ) root_size : Option < String > ,
100
-
85
+ #[ derive( clap:: Args , Debug , Clone ) ]
86
+ pub ( crate ) struct InstallTargetOpts {
101
87
// TODO: A size specifier which allocates free space for the root in *addition* to the base container image size
102
88
// pub(crate) root_additional_size: Option<String>
103
89
/// The transport; e.g. oci, oci-archive. Defaults to `registry`.
@@ -115,11 +101,10 @@ pub(crate) struct InstallOpts {
115
101
/// Enable verification via an ostree remote
116
102
#[ clap( long) ]
117
103
pub ( crate ) target_ostree_remote : Option < String > ,
104
+ }
118
105
119
- /// Target root filesystem type.
120
- #[ clap( long, value_enum, default_value_t) ]
121
- pub ( crate ) filesystem : Filesystem ,
122
-
106
+ #[ derive( clap:: Args , Debug , Clone ) ]
107
+ pub ( crate ) struct InstallConfigOpts {
123
108
/// Path to an Ignition config file
124
109
#[ clap( long, value_parser) ]
125
110
pub ( crate ) ignition_file : Option < Utf8PathBuf > ,
@@ -131,13 +116,6 @@ pub(crate) struct InstallOpts {
131
116
#[ clap( long, value_name = "digest" , value_parser) ]
132
117
pub ( crate ) ignition_hash : Option < crate :: ignition:: IgnitionHash > ,
133
118
134
- /// Target root block device setup.
135
- ///
136
- /// direct: Filesystem written directly to block device
137
- /// tpm2-luks: Bind unlock of filesystem to presence of the default tpm2 device.
138
- #[ clap( long, value_enum, default_value_t) ]
139
- pub ( crate ) block_setup : BlockSetup ,
140
-
141
119
/// Disable SELinux in the target (installed) system.
142
120
///
143
121
/// This is currently necessary to install *from* a system with SELinux disabled
@@ -154,6 +132,40 @@ pub(crate) struct InstallOpts {
154
132
karg : Option < Vec < String > > ,
155
133
}
156
134
135
+ /// Perform an upgrade operation
136
+ #[ derive( Debug , Clone , clap:: Parser ) ]
137
+ pub ( crate ) struct InstallOpts {
138
+ /// Target block device for installation. The entire device will be wiped.
139
+ pub ( crate ) device : Utf8PathBuf ,
140
+
141
+ /// Automatically wipe all existing data on device
142
+ #[ clap( long) ]
143
+ pub ( crate ) wipe : bool ,
144
+
145
+ /// Target root block device setup.
146
+ ///
147
+ /// direct: Filesystem written directly to block device
148
+ /// tpm2-luks: Bind unlock of filesystem to presence of the default tpm2 device.
149
+ #[ clap( long, value_enum, default_value_t) ]
150
+ pub ( crate ) block_setup : BlockSetup ,
151
+
152
+ /// Size of the root partition (default specifier: M). Allowed specifiers: M (mebibytes), G (gibibytes), T (tebibytes).
153
+ ///
154
+ /// By default, all remaining space on the disk will be used.
155
+ #[ clap( long) ]
156
+ pub ( crate ) root_size : Option < String > ,
157
+
158
+ /// Target root filesystem type.
159
+ #[ clap( long, value_enum, default_value_t) ]
160
+ pub ( crate ) filesystem : Filesystem ,
161
+
162
+ #[ clap( flatten) ]
163
+ pub ( crate ) target_opts : InstallTargetOpts ,
164
+
165
+ #[ clap( flatten) ]
166
+ pub ( crate ) config_opts : InstallConfigOpts ,
167
+ }
168
+
157
169
// Shared read-only global state
158
170
struct State {
159
171
opts : InstallOpts ,
@@ -278,15 +290,16 @@ async fn initialize_ostree_root_from_self(
278
290
} ;
279
291
280
292
// Parse the target CLI image reference options
281
- let target_sigverify = if opts. target_no_signature_verification {
293
+ let target_sigverify = if opts. target_opts . target_no_signature_verification {
282
294
SignatureSource :: ContainerPolicyAllowInsecure
283
- } else if let Some ( remote) = opts. target_ostree_remote . as_deref ( ) {
295
+ } else if let Some ( remote) = opts. target_opts . target_ostree_remote . as_deref ( ) {
284
296
SignatureSource :: OstreeRemote ( remote. to_string ( ) )
285
297
} else {
286
298
SignatureSource :: ContainerPolicy
287
299
} ;
288
- let target_imgref = if let Some ( imgref) = opts. target_imgref . as_ref ( ) {
289
- let transport = ostree_container:: Transport :: try_from ( opts. target_transport . as_str ( ) ) ?;
300
+ let target_imgref = if let Some ( imgref) = opts. target_opts . target_imgref . as_ref ( ) {
301
+ let transport =
302
+ ostree_container:: Transport :: try_from ( opts. target_opts . target_transport . as_str ( ) ) ?;
290
303
let imgref = ostree_container:: ImageReference {
291
304
transport,
292
305
name : imgref. to_string ( ) ,
@@ -725,7 +738,7 @@ pub(crate) async fn install(opts: InstallOpts) -> Result<()> {
725
738
crate :: lsm:: container_setup_selinux ( ) ?;
726
739
// This will re-execute the current process (once).
727
740
crate :: lsm:: selinux_ensure_install ( ) ?;
728
- } else if opts. disable_selinux {
741
+ } else if opts. config_opts . disable_selinux {
729
742
override_disable_selinux = true ;
730
743
println ! ( "notice: Target has SELinux enabled, overriding to disable" )
731
744
} else {
@@ -770,7 +783,7 @@ pub(crate) async fn install(opts: InstallOpts) -> Result<()> {
770
783
kargs. push ( "selinux=0" ) ;
771
784
}
772
785
// This is interpreted by our GRUB fragment
773
- if state. opts . ignition_file . is_some ( ) {
786
+ if state. opts . config_opts . ignition_file . is_some ( ) {
774
787
kargs. push ( crate :: ignition:: PLATFORM_METAL_KARG ) ;
775
788
kargs. push ( crate :: bootloader:: IGNITION_VARIABLE ) ;
776
789
}
@@ -792,11 +805,11 @@ pub(crate) async fn install(opts: InstallOpts) -> Result<()> {
792
805
crate :: bootloader:: install_via_bootupd ( & rootfs. device , & rootfs. rootfs , & rootfs. boot_uuid ) ?;
793
806
794
807
// If Ignition is specified, enable it
795
- if let Some ( ignition_file) = state. opts . ignition_file . as_deref ( ) {
808
+ if let Some ( ignition_file) = state. opts . config_opts . ignition_file . as_deref ( ) {
796
809
let src = std:: fs:: File :: open ( ignition_file)
797
810
. with_context ( || format ! ( "Opening {ignition_file}" ) ) ?;
798
811
let bootfs = rootfs. rootfs . join ( "boot" ) ;
799
- crate :: ignition:: write_ignition ( & bootfs, & state. opts . ignition_hash , & src) ?;
812
+ crate :: ignition:: write_ignition ( & bootfs, & state. opts . config_opts . ignition_hash , & src) ?;
800
813
crate :: ignition:: enable_firstboot ( & bootfs) ?;
801
814
println ! ( "Installed Ignition config from {ignition_file}" ) ;
802
815
}
0 commit comments