Merge lp:~mvo/ubuntu-release-upgrader/lp1052605 into lp:ubuntu-release-upgrader

Proposed by Michael Vogt
Status: Merged
Approved by: Michael Terry
Approved revision: no longer in the source branch.
Merged at revision: 2566
Proposed branch: lp:~mvo/ubuntu-release-upgrader/lp1052605
Merge into: lp:ubuntu-release-upgrader
Diff against target: 75 lines (+34/-11)
1 file modified
DistUpgrade/DistUpgradeController.py (+34/-11)
To merge this branch: bzr merge lp:~mvo/ubuntu-release-upgrader/lp1052605
Reviewer Review Type Date Requested Status
Michael Terry Approve
Review via email: mp+125693@code.launchpad.net

Description of the change

This branches fixes bug #1052605 by
a) spinning on the dpkg lock for a short while
b) reverting cleanly if the cache open fails after a sources.list update
   but before anything got installed

To post a comment you must log in.
2554. By Colin Watson

DistUpgrade/DistUpgradeController.py: Guard against UnboundLocalError in
doDistUpgradeFetching.

2555. By Brian Murray

ensure that apt-clone system state is included in bug reports filed by
apport

2556. By Brian Murray

DistUpgrade/DistUpgradeController.py: properly handle source entries with
unicode comments in them (LP: #1039484)

2557. By Brian Murray

releasing version 1:0.181

2558. By Brian Murray

Do not try to add apt-clone system state if it does not exist

2559. By Colin Watson

fix version number

2560. By Brian Murray

releasing version 1:0.182

2561. By Brian Murray

debian/ubuntu-release-upgrader-core.preinst: modify
/etc/dist-upgrader/release-upgrades to use Prompt instead of prompt
thereby avoiding a conffile prompt (LP: #1045579)

2562. By Brian Murray

releasing version 1:0.183

2563. By Colin Watson

Decode the output of apt_pkg.size_to_str() if necessary when
substituting it into Unicode strings (LP: #1031882).

2564. By Colin Watson

Ship /usr/share/keyrings/ubuntu-archive-keyring.gpg as
utils/apt/trusted.gpg (although that's only for tests anyway), rather
than whatever happens to be in /etc/apt/trusted.gpg on the system used
to build the source package.

2565. By Colin Watson

releasing version 1:0.184

Revision history for this message
Michael Terry (mterry) wrote :

Looks good to me

review: Approve
2566. By Michael Vogt

* lp:~mvo/ubuntu-release-upgrader/lp1052605 into lp:ubuntu-release-upgrader:
   - spinning on the dpkg lock for a short while before giving up
   - reverting cleanly if the cache open fails after a sources.list update
     but before anything got installed
   (LP: #1052605)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DistUpgrade/DistUpgradeController.py'
2--- DistUpgrade/DistUpgradeController.py 2012-07-03 16:49:34 +0000
3+++ DistUpgrade/DistUpgradeController.py 2012-09-21 12:38:36 +0000
4@@ -191,13 +191,42 @@
5 # apt cron job
6 self._aptCronJobPerms = 0o755
7
8- def openCache(self, lock=True):
9+ def openCache(self, lock=True, restore_sources_list_on_fail=False):
10 logging.debug("openCache()")
11 if self.cache is None:
12 self.quirks.run("PreCacheOpen")
13 else:
14 self.cache.release_lock()
15 self.cache.unlock_lists_dir()
16+ # this loop will try getting the lock a couple of times
17+ MAX_LOCK_RETRIES = 20
18+ lock_retry = 0
19+ while True:
20+ try:
21+ # exit here once the cache is ready
22+ return self._openCache(lock)
23+ except CacheExceptionLockingFailed as e:
24+ # wait a bit
25+ lock_retry += 1
26+ self._view.processEvents()
27+ time.sleep(0.1)
28+ logging.debug(
29+ "failed to lock the cache, retrying (%i)" % lock_retry)
30+ # and give up after some time
31+ if lock_retry > MAX_LOCK_RETRIES:
32+ logging.error("Cache can not be locked (%s)" % e)
33+ self._view.error(_("Unable to get exclusive lock"),
34+ _("This usually means that another "
35+ "package management application "
36+ "(like apt-get or aptitude) "
37+ "already running. Please close that "
38+ "application first."));
39+ if restore_sources_list_on_fail:
40+ self.abort()
41+ else:
42+ sys.exit(1)
43+
44+ def _openCache(self, lock):
45 try:
46 self.cache = MyCache(self.config,
47 self._view,
48@@ -218,15 +247,6 @@
49 self._view,
50 self.quirks,
51 self._view.getOpCacheProgress())
52- except CacheExceptionLockingFailed as e:
53- logging.error("Cache can not be locked (%s)" % e)
54- self._view.error(_("Unable to get exclusive lock"),
55- _("This usually means that another "
56- "package management application "
57- "(like apt-get or aptitude) "
58- "already running. Please close that "
59- "application first."));
60- sys.exit(1)
61 self.cache.partialUpgrade = self._partialUpgrade
62 logging.debug("/openCache(), new cache size %i" % len(self.cache))
63
64@@ -1651,7 +1671,10 @@
65
66 # then open the cache (again)
67 self._view.updateStatus(_("Checking package manager"))
68- self.openCache()
69+ # if something fails here (e.g. locking the cache) we need to
70+ # restore the system state (LP: #1052605)
71+ self.openCache(restore_sources_list_on_fail=True)
72+
73 # re-check server mode because we got new packages (it may happen
74 # that the system had no sources.list entries and therefore no
75 # desktop file information)

Subscribers

People subscribed via source and target branches