File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -574,11 +574,10 @@ fn install_create_rootfs(state: &State) -> Result<RootSetup> {
574
574
575
575
// Create the EFI system partition, if applicable
576
576
if let Some ( espdev) = espdev {
577
- Task :: new_and_run (
578
- "Creating ESP filesystem" ,
579
- "mkfs.fat" ,
580
- [ espdev. as_str ( ) , "-n" , "EFI-SYSTEM" ] ,
581
- ) ?;
577
+ Task :: new ( "Creating ESP filesystem" , "mkfs.fat" )
578
+ . args ( [ espdev. as_str ( ) , "-n" , "EFI-SYSTEM" ] )
579
+ . quiet_output ( )
580
+ . run ( ) ?;
582
581
let efifs_path = bootfs. join ( "efi" ) ;
583
582
std:: fs:: create_dir ( & efifs_path) . context ( "Creating efi dir" ) ?;
584
583
mount ( & espdev, & efifs_path) ?;
Original file line number Diff line number Diff line change 1
1
use std:: {
2
2
ffi:: OsStr ,
3
+ io:: Seek ,
3
4
process:: { Command , Stdio } ,
4
5
} ;
5
6
@@ -8,6 +9,7 @@ use anyhow::{Context, Result};
8
9
pub ( crate ) struct Task {
9
10
description : String ,
10
11
quiet : bool ,
12
+ quiet_output : bool ,
11
13
pub ( crate ) cmd : Command ,
12
14
}
13
15
@@ -23,6 +25,7 @@ impl Task {
23
25
Self {
24
26
description,
25
27
quiet : false ,
28
+ quiet_output : false ,
26
29
cmd,
27
30
}
28
31
}
@@ -32,6 +35,12 @@ impl Task {
32
35
self
33
36
}
34
37
38
+ // Do not print stdout/stderr, unless the command fails
39
+ pub ( crate ) fn quiet_output ( mut self ) -> Self {
40
+ self . quiet_output = true ;
41
+ self
42
+ }
43
+
35
44
pub ( crate ) fn args < S : AsRef < OsStr > > ( mut self , args : impl IntoIterator < Item = S > ) -> Self {
36
45
self . cmd . args ( args) ;
37
46
self
@@ -44,9 +53,21 @@ impl Task {
44
53
if !self . quiet {
45
54
println ! ( "{description}" ) ;
46
55
}
56
+ let mut output = None ;
57
+ if self . quiet_output {
58
+ let tmpf = tempfile:: tempfile ( ) ?;
59
+ cmd. stdout ( Stdio :: from ( tmpf. try_clone ( ) ?) ) ;
60
+ cmd. stderr ( Stdio :: from ( tmpf. try_clone ( ) ?) ) ;
61
+ output = Some ( tmpf) ;
62
+ }
47
63
tracing:: debug!( "exec: {cmd:?}" ) ;
48
64
let st = cmd. status ( ) ?;
49
65
if !st. success ( ) {
66
+ if let Some ( mut output) = output {
67
+ output. seek ( std:: io:: SeekFrom :: Start ( 0 ) ) ?;
68
+ let mut stderr = std:: io:: stderr ( ) . lock ( ) ;
69
+ std:: io:: copy ( & mut output, & mut stderr) ?;
70
+ }
50
71
anyhow:: bail!( "Task {description} failed: {st:?}" ) ;
51
72
}
52
73
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments