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') 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 41006b0fd874a862195b918fad17a7ae04f4fe57 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Feb 2006 11:41:31 +0000 Subject: * added first non-interactive version --- DistUpgrade/DistUpgradeViewNonInteractive.py | 72 ++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 DistUpgrade/DistUpgradeViewNonInteractive.py (limited to 'DistUpgrade') diff --git a/DistUpgrade/DistUpgradeViewNonInteractive.py b/DistUpgrade/DistUpgradeViewNonInteractive.py new file mode 100644 index 00000000..f77d3d43 --- /dev/null +++ b/DistUpgrade/DistUpgradeViewNonInteractive.py @@ -0,0 +1,72 @@ +# DistUpgradeView.py +# +# Copyright (c) 2004,2005 Canonical +# +# Author: Michael Vogt +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA + +class NonInteractiveDistUpgradeView(object): + " non-interactive version of the upgrade view " + def __init__(self): + pass + def getOpCacheProgress(self): + " return a OpProgress() subclass for the given graphic" + return apt.progress.OpProgress() + def getFetchProgress(self): + " return a fetch progress object " + return apt.progress.FetchProgress() + def getInstallProgress(self): + " return a install progress object " + return apt.progress.InstallProgress() + def updateStatus(self, msg): + """ update the current status of the distUpgrade based + on the current view + """ + pass + def setStep(self, step): + """ we have 5 steps current for a upgrade: + 1. Analyzing the system + 2. Updating repository information + 3. Performing the upgrade + 4. Post upgrade stuff + 5. Complete + """ + pass + def confirmChanges(self, summary, changes, downloadSize): + """ display the list of changed packages (apt.Package) and + return if the user confirms them + """ + self.toInstall = [] + self.toUpgrade = [] + self.toRemove = [] + for pkg in changes: + if pkg.markedInstall: self.toInstall.append(pkg.name) + elif pkg.markedUpgrade: self.toUpgrade.append(pkg.name) + elif pkg.markedDelete: self.toRemove.append(pkg.name) + # no downgrades, re-installs + assert(len(self.toInstall)+len(self.toUpgrade)+len(self.toRemove) == len(changes)) + return True + def askYesNoQuestion(self, summary, msg): + " ask a Yes/No question and return True on 'Yes' " + return True + def confirmRestart(self): + " generic ask about the restart, can be overriden " + return False + def error(self, summary, msg, extended_msg=None): + " display a error " + logging.error("%s %s (%s)" % (summary, msg, extended_msg) + -- 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') 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') 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') 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') 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') 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