@@ -73,10 +73,12 @@ func (up SystemUpdater) Update() (*[]CommandOutput, error) {
7373 var finalOutput = []CommandOutput {}
7474 var cmd * exec.Cmd
7575 binaryPath := up .BinaryPath
76+
7677 cli := []string {binaryPath , "upgrade" , "--quiet" }
7778 up .Config .Logger .Debug ("Executing update" , slog .Any ("cli" , cli ))
7879 cmd = exec .Command (cli [0 ], cli [1 :]... )
7980 out , err := session .RunLog (up .Config .Logger , slog .LevelDebug , cmd )
81+
8082 tmpout := CommandOutput {}.New (out , err )
8183 tmpout .Failure = err != nil
8284 tmpout .Context = "System Update"
@@ -121,55 +123,44 @@ func (up SystemUpdater) Check() (bool, error) {
121123 return updateNecessary , nil
122124}
123125
124- func BootcCompatible (binaryPath string ) ( bool , error ) {
126+ func BootcCompatible (binaryPath string ) bool {
125127 cmd := exec .Command (binaryPath , "status" , "--format=json" )
126128 out , err := cmd .CombinedOutput ()
127129 if err != nil {
128- return false , nil
130+ return false
129131 }
130132 var status bootcStatus
131133 err = json .Unmarshal (out , & status )
132134 if err != nil {
133- return false , nil
135+ return false
134136 }
135- return ! (status .Status .Booted .Incompatible || status .Status .Staged .Incompatible ), nil
137+ return ! (status .Status .Booted .Incompatible || status .Status .Staged .Incompatible )
136138}
137139
138140func InitializeSystemDriver (initConfiguration UpdaterInitConfiguration ) (SystemUpdateDriver , DriverConfiguration , bool , error ) {
139- var enableUpd bool = true
140141
141142 rpmOstreeUpdater , err := rpmostree.RpmOstreeUpdater {}.New (initConfiguration )
142- if err != nil {
143- enableUpd = false
144- }
145143
146144 systemUpdater , err := SystemUpdater {}.New (initConfiguration )
147- if err != nil {
148- enableUpd = false
149- }
150145
151- isBootc , err := BootcCompatible (systemUpdater .BinaryPath )
152- if err != nil {
153- isBootc = false
154- }
146+ isBootc := BootcCompatible (systemUpdater .BinaryPath )
155147
156148 if ! isBootc {
157149 slog .Debug ("Using rpm-ostree fallback as system driver" )
158150 }
159151
160152 // 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
163156
164- var finalConfig DriverConfiguration
157+ // var finalConfig DriverConfiguration
165158 var mainSystemDriver SystemUpdateDriver
166159 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
172162 }
163+ mainSystemDriver = rpmOstreeUpdater
164+ return mainSystemDriver , rpmOstreeUpdater .Config , isBootc , err
173165
174- return mainSystemDriver , finalConfig , isBootc , err
175166}
0 commit comments