From 0f654e366f82fc4d8ddcc96d8f5bc57720310c7f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 31 Jan 2006 09:26:36 +0000 Subject: * fix a bogus cache.commit() --- DistUpgrade/DistUpgradeControler.py | 1 - 1 file changed, 1 deletion(-) (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 6ab77103..ca43e80c 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -266,7 +266,6 @@ class DistUpgradeControler(object): "Please see the below message for more " "information. "), "%s" % e) - self.cache.commit(fprogress,iprogress) def abort(self): """ abort the upgrade, cleanup (as much as possible) """ -- cgit v1.2.3 From 442066f04db10be923c15455d16155358a6d5321 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Feb 2006 12:56:26 +0000 Subject: * started to implement a more flexible config file approach --- DistUpgrade/DistUpgrade.cfg | 4 ++++ DistUpgrade/DistUpgradeControler.py | 14 +++++++------- DistUpgrade/DistUpgradeViewNonInteractive.py | 3 +++ 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 DistUpgrade/DistUpgrade.cfg (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg new file mode 100644 index 00000000..979d7c0c --- /dev/null +++ b/DistUpgrade/DistUpgrade.cfg @@ -0,0 +1,4 @@ +[Distro] +From=breezy +To=Dapper +ValidOrigin=Ubuntu diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index ca43e80c..1ba0f7e0 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -28,8 +28,8 @@ import subprocess import logging import re import statvfs +import ConfigParser -from UpdateManager.Common.SimpleGladeApp import SimpleGladeApp from SoftwareProperties.aptsources import SourcesList, SourceEntry from gettext import gettext as _ from DistUpgradeCache import MyCache @@ -42,13 +42,13 @@ class DistUpgradeControler(object): self._view.updateStatus(_("Reading cache")) self.cache = None + self.config = ConfigParser.ConfigParser() + self.config.read(['DistUpgrade.cfg']) + # some constants here - #self.fromDist = "hoary" - #self.toDist = "breezy" - self.fromDist = "breezy" - self.toDist = "dapper" - - self.origin = "Ubuntu" + self.fromDist = self.config.get("Distro","From") + self.toDist = self.config.get("Distro","To") + self.origin = self.config.get("Distro","ValidOrigin") # forced obsoletes self.forced_obsoletes = [] diff --git a/DistUpgrade/DistUpgradeViewNonInteractive.py b/DistUpgrade/DistUpgradeViewNonInteractive.py index f77d3d43..e8236565 100644 --- a/DistUpgrade/DistUpgradeViewNonInteractive.py +++ b/DistUpgrade/DistUpgradeViewNonInteractive.py @@ -19,6 +19,9 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +import apt +import logging + class NonInteractiveDistUpgradeView(object): " non-interactive version of the upgrade view " def __init__(self): -- cgit v1.2.3 From 0f3e83010710cf3493c0c9f2bab16e5f028c114c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Feb 2006 15:50:23 +0000 Subject: * make the Config-File more usable --- DistUpgrade/DistUpgrade.cfg | 28 ++++++++++++++++++++++++- DistUpgrade/DistUpgradeCache.py | 18 ++++++++-------- DistUpgrade/DistUpgradeConfigParser.py | 20 ++++++++++++++++++ DistUpgrade/DistUpgradeControler.py | 38 ++++++++++++++++------------------ SoftwareProperties/aptsources.py | 2 ++ 5 files changed, 76 insertions(+), 30 deletions(-) create mode 100644 DistUpgrade/DistUpgradeConfigParser.py (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index 979d7c0c..b9cb2cc3 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -1,4 +1,30 @@ +# Distro contains global information about the upgrade [Distro] +# the meta-pkgs we support +MetaPkgs=ubuntu-desktop, kubuntu-desktop, edubuntu-desktop, xubuntu-desktop +BaseMetaPkgs=ubuntu-base +ForcedPurges=xorg-common + +# information about the individual meta-pkgs +[ubuntu-desktop] +KeyDependencies=gdm, gnome-panel, ubuntu-artwork +ForcedObsoletes=xscreensaver + +[kubuntu-desktop] +KeyDependencies=kdm, kicker, kubuntu-artwork-usplash + +[edubuntu-desktop] +KeyDependencies=edubuntu-artwork, tuxpaint + +[xubuntu-desktop] +KeyDependencies=xubuntu-artwork-usplash, xubuntu-default-settings, xfce4 + + +[Files] +BackupExt=distUpgrade + +[Sources] From=breezy -To=Dapper +To=dapper ValidOrigin=Ubuntu +ValidMirrors = http://archive.ubuntu.com/ubuntu, http://security.ubuntu.com/ubuntu, http://archive.distrosprint/ubuntu/ \ No newline at end of file diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py index c7cb89f3..45d892c7 100644 --- a/DistUpgrade/DistUpgradeCache.py +++ b/DistUpgrade/DistUpgradeCache.py @@ -5,6 +5,7 @@ import os import re import logging from gettext import gettext as _ +from DistUpgradeConfigParser import DistUpgradeConfigParser class MyCache(apt.Cache): # init @@ -12,6 +13,9 @@ class MyCache(apt.Cache): apt.Cache.__init__(self, progress) self.to_install = [] self.to_remove = [] + + self.config = DistUpgradeConfigParser() + # turn on debuging apt_pkg.Config.Set("Debug::pkgProblemResolver","true") fd = os.open(os.path.expanduser("~/dist-upgrade-apt.log"), os.O_RDWR|os.O_CREAT|os.O_TRUNC) @@ -161,14 +165,12 @@ class MyCache(apt.Cache): return metapkg_found # now check for ubuntu-desktop, kubuntu-desktop, edubuntu-desktop - metapkgs = {"ubuntu-desktop": ["gdm","gnome-panel", "ubuntu-artwork"], - "kubuntu-desktop": ["kdm", "kicker", - "kubuntu-artwork-usplash"], - "edubuntu-desktop": ["edubuntu-artwork", "tuxpaint"] - } + metapkgs = self.config.getlist("Distro","MetaPkgs") # we never go without ubuntu-base - self["ubuntu-base"].markInstall() + for pkg in self.config.getlist("Distro","BaseMetaPkgs"): + self[pkg].markInstall() + # every meta-pkg that is installed currently, will be marked # install (that result in a upgrade and removes a markDelete) for key in metapkgs: @@ -182,7 +184,7 @@ class MyCache(apt.Cache): logging.debug("no {ubuntu,edubuntu,kubuntu}-desktop pkg installed") for key in metapkgs: deps_found = True - for pkg in metapkgs[key]: + for pkg in self.config.getlist(key,"KeyDependencies"): deps_found &= self.has_key(pkg) and self[pkg].isInstalled if deps_found: logging.debug("guessing '%s' as missing meta-pkg" % key) @@ -208,8 +210,6 @@ class MyCache(apt.Cache): "above first using synaptic or " "apt-get before proceeding.")) return False - - # FIXME: check for ubuntu-desktop, kubuntu-dekstop, edubuntu-desktop return True def _inRemovalBlacklist(self, pkgname): diff --git a/DistUpgrade/DistUpgradeConfigParser.py b/DistUpgrade/DistUpgradeConfigParser.py new file mode 100644 index 00000000..449e67b2 --- /dev/null +++ b/DistUpgrade/DistUpgradeConfigParser.py @@ -0,0 +1,20 @@ +from ConfigParser import ConfigParser, NoOptionError + + +class DistUpgradeConfigParser(ConfigParser): + def __init__(self): + ConfigParser.__init__(self) + self.read(['DistUpgrade.cfg']) + def getlist(self, section, option): + try: + tmp = self.get(section, option) + except NoOptionError: + return [] + items = [x.strip() for x in tmp.split(",")] + return items + + +if __name__ == "__main__": + c = DistUpgradeConfigParser() + print c.getlist("Distro","MetaPkgs") + print c.getlist("Distro","ForcedPurges") diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 1ba0f7e0..fd9a0cbe 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -28,7 +28,7 @@ import subprocess import logging import re import statvfs -import ConfigParser +from DistUpgradeConfigParser import DistUpgradeConfigParser from SoftwareProperties.aptsources import SourcesList, SourceEntry from gettext import gettext as _ @@ -42,21 +42,16 @@ class DistUpgradeControler(object): self._view.updateStatus(_("Reading cache")) self.cache = None - self.config = ConfigParser.ConfigParser() - self.config.read(['DistUpgrade.cfg']) - + self.config = DistUpgradeConfigParser() + self.sources_backup_ext = "."+self.config.get("Files","BackupExt") + # some constants here - self.fromDist = self.config.get("Distro","From") - self.toDist = self.config.get("Distro","To") - self.origin = self.config.get("Distro","ValidOrigin") + self.fromDist = self.config.get("Sources","From") + self.toDist = self.config.get("Sources","To") + self.origin = self.config.get("Sources","ValidOrigin") # forced obsoletes - self.forced_obsoletes = [] - for line in open("forced_obsoletes.txt").readlines(): - line = line.strip() - if not line == "" or line.startswith("#"): - self.forced_obsoletes.append(line) - logging.debug("forced obsoletes '%s'" % line) + self.forced_obsoletes = self.config.getlist("Distro","ForcedObsoletes") def openCache(self): @@ -81,15 +76,16 @@ class DistUpgradeControler(object): ] # list of valid mirrors that we can add - valid_mirrors = ["http://archive.ubuntu.com/ubuntu", - "http://security.ubuntu.com/ubuntu"] + valid_mirrors = self.config.getlist("Sources","ValidMirrors") # look over the stuff we have foundToDist = False for entry in self.sources: # check if it's a mirror (or offical site) + validMirror = False for mirror in valid_mirrors: if self.sources.is_mirror(mirror,entry.uri): + validMirror = True if entry.dist in toDists: # so the self.sources.list is already set to the new # distro @@ -103,10 +99,9 @@ class DistUpgradeControler(object): entry.disabled = True # it can only be one valid mirror, so we can break here break - else: - # disable non-official entries that point to dist - if entry.dist == self.fromDist: - entry.disabled = True + # disable anything that is not from a official mirror + if not validMirror: + entry.disabled = True if not foundToDist: # FIXME: offer to write a new self.sources.list entry @@ -116,7 +111,6 @@ class DistUpgradeControler(object): "the upgrade was found.\n")) # write (well, backup first ;) ! - self.sources_backup_ext = ".distUpgrade" self.sources.backup(self.sources_backup_ext) self.sources.save() @@ -279,9 +273,13 @@ class DistUpgradeControler(object): self._view.updateStatus(_("Checking package manager")) self._view.setStep(1) self.openCache() + if not self.cache.sanityCheck(self._view): abort(1) + # run a "apt-get update" now + self.doUpdate() + # do pre-upgrade stuff (calc list of obsolete pkgs etc) self.doPreUpdate() diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py index 3e8d522e..c0d2c2ba 100644 --- a/SoftwareProperties/aptsources.py +++ b/SoftwareProperties/aptsources.py @@ -517,3 +517,5 @@ if __name__ == "__main__": "http://de.archive.ubuntu.com/ubuntu/") print "is_mirror(): %s" % mirror + print sources.is_mirror("http://archive.ubuntu.com/ubuntu", + "http://de.archive.ubuntu.com/ubuntu/") -- cgit v1.2.3 From 00ef7226be8cea7332bb6ef43bcc11d48412ce78 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Feb 2006 16:08:13 +0000 Subject: * fix small problems in the per-meta-pkg obsoletes support --- DistUpgrade/DistUpgradeControler.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index fd9a0cbe..4211c93b 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -233,6 +233,11 @@ class DistUpgradeControler(object): now_foreign = self.cache._getForeignPkgs(self.origin, self.fromDist, self.toDist) logging.debug("Obsolete: %s" % " ".join(now_obsolete)) logging.debug("Foreign: %s" % " ".join(now_foreign)) + + # now get the meta-pkg specific obsoletes + for pkg in self.config.getlist("Distro","MetaPkgs"): + if self.cache.has_key(pkg) and self.cache[pkg].isInstalled: + self.forced_obsoletes.extend(self.config.getlist(pkg,"ForcedObsoletes")) # mark packages that are now obsolete (and where not obsolete # before) to be deleted. make sure to not delete any foreign -- cgit v1.2.3 From cbcb6a374bb92bd38e3dac13d5ab78c8fd2a4690 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Feb 2006 16:42:31 +0000 Subject: * make force_purges work --- DistUpgrade/DistUpgradeControler.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 4211c93b..7ee79cac 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -52,7 +52,8 @@ class DistUpgradeControler(object): # forced obsoletes self.forced_obsoletes = self.config.getlist("Distro","ForcedObsoletes") - + # forced purges + self.forced_purges = self.config.getlist("Distro","ForcedPurges") def openCache(self): self.cache = MyCache(self._view.getOpCacheProgress()) @@ -116,6 +117,9 @@ class DistUpgradeControler(object): # re-check if the written self.sources are valid, if not revert and # bail out + # TODO: check if some main packages are still available or if we + # accidently shot them, if not, maybe offer to write a standard + # sources.list? try: sourceslist = apt_pkg.GetPkgSourceList() sourceslist.ReadMainList() @@ -234,22 +238,35 @@ class DistUpgradeControler(object): logging.debug("Obsolete: %s" % " ".join(now_obsolete)) logging.debug("Foreign: %s" % " ".join(now_foreign)) - # now get the meta-pkg specific obsoletes + # now get the meta-pkg specific obsoletes and purges for pkg in self.config.getlist("Distro","MetaPkgs"): if self.cache.has_key(pkg) and self.cache[pkg].isInstalled: self.forced_obsoletes.extend(self.config.getlist(pkg,"ForcedObsoletes")) - + self.forced_purges.extend(self.config.getlist(pkg,"ForcedPurges")) + logging.debug("forced_obsoletes: %s", self.forced_obsoletes) + logging.debug("forced_purges: %s", self.forced_purges) + + # mark packages that are now obsolete (and where not obsolete # before) to be deleted. make sure to not delete any foreign # (that is, not from ubuntu) packages remove_candidates = now_obsolete - self.obsolete_pkgs remove_candidates |= set(self.forced_obsoletes) + logging.debug("remove_candidates: '%s'" % remove_candidates) logging.debug("Start checking for obsolete pkgs") for pkgname in remove_candidates: if pkgname not in self.foreign_pkgs: if not self.cache._tryMarkObsoleteForRemoval(pkgname, remove_candidates, self.foreign_pkgs): logging.debug("'%s' scheduled for remove but not in remove_candiates, skipping", pkgname) logging.debug("Finish checking for obsolete pkgs") + + # mark some stuff for purge + for pkg in self.forced_purges: + if self.cache.has_key(pkg): + logging.debug("Marking '%s' for purge", pkg) + self.cache._depcache.MarkDelete(self.cache[pkg]._pkg,True) + + # get changes changes = self.cache.getChanges() logging.debug("The following packages are remove candidates: %s" % " ".join([pkg.name for pkg in changes])) if len(changes) > 0 and \ -- cgit v1.2.3 From f593c02a4051313dd0044888a26d7ab3f4ba1133 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Feb 2006 17:06:07 +0000 Subject: * make DistUpgadeConfigParser -> DistUpgradeConfig --- DistUpgrade/DistUpgrade.cfg | 3 +++ DistUpgrade/DistUpgradeCache.py | 4 ++-- DistUpgrade/DistUpgradeConfigParser.py | 2 +- DistUpgrade/DistUpgradeControler.py | 4 ++-- DistUpgrade/dist-upgrade.py | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index b9cb2cc3..cf97d16f 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -1,3 +1,6 @@ +[General] +Frontend=GtkDistUpgradeView + # Distro contains global information about the upgrade [Distro] # the meta-pkgs we support diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py index 45d892c7..2836d297 100644 --- a/DistUpgrade/DistUpgradeCache.py +++ b/DistUpgrade/DistUpgradeCache.py @@ -5,7 +5,7 @@ import os import re import logging from gettext import gettext as _ -from DistUpgradeConfigParser import DistUpgradeConfigParser +from DistUpgradeConfigParser import DistUpgradeConfig class MyCache(apt.Cache): # init @@ -14,7 +14,7 @@ class MyCache(apt.Cache): self.to_install = [] self.to_remove = [] - self.config = DistUpgradeConfigParser() + self.config = DistUpgradeConfig() # turn on debuging apt_pkg.Config.Set("Debug::pkgProblemResolver","true") diff --git a/DistUpgrade/DistUpgradeConfigParser.py b/DistUpgrade/DistUpgradeConfigParser.py index 449e67b2..c87e2f1b 100644 --- a/DistUpgrade/DistUpgradeConfigParser.py +++ b/DistUpgrade/DistUpgradeConfigParser.py @@ -1,7 +1,7 @@ from ConfigParser import ConfigParser, NoOptionError -class DistUpgradeConfigParser(ConfigParser): +class DistUpgradeConfig(ConfigParser): def __init__(self): ConfigParser.__init__(self) self.read(['DistUpgrade.cfg']) diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 7ee79cac..3a43d517 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -28,7 +28,7 @@ import subprocess import logging import re import statvfs -from DistUpgradeConfigParser import DistUpgradeConfigParser +from DistUpgradeConfigParser import DistUpgradeConfig from SoftwareProperties.aptsources import SourcesList, SourceEntry from gettext import gettext as _ @@ -42,7 +42,7 @@ class DistUpgradeControler(object): self._view.updateStatus(_("Reading cache")) self.cache = None - self.config = DistUpgradeConfigParser() + self.config = DistUpgradeConfig() self.sources_backup_ext = "."+self.config.get("Files","BackupExt") # some constants here diff --git a/DistUpgrade/dist-upgrade.py b/DistUpgrade/dist-upgrade.py index eff05f35..14f9f4a1 100755 --- a/DistUpgrade/dist-upgrade.py +++ b/DistUpgrade/dist-upgrade.py @@ -2,6 +2,7 @@ from DistUpgradeViewGtk import GtkDistUpgradeView from DistUpgradeControler import DistUpgradeControler +from DistUpgradeConfigParser import DistUpgradeConfig import logging import os -- cgit v1.2.3 From 4422d2689f60ec0ac2d10db07919f746724cd9b3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Feb 2006 15:37:57 +0000 Subject: * added MaxRetries to the configuration, retry on update errors as well --- DistUpgrade/DistUpgrade.cfg | 6 ++--- DistUpgrade/DistUpgradeControler.py | 33 ++++++++++++++++++---------- DistUpgrade/DistUpgradeViewNonInteractive.py | 3 ++- 3 files changed, 26 insertions(+), 16 deletions(-) (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index fdc70150..f4491202 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -1,6 +1,3 @@ -[General] -Frontend=GtkDistUpgradeView - # Distro contains global information about the upgrade [Distro] # the meta-pkgs we support @@ -32,3 +29,6 @@ From=breezy To=dapper ValidOrigin=Ubuntu ValidMirrors = http://archive.ubuntu.com/ubuntu, http://security.ubuntu.com/ubuntu, http://archive.distrosprint/ubuntu/ + +[Network] +MaxRetries=3 \ No newline at end of file diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 3a43d517..1bcf81d3 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -158,17 +158,25 @@ class DistUpgradeControler(object): progress = self._view.getFetchProgress() # FIXME: retry here too? just like the DoDistUpgrade? # also remove all files from the lists partial dir! - try: - res = self.cache.update(progress) - except IOError, e: - self._view.error(_("Error during update"), - _("A problem occured during the update. " - "This is usually some sort of network " - "problem, please check your network " - "connection and retry."), - "%s" % e) - return False - return True + currentRetry = 0 + maxRetries = self.config.get("Network","MaxRetries") + while currentRetry < maxRetries: + try: + res = self.cache.update(progress) + except IOError, e: + logging.error("IOError in cache.update(): '%s'. Retrying (currentTry: %s)" % (e,currentTry)) + currentRetry += 1 + continue + # no exception, so all was fine, we are done + return True + + self._view.error(_("Error during update"), + _("A problem occured during the update. " + "This is usually some sort of network " + "problem, please check your network " + "connection and retry."), "%s" % e) + return False + def askDistUpgrade(self): if not self.cache.distUpgrade(self._view): @@ -196,7 +204,8 @@ class DistUpgradeControler(object): fprogress = self._view.getFetchProgress() iprogress = self._view.getInstallProgress() # retry the fetching in case of errors - while currentRetry < 3: + maxRetries = self.config.get("Network","MaxRetries") + while currentRetry < maxRetries: try: res = self.cache.commit(fprogress,iprogress) except SystemError, e: diff --git a/DistUpgrade/DistUpgradeViewNonInteractive.py b/DistUpgrade/DistUpgradeViewNonInteractive.py index bb426a7a..6bd110e4 100644 --- a/DistUpgrade/DistUpgradeViewNonInteractive.py +++ b/DistUpgrade/DistUpgradeViewNonInteractive.py @@ -21,6 +21,7 @@ import apt import logging +from DistUpgradeView import DistUpgradeView class NonInteractiveInstallProgress(apt.progress.InstallProgress): def error(self, pkg, errormsg): @@ -28,7 +29,7 @@ class NonInteractiveInstallProgress(apt.progress.InstallProgress): def conffile(self, current, new): logging.debug("got a conffile-prompt from dpkg for file: '%s'" % current) -class NonInteractiveDistUpgradeView(object): +class NonInteractiveDistUpgradeView(DistUpgradeView): " non-interactive version of the upgrade view " def __init__(self): pass -- cgit v1.2.3 From bf3614bae92b55fd038923002d4f01307dd72e06 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Feb 2006 17:41:20 +0000 Subject: * fix in the retry code --- DistUpgrade/DistUpgradeControler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 1bcf81d3..71127092 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -164,7 +164,7 @@ class DistUpgradeControler(object): try: res = self.cache.update(progress) except IOError, e: - logging.error("IOError in cache.update(): '%s'. Retrying (currentTry: %s)" % (e,currentTry)) + logging.error("IOError in cache.update(): '%s'. Retrying (currentRetry: %s)" % (e,currentRetry)) currentRetry += 1 continue # no exception, so all was fine, we are done @@ -199,7 +199,7 @@ class DistUpgradeControler(object): self.cache.requiredDownload) return res - def doDistUpgrade(self, currentTry=0): + def doDistUpgrade(self): currentRetry = 0 fprogress = self._view.getFetchProgress() iprogress = self._view.getInstallProgress() @@ -219,7 +219,7 @@ class DistUpgradeControler(object): return False except IOError, e: # fetch failed, will be retried - logging.error("IOError in cache.commit(): '%s'. Retrying (currentTry: %s)" % (e,currentTry)) + logging.error("IOError in cache.commit(): '%s'. Retrying (currentTry: %s)" % (e,currentRetry)) currentRetry += 1 continue # no exception, so all was fine, we are done -- cgit v1.2.3 From e8b68ea2858f439e93b36a1fb320ea4243790159 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Feb 2006 14:21:36 +0100 Subject: * added a "PostUpgrade{Install,Remove,Purge}" rule, removed the ForcedPurges and superseed it with the new rule --- DistUpgrade/DistUpgrade.cfg | 8 +++++--- DistUpgrade/DistUpgradeCache.py | 30 ++++++++++++++++++++++++++++++ DistUpgrade/DistUpgradeControler.py | 11 +---------- DistUpgrade/README | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 DistUpgrade/README (limited to 'DistUpgrade/DistUpgradeControler.py') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index e081313a..a2720f49 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -7,15 +7,17 @@ View=DistUpgradeViewGtk # the meta-pkgs we support MetaPkgs=ubuntu-desktop, kubuntu-desktop, edubuntu-desktop, xubuntu-desktop BaseMetaPkgs=ubuntu-base -ForcedPurges=xorg-common +PostUpgradePurge=xorg-common # information about the individual meta-pkgs [ubuntu-desktop] KeyDependencies=gdm, gnome-panel, ubuntu-artwork -ForcedObsoletes=xscreensaver +# those pkgs will be marked remove right after the distUpgrade in the cache +PostUpgradeRemove=xchat, xscreensaver [kubuntu-desktop] KeyDependencies=kdm, kicker, kubuntu-artwork-usplash +# those packages are marked as obsolete right after the upgrade ForcedObsoletes=ivman [edubuntu-desktop] @@ -32,7 +34,7 @@ BackupExt=distUpgrade From=breezy To=dapper ValidOrigin=Ubuntu -ValidMirrors = http://archive.ubuntu.com/ubuntu, http://security.ubuntu.com/ubuntu, http://archive.distrosprint/ubuntu/ +ValidMirrors = http://archive.ubuntu.com/ubuntu, http://security.ubuntu.com/ubuntu [Network] MaxRetries=3 \ No newline at end of file diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py index 6826e3ba..b20c9f77 100644 --- a/DistUpgrade/DistUpgradeCache.py +++ b/DistUpgrade/DistUpgradeCache.py @@ -15,6 +15,7 @@ class MyCache(apt.Cache): self.to_remove = [] self.config = DistUpgradeConfig() + self.metapkgs = self.config.getlist("Distro","MetaPkgs") # turn on debuging apt_pkg.Config.Set("Debug::pkgProblemResolver","true") @@ -97,10 +98,38 @@ class MyCache(apt.Cache): return False return True + def markInstall(self, pkg, reason=""): + logging.debug("Installing '%s' (%s)" % (pkg, reason)) + if self.has_key(pkg): + self[pkg].markInstall() + def markRemove(self, pkg, reason=""): + logging.debug("Removing '%s' (%s)" % (pkg, reason)) + if self.has_key(pkg): + self[pkg].markDelete() + def markPurge(self, pkg, reason=""): + logging.debug("Purging '%s' (%s)" % (pkg, reason)) + if self.has_key(pkg): + self._depcache.MarkDelete(self[pkg]._pkg,True) + + def postUpgradeRule(self): + " run after the upgrade was done in the cache " + for (rule, action) in [("Install", self.markInstall), + ("Remove", self.markRemove), + ("Purge", self.markPurge)]: + # first the global list + for pkg in self.config.getlist("Distro","PostUpgrade%s" % rule): + action(pkg, "Distro PostUpgrade%s rule" % rule) + for key in self.metapkgs: + if self.has_key(key) and self[key].isInstalled: + for pkg in self.config.getlist(key,"PostUpgrade%s" % rule): + action(pkg, "%s PostUpgrade%s rule" % (key, rule)) + def distUpgrade(self, view): try: # upgrade (and make sure this way that the cache is ok) self.upgrade(True) + self.postUpgradeRule() + if not self._installMetaPkgs(view): raise SystemError, _("Can't upgrade required meta-packages") if not self._verifyChanges(): @@ -176,6 +205,7 @@ class MyCache(apt.Cache): for key in metapkgs: try: if self.has_key(key) and self[key].isInstalled: + logging.debug("Marking '%s' for upgrade" % key) self[key].markUpgrade() except SystemError, e: logging.debug("Can't mark '%s' for upgrade" % key) diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 71127092..9fa717fe 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -52,8 +52,6 @@ class DistUpgradeControler(object): # forced obsoletes self.forced_obsoletes = self.config.getlist("Distro","ForcedObsoletes") - # forced purges - self.forced_purges = self.config.getlist("Distro","ForcedPurges") def openCache(self): self.cache = MyCache(self._view.getOpCacheProgress()) @@ -251,9 +249,8 @@ class DistUpgradeControler(object): for pkg in self.config.getlist("Distro","MetaPkgs"): if self.cache.has_key(pkg) and self.cache[pkg].isInstalled: self.forced_obsoletes.extend(self.config.getlist(pkg,"ForcedObsoletes")) - self.forced_purges.extend(self.config.getlist(pkg,"ForcedPurges")) logging.debug("forced_obsoletes: %s", self.forced_obsoletes) - logging.debug("forced_purges: %s", self.forced_purges) + # mark packages that are now obsolete (and where not obsolete @@ -269,12 +266,6 @@ class DistUpgradeControler(object): logging.debug("'%s' scheduled for remove but not in remove_candiates, skipping", pkgname) logging.debug("Finish checking for obsolete pkgs") - # mark some stuff for purge - for pkg in self.forced_purges: - if self.cache.has_key(pkg): - logging.debug("Marking '%s' for purge", pkg) - self.cache._depcache.MarkDelete(self.cache[pkg]._pkg,True) - # get changes changes = self.cache.getChanges() logging.debug("The following packages are remove candidates: %s" % " ".join([pkg.name for pkg in changes])) diff --git a/DistUpgrade/README b/DistUpgrade/README new file mode 100644 index 00000000..28684985 --- /dev/null +++ b/DistUpgrade/README @@ -0,0 +1,32 @@ +The DistUpgrade.cfg format is based on the python ConfigParser. + +It supports the following sections: + +[View] - controls the output + +[Distro] - global distribution specfic options +BaseMetaPkgs: + the basic meta-pkgs that must be installed (ubuntu-base usually) +MetaPkgs: + packages that define a "desktop" (e.g. ubuntu-desktop) +PostUpgrade{Install,Remove,Purge}: + action right after the upgrade was calculated in the cache (marking + happens *before* the cache.commit()) +ForcedObsoletes: + Obsolete packages that the user is asked about after the upgrade (marking + happens *after* the cache.commit()) + +[$meta-pkg] +KeyDependencies: + Dependencies that are considered "key" dependencies of the meta-pkg to + detect if it was installed but later removed by the user +PostUpgrade{Install,Remove,Purge}: + s.above +ForcedObsoletes: + s.above + +[Files] - file specific stuff + +[Sources] - how to rewrite the sources.list + +[Network] - network specific options \ No newline at end of file -- cgit v1.2.3