@@ -346,6 +346,22 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro
346346 cmd .Env = env
347347 output , err := cmd .CombinedOutput ()
348348 if err != nil {
349+ // This is a bit of a hack, but if we get an error that says we need to run dpkg configure, we run it.
350+ // The typical cause is that we install a package that kills nodeup,
351+ // also killing apt-get, and then apt-get is in a bad state.
352+ // Typical error looks like this:
353+ // exit status 100: E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
354+ if strings .Contains (string (output ), "dpkg --configure -a" ) {
355+ klog .Warningf ("found error requiring dpkg repair: %q" , string (output ))
356+ args := []string {"dpkg" , "--configure" , "-a" }
357+ klog .Infof ("running command %s" , args )
358+ cmd := exec .Command (args [0 ], args [1 :]... )
359+ dpkgOutput , err := cmd .CombinedOutput ()
360+ if err != nil {
361+ return fmt .Errorf ("error running `dpkg --configure -a`: %v: %s" , err , string (dpkgOutput ))
362+ }
363+ // Note that we still return an error, because our package installation failed; we will retry.
364+ }
349365 return fmt .Errorf ("error installing package %q: %v: %s" , e .Name , err , string (output ))
350366 }
351367 } else {
0 commit comments