File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,6 +167,20 @@ where
167167fn check_previous_rollback ( ) -> Result < bool > {
168168 log:: debug!( "Checking journalctl for previous rollback attempts..." ) ;
169169
170+ // Use systemd's first-boot detection to skip the rollback check on first boot.
171+ // This is more reliable than journalctl --list-boots, which would also skip
172+ // on systems with non-persistent journald storage.
173+ let first_boot_check = Command :: new ( "systemd-analyze" )
174+ . arg ( "condition" )
175+ . arg ( "ConditionFirstBoot=yes" )
176+ . output ( )
177+ . context ( "Failed to execute 'systemd-analyze condition ConditionFirstBoot=yes'" ) ?;
178+
179+ if first_boot_check. status . success ( ) {
180+ log:: debug!( "First boot detected, skipping rollback check" ) ;
181+ return Ok ( false ) ;
182+ }
183+
170184 let output = Command :: new ( "journalctl" )
171185 . arg ( "-b" )
172186 . arg ( "-1" )
@@ -186,8 +200,7 @@ fn check_previous_rollback() -> Result<bool> {
186200 return Ok ( false ) ;
187201 }
188202
189- let journal_output =
190- String :: from_utf8 ( output. stdout ) . context ( "Failed to parse journalctl output as UTF-8" ) ?;
203+ let journal_output = String :: from_utf8_lossy ( & output. stdout ) ;
191204
192205 if journal_output. trim ( ) . is_empty ( ) {
193206 log:: debug!( "No rollback service logs found in previous boot" ) ;
You can’t perform that action at this time.
0 commit comments