Commit 6e1c089 1 parent 875a04a commit 6e1c089 Copy full SHA for 6e1c089
File tree 4 files changed +24
-12
lines changed
4 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ impl SavedState {
87
87
/// Write-lock guard for statefile, protecting against concurrent state updates.
88
88
#[ derive( Debug ) ]
89
89
pub ( crate ) struct StateLockGuard {
90
- sysroot : openat:: Dir ,
90
+ pub ( crate ) sysroot : openat:: Dir ,
91
91
lockfile : Option < File > ,
92
92
}
93
93
Original file line number Diff line number Diff line change @@ -110,15 +110,14 @@ pub(crate) fn update(name: &str) -> Result<ComponentUpdateResult> {
110
110
let mut pending_container = state. pending . take ( ) . unwrap_or_default ( ) ;
111
111
let interrupted = pending_container. get ( component. name ( ) ) . cloned ( ) ;
112
112
pending_container. insert ( component. name ( ) . into ( ) , update. clone ( ) ) ;
113
- let sysroot = openat:: Dir :: open ( "/" ) ?;
114
- let mut state_guard =
115
- SavedState :: acquire_write_lock ( sysroot) . context ( "Failed to acquire write lock" ) ?;
113
+ let mut state_guard = SavedState :: acquire_write_lock ( openat:: Dir :: open ( "/" ) ?)
114
+ . context ( "Failed to acquire write lock" ) ?;
116
115
state_guard
117
116
. update_state ( & state)
118
117
. context ( "Failed to update state" ) ?;
119
118
120
119
let newinst = component
121
- . run_update ( & inst)
120
+ . run_update ( & state_guard . sysroot , & inst)
122
121
. with_context ( || format ! ( "Failed to update {}" , component. name( ) ) ) ?;
123
122
state. installed . insert ( component. name ( ) . into ( ) , newinst) ;
124
123
pending_container. remove ( component. name ( ) ) ;
Original file line number Diff line number Diff line change @@ -52,7 +52,11 @@ pub(crate) trait Component {
52
52
fn query_update ( & self ) -> Result < Option < ContentMetadata > > ;
53
53
54
54
/// Used on the client to run an update.
55
- fn run_update ( & self , current : & InstalledContent ) -> Result < InstalledContent > ;
55
+ fn run_update (
56
+ & self ,
57
+ sysroot : & openat:: Dir ,
58
+ current : & InstalledContent ,
59
+ ) -> Result < InstalledContent > ;
56
60
57
61
/// Used on the client to validate an installed version.
58
62
fn validate ( & self , current : & InstalledContent ) -> Result < ValidationResult > ;
@@ -67,12 +71,16 @@ pub(crate) fn new_from_name(name: &str) -> Result<Box<dyn Component>> {
67
71
Ok ( r)
68
72
}
69
73
74
+ /// Returns the path to the payload directory for an available update for
75
+ /// a component.
76
+ pub ( crate ) fn component_updatedirname ( component : & dyn Component ) -> PathBuf {
77
+ Path :: new ( BOOTUPD_UPDATES_DIR ) . join ( component. name ( ) )
78
+ }
79
+
70
80
/// Returns the path to the payload directory for an available update for
71
81
/// a component.
72
82
pub ( crate ) fn component_updatedir ( sysroot : & str , component : & dyn Component ) -> PathBuf {
73
- Path :: new ( sysroot)
74
- . join ( BOOTUPD_UPDATES_DIR )
75
- . join ( component. name ( ) )
83
+ Path :: new ( sysroot) . join ( component_updatedirname ( component) )
76
84
}
77
85
78
86
/// Returns the name of the JSON file containing a component's available update metadata installed
Original file line number Diff line number Diff line change @@ -128,14 +128,19 @@ impl Component for EFI {
128
128
} )
129
129
}
130
130
131
- fn run_update ( & self , current : & InstalledContent ) -> Result < InstalledContent > {
131
+ fn run_update (
132
+ & self ,
133
+ sysroot : & openat:: Dir ,
134
+ current : & InstalledContent ,
135
+ ) -> Result < InstalledContent > {
132
136
let currentf = current
133
137
. filetree
134
138
. as_ref ( )
135
139
. ok_or_else ( || anyhow:: anyhow!( "No filetree for installed EFI found!" ) ) ?;
136
140
let updatemeta = self . query_update ( ) ?. expect ( "update available" ) ;
137
- let updated =
138
- openat:: Dir :: open ( & component_updatedir ( "/" , self ) ) . context ( "opening update dir" ) ?;
141
+ let updated = sysroot
142
+ . sub_dir ( & component_updatedirname ( self ) )
143
+ . context ( "opening update dir" ) ?;
139
144
let updatef = filetree:: FileTree :: new_from_dir ( & updated) . context ( "reading update dir" ) ?;
140
145
let diff = currentf. diff ( & updatef) ?;
141
146
let destdir = openat:: Dir :: open ( & Path :: new ( "/" ) . join ( MOUNT_PATH ) . join ( "EFI" ) )
You can’t perform that action at this time.
0 commit comments