@@ -54,13 +54,14 @@ func (s *Service) ListUpgradablePackages(ctx context.Context, matcher func(updat
5454 }
5555 defer s .lock .Unlock ()
5656
57+ // Attempt to fix dpkg database in case an upgrade was interrupted in the middle.
5758 if err := runDpkgConfigureCommand (ctx ); err != nil {
58- return nil , fmt . Errorf ("error running dpkg configure command: %w " , err )
59+ slog . Warn ("error running dpkg configure command, skipped" , "error " , err )
5960 }
6061
6162 err := runUpdateCommand (ctx )
6263 if err != nil {
63- return nil , fmt . Errorf ( "error running apt-get update command: %w" , err )
64+ return nil , err
6465 }
6566
6667 pkgs , err := listUpgradablePackages (ctx , matcher )
@@ -170,9 +171,9 @@ func runDpkgConfigureCommand(ctx context.Context) error {
170171 if err != nil {
171172 return err
172173 }
173- err = dpkgCmd .RunWithinContext (ctx )
174+ out , err : = dpkgCmd .RunAndCaptureCombinedOutput (ctx )
174175 if err != nil {
175- return fmt .Errorf ("error running dpkg configure command: %w" , err )
176+ return fmt .Errorf ("error running dpkg configure command: %w: %s " , err , out )
176177 }
177178 return nil
178179}
@@ -182,9 +183,9 @@ func runUpdateCommand(ctx context.Context) error {
182183 if err != nil {
183184 return err
184185 }
185- err = updateCmd .RunWithinContext (ctx )
186+ out , err : = updateCmd .RunAndCaptureCombinedOutput (ctx )
186187 if err != nil {
187- return err
188+ return fmt . Errorf ( "error running apt-get update command: %w: %s" , err , out )
188189 }
189190 return nil
190191}
0 commit comments