Skip to content

Commit 4a2384c

Browse files
committed
rauc: expose the current primary slot via the broker framework
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
1 parent 909ac07 commit 4a2384c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/dbus/rauc.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub struct Rauc {
9898
pub operation: Arc<Topic<String>>,
9999
pub progress: Arc<Topic<Progress>>,
100100
pub slot_status: Arc<Topic<Arc<SlotStatus>>>,
101+
pub primary: Arc<Topic<String>>,
101102
pub last_error: Arc<Topic<String>>,
102103
pub install: Arc<Topic<String>>,
103104
pub channels: Arc<Topic<Vec<Channel>>>,
@@ -265,6 +266,7 @@ impl Rauc {
265266
operation: bb.topic_ro("/v1/tac/update/operation", None),
266267
progress: bb.topic_ro("/v1/tac/update/progress", None),
267268
slot_status: bb.topic_ro("/v1/tac/update/slots", None),
269+
primary: bb.topic_ro("/v1/tac/update/primary", None),
268270
last_error: bb.topic_ro("/v1/tac/update/last_error", None),
269271
install: bb.topic_wo("/v1/tac/update/install", Some("".to_string())),
270272
channels: bb.topic_ro("/v1/tac/update/channels", None),
@@ -300,6 +302,7 @@ impl Rauc {
300302
let conn_task = conn.clone();
301303
let operation = inst.operation.clone();
302304
let slot_status = inst.slot_status.clone();
305+
let primary = inst.primary.clone();
303306
let channels = inst.channels.clone();
304307
let should_reboot = inst.should_reboot.clone();
305308

@@ -313,6 +316,15 @@ impl Rauc {
313316
}
314317

315318
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+
316328
// Referesh the slot status whenever the current operation changes
317329
// This is mostly relevant for "installing" -> "idle" transitions
318330
// but it can't hurt to do it on any transition.

0 commit comments

Comments
 (0)