@@ -73,10 +73,12 @@ func (up SystemUpdater) Update() (*[]CommandOutput, error) {
73
73
var finalOutput = []CommandOutput {}
74
74
var cmd * exec.Cmd
75
75
binaryPath := up .BinaryPath
76
+
76
77
cli := []string {binaryPath , "upgrade" , "--quiet" }
77
78
up .Config .Logger .Debug ("Executing update" , slog .Any ("cli" , cli ))
78
79
cmd = exec .Command (cli [0 ], cli [1 :]... )
79
80
out , err := session .RunLog (up .Config .Logger , slog .LevelDebug , cmd )
81
+
80
82
tmpout := CommandOutput {}.New (out , err )
81
83
tmpout .Failure = err != nil
82
84
tmpout .Context = "System Update"
@@ -121,55 +123,44 @@ func (up SystemUpdater) Check() (bool, error) {
121
123
return updateNecessary , nil
122
124
}
123
125
124
- func BootcCompatible (binaryPath string ) ( bool , error ) {
126
+ func BootcCompatible (binaryPath string ) bool {
125
127
cmd := exec .Command (binaryPath , "status" , "--format=json" )
126
128
out , err := cmd .CombinedOutput ()
127
129
if err != nil {
128
- return false , nil
130
+ return false
129
131
}
130
132
var status bootcStatus
131
133
err = json .Unmarshal (out , & status )
132
134
if err != nil {
133
- return false , nil
135
+ return false
134
136
}
135
- return ! (status .Status .Booted .Incompatible || status .Status .Staged .Incompatible ), nil
137
+ return ! (status .Status .Booted .Incompatible || status .Status .Staged .Incompatible )
136
138
}
137
139
138
140
func InitializeSystemDriver (initConfiguration UpdaterInitConfiguration ) (SystemUpdateDriver , DriverConfiguration , bool , error ) {
139
- var enableUpd bool = true
140
141
141
142
rpmOstreeUpdater , err := rpmostree.RpmOstreeUpdater {}.New (initConfiguration )
142
- if err != nil {
143
- enableUpd = false
144
- }
145
143
146
144
systemUpdater , err := SystemUpdater {}.New (initConfiguration )
147
- if err != nil {
148
- enableUpd = false
149
- }
150
145
151
- isBootc , err := BootcCompatible (systemUpdater .BinaryPath )
152
- if err != nil {
153
- isBootc = false
154
- }
146
+ isBootc := BootcCompatible (systemUpdater .BinaryPath )
155
147
156
148
if ! isBootc {
157
149
slog .Debug ("Using rpm-ostree fallback as system driver" )
158
150
}
159
151
160
152
// The system driver to be applied needs to have the correct "enabled" value since it will NOT update from here onwards.
161
- systemUpdater .Config .Enabled = systemUpdater .Config .Enabled && isBootc && enableUpd
162
- rpmOstreeUpdater .Config .Enabled = rpmOstreeUpdater .Config .Enabled && ! isBootc && enableUpd
153
+ systemUpdater .Config .Enabled = systemUpdater .Config .Enabled && isBootc
154
+
155
+ rpmOstreeUpdater .Config .Enabled = rpmOstreeUpdater .Config .Enabled && ! isBootc
163
156
164
- var finalConfig DriverConfiguration
157
+ // var finalConfig DriverConfiguration
165
158
var mainSystemDriver SystemUpdateDriver
166
159
if isBootc {
167
- mainSystemDriver = & systemUpdater
168
- finalConfig = systemUpdater .Config
169
- } else {
170
- mainSystemDriver = & rpmOstreeUpdater
171
- finalConfig = systemUpdater .Config
160
+ mainSystemDriver = systemUpdater
161
+ return mainSystemDriver , systemUpdater .Config , isBootc , err
172
162
}
163
+ mainSystemDriver = rpmOstreeUpdater
164
+ return mainSystemDriver , rpmOstreeUpdater .Config , isBootc , err
173
165
174
- return mainSystemDriver , finalConfig , isBootc , err
175
166
}
0 commit comments