@@ -50,16 +50,17 @@ impl Display for Filesystem {
50
50
}
51
51
}
52
52
53
- #[ derive( clap:: ValueEnum , Debug , Copy , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
53
+ #[ derive( clap:: ValueEnum , Default , Debug , Copy , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
54
54
#[ serde( rename_all = "kebab-case" ) ]
55
55
pub ( crate ) enum BlockSetup {
56
+ #[ default]
56
57
Direct ,
57
58
Tpm2Luks ,
58
59
}
59
60
60
- impl Default for BlockSetup {
61
- fn default ( ) -> Self {
62
- Self :: Direct
61
+ impl Display for BlockSetup {
62
+ fn fmt ( & self , f : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result {
63
+ self . to_possible_value ( ) . unwrap ( ) . get_name ( ) . fmt ( f )
63
64
}
64
65
}
65
66
@@ -113,11 +114,14 @@ fn sgdisk_partition(
113
114
fn mkfs < ' a > (
114
115
dev : & str ,
115
116
fs : Filesystem ,
116
- label : Option < & ' _ str > ,
117
+ label : & str ,
117
118
opts : impl IntoIterator < Item = & ' a str > ,
118
119
) -> Result < uuid:: Uuid > {
119
120
let u = uuid:: Uuid :: new_v4 ( ) ;
120
- let mut t = Task :: new ( "Creating filesystem" , format ! ( "mkfs.{fs}" ) ) ;
121
+ let mut t = Task :: new (
122
+ & format ! ( "Creating {label} filesystem ({fs})" ) ,
123
+ format ! ( "mkfs.{fs}" ) ,
124
+ ) ;
121
125
match fs {
122
126
Filesystem :: Xfs => {
123
127
t. cmd . arg ( "-m" ) ;
@@ -129,14 +133,13 @@ fn mkfs<'a>(
129
133
}
130
134
} ;
131
135
// Today all the above mkfs commands take -L
132
- if let Some ( label) = label {
133
- t. cmd . args ( [ "-L" , label] ) ;
134
- }
136
+ t. cmd . args ( [ "-L" , label] ) ;
135
137
t. cmd . args ( opts) ;
136
138
t. cmd . arg ( dev) ;
137
139
// All the mkfs commands are unnecessarily noisy by default
138
140
t. cmd . stdout ( Stdio :: null ( ) ) ;
139
- t. run ( ) ?;
141
+ // But this one is notable so let's print the whole thing with verbose()
142
+ t. verbose ( ) . run ( ) ?;
140
143
Ok ( u)
141
144
}
142
145
@@ -196,6 +199,20 @@ pub(crate) fn install_create_rootfs(
196
199
. context ( "Absolute device path in /dev/ required" ) ?;
197
200
let device = devdir. join ( reldevice) ;
198
201
202
+ // Use the install configuration to find the block setup, if we have one
203
+ let block_setup = if let Some ( config) = state. install_config . as_ref ( ) {
204
+ config. get_block_setup ( opts. block_setup . as_ref ( ) . copied ( ) ) ?
205
+ } else if opts. filesystem . is_some ( ) {
206
+ // Otherwise, if a filesystem is specified then we default to whatever was
207
+ // specified via --block-setup, or the default
208
+ opts. block_setup . unwrap_or_default ( )
209
+ } else {
210
+ // If there was no default filesystem, then there's no default block setup,
211
+ // and we need to error out.
212
+ anyhow:: bail!( "No install configuration found, and no filesystem specified" )
213
+ } ;
214
+ println ! ( "Using block setup: {block_setup}" ) ;
215
+
199
216
let root_size = opts
200
217
. root_size
201
218
. as_deref ( )
@@ -305,18 +322,7 @@ pub(crate) fn install_create_rootfs(
305
322
} ;
306
323
307
324
let base_rootdev = findpart ( ROOTPN ) ?;
308
- // Use the install configuration to find the block setup, if we have one
309
- let block_setup = if let Some ( config) = state. install_config . as_ref ( ) {
310
- config. get_block_setup ( opts. block_setup . as_ref ( ) . copied ( ) ) ?
311
- } else if opts. filesystem . is_some ( ) {
312
- // Otherwise, if a filesystem is specified then we default to whatever was
313
- // specified via --block-setup, or the default
314
- opts. block_setup . unwrap_or_default ( )
315
- } else {
316
- // If there was no default filesystem, then there's no default block setup,
317
- // and we need to error out.
318
- anyhow:: bail!( "No install configuration found, and no filesystem specified" )
319
- } ;
325
+
320
326
let ( rootdev, root_blockdev_kargs) = match block_setup {
321
327
BlockSetup :: Direct => ( base_rootdev, None ) ,
322
328
BlockSetup :: Tpm2Luks => {
@@ -335,10 +341,12 @@ pub(crate) fn install_create_rootfs(
335
341
. args ( [ base_rootdev. as_str ( ) ] )
336
342
. run ( ) ?;
337
343
// The --wipe-slot=all removes our temporary passphrase, and binds to the local TPM device.
344
+ // We also use .verbose() here as the details are important/notable.
338
345
Task :: new ( "Enrolling root device with TPM" , "systemd-cryptenroll" )
339
346
. args ( [ "--wipe-slot=all" , "--tpm2-device=auto" , "--unlock-key-file" ] )
340
347
. args ( [ tmp_keyfile] )
341
348
. args ( [ base_rootdev. as_str ( ) ] )
349
+ . verbose ( )
342
350
. run_with_stdin_buf ( dummy_passphrase_input) ?;
343
351
Task :: new ( "Opening root LUKS device" , "cryptsetup" )
344
352
. args ( [ "luksOpen" , base_rootdev. as_str ( ) , luks_name] )
@@ -357,10 +365,10 @@ pub(crate) fn install_create_rootfs(
357
365
358
366
// Initialize the /boot filesystem
359
367
let bootdev = & findpart ( BOOTPN ) ?;
360
- let boot_uuid = mkfs ( bootdev, bootfs_type, Some ( "boot" ) , [ ] ) . context ( "Initializing /boot" ) ?;
368
+ let boot_uuid = mkfs ( bootdev, bootfs_type, "boot" , [ ] ) . context ( "Initializing /boot" ) ?;
361
369
362
370
// Initialize rootfs
363
- let root_uuid = mkfs ( & rootdev, root_filesystem, Some ( "root" ) , [ ] ) ?;
371
+ let root_uuid = mkfs ( & rootdev, root_filesystem, "root" , [ ] ) ?;
364
372
let rootarg = format ! ( "root=UUID={root_uuid}" ) ;
365
373
let bootsrc = format ! ( "UUID={boot_uuid}" ) ;
366
374
let bootarg = format ! ( "boot={bootsrc}" ) ;
0 commit comments