@@ -98,6 +98,7 @@ pub struct Rauc {
98
98
pub operation : Arc < Topic < String > > ,
99
99
pub progress : Arc < Topic < Progress > > ,
100
100
pub slot_status : Arc < Topic < Arc < SlotStatus > > > ,
101
+ pub primary : Arc < Topic < String > > ,
101
102
pub last_error : Arc < Topic < String > > ,
102
103
pub install : Arc < Topic < String > > ,
103
104
pub channels : Arc < Topic < Vec < Channel > > > ,
@@ -265,6 +266,7 @@ impl Rauc {
265
266
operation : bb. topic_ro ( "/v1/tac/update/operation" , None ) ,
266
267
progress : bb. topic_ro ( "/v1/tac/update/progress" , None ) ,
267
268
slot_status : bb. topic_ro ( "/v1/tac/update/slots" , None ) ,
269
+ primary : bb. topic_ro ( "/v1/tac/update/primary" , None ) ,
268
270
last_error : bb. topic_ro ( "/v1/tac/update/last_error" , None ) ,
269
271
install : bb. topic_wo ( "/v1/tac/update/install" , Some ( "" . to_string ( ) ) ) ,
270
272
channels : bb. topic_ro ( "/v1/tac/update/channels" , None ) ,
@@ -300,6 +302,7 @@ impl Rauc {
300
302
let conn_task = conn. clone ( ) ;
301
303
let operation = inst. operation . clone ( ) ;
302
304
let slot_status = inst. slot_status . clone ( ) ;
305
+ let primary = inst. primary . clone ( ) ;
303
306
let channels = inst. channels . clone ( ) ;
304
307
let should_reboot = inst. should_reboot . clone ( ) ;
305
308
@@ -313,6 +316,15 @@ impl Rauc {
313
316
}
314
317
315
318
loop {
319
+ // Update which slot is considered the primary whenever the current
320
+ // operation changes.
321
+ // (The one that should be booted next _if it is bootable_)
322
+ let new_primary = proxy. get_primary ( ) . await . ok ( ) . map ( |p| p. replace ( '.' , "_" ) ) ;
323
+
324
+ if let Some ( p) = new_primary {
325
+ primary. set_if_changed ( p) ;
326
+ }
327
+
316
328
// Referesh the slot status whenever the current operation changes
317
329
// This is mostly relevant for "installing" -> "idle" transitions
318
330
// but it can't hurt to do it on any transition.
0 commit comments