Skip to content

Commit c34c4e4

Browse files
committed
dbus: rauc: allow configuring the *_criteria in channel files
1 parent 9ab5afc commit c34c4e4

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

openapi.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,12 @@ components:
11661166
type: boolean
11671167
force_auto_install:
11681168
type: boolean
1169+
candidate_criteria:
1170+
type: string
1171+
install_criteria:
1172+
type: string
1173+
reboot_criteria:
1174+
type: string
11691175

11701176
ServiceStatus:
11711177
type: object

src/dbus/rauc/system_conf.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,25 @@ fn poll_section(
4545
writeln!(&mut section, "interval-sec={}", interval.as_secs())?;
4646
}
4747

48-
writeln!(&mut section, "candidate-criteria=different-version")?;
48+
let candidate_criteria = primary_channel
49+
.candidate_criteria
50+
.as_deref()
51+
.unwrap_or("different-version");
52+
53+
writeln!(&mut section, "candidate-criteria={candidate_criteria}")?;
4954

5055
if auto_install {
51-
writeln!(&mut section, "install-criteria=different-version")?;
52-
writeln!(
53-
&mut section,
54-
"reboot-criteria=updated-slots;updated-artifacts"
55-
)?;
56+
let install_criteria = primary_channel
57+
.install_criteria
58+
.as_deref()
59+
.unwrap_or("different-version");
60+
let reboot_criteria = primary_channel
61+
.reboot_criteria
62+
.as_deref()
63+
.unwrap_or("updated-slots;updated-artifacts");
64+
65+
writeln!(&mut section, "install-criteria={install_criteria}")?;
66+
writeln!(&mut section, "reboot-criteria={reboot_criteria}")?;
5667
writeln!(&mut section, "reboot-cmd=systemctl reboot")?;
5768
}
5869

src/dbus/rauc/update_channels.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ pub struct Channel {
5656
pub bundle: Option<UpstreamBundle>,
5757
pub force_polling: Option<bool>,
5858
pub force_auto_install: Option<bool>,
59+
pub candidate_criteria: Option<String>,
60+
pub install_criteria: Option<String>,
61+
pub reboot_criteria: Option<String>,
5962
}
6063

6164
#[derive(Serialize, Deserialize, Clone, PartialEq)]
@@ -70,6 +73,9 @@ pub struct ChannelFile {
7073
pub polling_interval: Option<String>,
7174
pub force_polling: Option<bool>,
7275
pub force_auto_install: Option<bool>,
76+
pub candidate_criteria: Option<String>,
77+
pub install_criteria: Option<String>,
78+
pub reboot_criteria: Option<String>,
7379
}
7480

7581
#[cfg(not(feature = "demo_mode"))]
@@ -151,6 +157,9 @@ impl Channel {
151157
bundle: None,
152158
force_polling: channel_file.force_polling,
153159
force_auto_install: channel_file.force_auto_install,
160+
candidate_criteria: channel_file.candidate_criteria,
161+
install_criteria: channel_file.install_criteria,
162+
reboot_criteria: channel_file.reboot_criteria,
154163
};
155164

156165
ch.update_enabled();

0 commit comments

Comments
 (0)