Print some more helpful messages on apt failure

This commit is contained in:
Anders Ingemann 2013-12-29 23:02:36 +01:00
parent 7afd04f1c9
commit 9a525628a2
2 changed files with 25 additions and 9 deletions

View file

@ -68,6 +68,8 @@ class AptUpgrade(Task):
predecessors = [AptUpdate, DisableDaemonAutostart]
def run(self, info):
from subprocess import CalledProcessError
try:
log_check_call(['/usr/sbin/chroot', info.root,
'/usr/bin/apt-get', 'install',
'--fix-broken',
@ -77,6 +79,14 @@ class AptUpgrade(Task):
'/usr/bin/apt-get', 'upgrade',
'--no-install-recommends',
'--assume-yes'])
except CalledProcessError as e:
if e.returncode == 100:
import logging
msg = ('apt exited with status code 100. '
'This can sometimes occur when package retrieval times out or a package extraction failed. '
'apt might succeed if you try bootstrapping again.')
logging.getLogger(__name__).warn(msg)
raise e
class PurgeUnusedPackages(Task):

View file

@ -44,6 +44,12 @@ class InstallRemotePackages(Task):
'this may be because\nthe image volume is '
'running out of disk space ({free}MB left)').format(free=free_mb)
logging.getLogger(__name__).warn(msg)
else:
if e.returncode == 100:
msg = ('apt exited with status code 100. '
'This can sometimes occur when package retrieval times out or a package extraction failed. '
'apt might succeed if you try bootstrapping again.')
logging.getLogger(__name__).warn(msg)
raise e