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/DistUpgradeCache.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'DistUpgrade/DistUpgradeCache.py') 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): -- 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/DistUpgradeCache.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 d5021367c09c22f7ab6296bbec5f159ee0ab0dda Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Feb 2006 11:46:06 +0100 Subject: * DistUpgrade/DistUpgradeCache.py: cache._installMetaPkgs(): support meta-pkgs in universe as well (like xubuntu-desktop) --- DistUpgrade/DistUpgradeCache.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'DistUpgrade/DistUpgradeCache.py') diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py index 2836d297..6826e3ba 100644 --- a/DistUpgrade/DistUpgradeCache.py +++ b/DistUpgrade/DistUpgradeCache.py @@ -175,7 +175,8 @@ class MyCache(apt.Cache): # install (that result in a upgrade and removes a markDelete) for key in metapkgs: try: - if self[key].isInstalled: self[key].markUpgrade() + if self.has_key(key) and self[key].isInstalled: + self[key].markUpgrade() except SystemError, e: logging.debug("Can't mark '%s' for upgrade" % key) return False -- 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/DistUpgradeCache.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