Skip to content

Commit 6a43333

Browse files
committed
dbus: rauc: update_channels: add a concept of a single primary channel
RAUC native update polling only supports a single update channel, while our native update polling did support multiple (all channels which RAUC would have accepted updates from, based on the enabled signing certificates, were polled for updates and the user was asked if they wanted to install updates from them). Prepare for the change by adding a concept of a single primary update channel. The primary channel is the first enabled one. Based on the channel definition file name. E.g. on production TACs these channel files are available: root@lxatac-00011:~# ls /usr/share/tacd/update_channels/ 01_stable.yaml 05_testing.yaml They are sorted by name when they are read from disk, so if both `stable.cert.pem` and `testing.cert.pem` are found in `/etc/rauc/certificates-enabled/`, then the stable channel will be the primary channel, but bundles from the testing channel may still be installed via the command line interface (e.g. to facilitate a channel switch). Signed-off-by: Leonard Göhrs <[email protected]>
1 parent 46cb875 commit 6a43333

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,8 @@ components:
11321132
type: integer
11331133
enabled:
11341134
type: boolean
1135+
primary:
1136+
type: boolean
11351137
bundle:
11361138
type: object
11371139
properties:

src/dbus/rauc/update_channels.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub struct Channel {
4848
pub url: String,
4949
pub polling_interval: Option<Duration>,
5050
pub enabled: bool,
51+
pub primary: bool,
5152
pub bundle: Option<UpstreamBundle>,
5253
}
5354

@@ -110,6 +111,7 @@ impl Channel {
110111
url: channel_file.url.trim().to_string(),
111112
polling_interval,
112113
enabled: false,
114+
primary: false,
113115
bundle: None,
114116
};
115117

@@ -147,13 +149,21 @@ impl Channels {
147149

148150
let mut channels: Vec<Channel> = Vec::new();
149151

152+
let mut have_primary = false;
153+
150154
for dir_entry in dir_entries {
151-
let channel = Channel::from_file(&dir_entry.path())?;
155+
let mut channel = Channel::from_file(&dir_entry.path())?;
152156

153157
if channels.iter().any(|ch| ch.name == channel.name) {
154158
bail!("Encountered duplicate channel name \"{}\"", channel.name);
155159
}
156160

161+
// There can only be one primary channel.
162+
// If multiple channels are enabled the primary one is the one with
163+
// the highest precedence.
164+
channel.primary = channel.enabled && !have_primary;
165+
have_primary |= channel.primary;
166+
157167
channels.push(channel);
158168
}
159169

0 commit comments

Comments
 (0)