diff options
| author | Sebastian Heinlein <sebi@sebi-pc> | 2006-10-09 16:30:22 +0200 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@sebi-pc> | 2006-10-09 16:30:22 +0200 |
| commit | 71121af388843e45eb2b655b6d1bd94542503651 (patch) | |
| tree | 9481c824609dd6777dc3470c42c8e43c0b78d5ff /DistUpgrade | |
| parent | 7afafc629b7c5b408972aafc46ef5d1887544aac (diff) | |
| parent | ff9de68c6430ff296e0781a8cee1122e89785db5 (diff) | |
| download | python-apt-71121af388843e45eb2b655b6d1bd94542503651.tar.gz | |
* merge with mvo
Diffstat (limited to 'DistUpgrade')
| -rw-r--r-- | DistUpgrade/Changelog | 4 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgrade.cfg | 3 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgrade.glade | 6 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeCache.py | 49 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeControler.py | 33 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeView.py | 4 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeViewGtk.py | 24 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeViewText.py | 196 |
8 files changed, 286 insertions, 33 deletions
diff --git a/DistUpgrade/Changelog b/DistUpgrade/Changelog index 5f7ba584..ece5feda 100644 --- a/DistUpgrade/Changelog +++ b/DistUpgrade/Changelog @@ -1,3 +1,7 @@ +2006-10-06: + - fix source.list rewrite corner case bug (#64159) +2006-10-04: + - improve the space checking/logging 2006-09-29: - typo fix (thanks to Jane Silber) (lp: #62946) 2006-09-28: diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index b25def9a..f399a1f5 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -1,6 +1,7 @@ [View] View=DistUpgradeViewGtk #View=DistUpgradeViewNonInteractive +#View=DistUpgradeViewText # Distro contains global information about the upgrade [Distro] @@ -20,7 +21,7 @@ KeepInstalledSection=translations [ubuntu-desktop] KeyDependencies=gdm, gnome-panel, ubuntu-artwork # those pkgs will be marked remove right after the distUpgrade in the cache -PostUpgradeRemove=xchat, xscreensaver +PostUpgradeRemove=xscreensaver [kubuntu-desktop] KeyDependencies=kdm, kicker, kubuntu-artwork-usplash diff --git a/DistUpgrade/DistUpgrade.glade b/DistUpgrade/DistUpgrade.glade index 615f698c..2d4ebf92 100644 --- a/DistUpgrade/DistUpgrade.glade +++ b/DistUpgrade/DistUpgrade.glade @@ -682,7 +682,7 @@ <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> - <property name="label">_Start Upgrade</property> + <property name="label" translatable="yes">_Start Upgrade</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> @@ -1264,7 +1264,7 @@ <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> - <property name="label">_Continue</property> + <property name="label" translatable="yes">_Continue</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> @@ -1487,7 +1487,7 @@ <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> - <property name="label">_Cancel Upgrade</property> + <property name="label" translatable="yes">_Cancel Upgrade</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py index 318c30cd..7d0d27e0 100644 --- a/DistUpgrade/DistUpgradeCache.py +++ b/DistUpgrade/DistUpgradeCache.py @@ -1,7 +1,6 @@ import warnings warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning) -warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning) import apt import apt_pkg import os @@ -164,6 +163,31 @@ class MyCache(apt.Cache): if func is not None: func() + def edgyQuirks(self): + """ this function works around quirks in the dapper->edgy upgrade """ + logging.debug("running edgyQuirks handler") + # deal with the python2.4-$foo -> python-$foo transition + for pkg in self: + if (pkg.name.startswith("python2.4-") and + pkg.isInstalled and + not pkg.markedUpgrade): + basepkg = "python-"+pkg.name[len("python2.4-"):] + if (self.has_key(basepkg) and not self[basepkg].markedInstall): + try: + self.markInstall(basepkg, + "python2.4->python upgrade rule") + except SystemError, e: + logging.debug("Failed to apply python2.4->python install: %s (%s)" % (basepkg, e)) + # deal with *gar*gar* hpijs + if (self.has_key("hpijs") and self["hpijs"].isInstalled and + not self["hpijs"].markedUpgrade): + try: + self.markInstall("hpijs","hpijs quirk upgrade rule") + except SystemError, e: + logging.debug("Failed to apply hpijs install (%s)" % e) + + + def dapperQuirks(self): """ this function works around quirks in the breezy->dapper upgrade """ logging.debug("running dapperQuirks handler") @@ -283,8 +307,8 @@ class MyCache(apt.Cache): logging.debug("guessing '%s' as missing meta-pkg" % key) try: self[key].markInstall() - except SystemError: - logging.error("failed to mark '%s' for install" % key) + except SystemError, e: + logging.error("failed to mark '%s' for install (%s)" % (key,e)) view.error(_("Can't install '%s'" % key), _("It was impossible to install a " "required package. Please report " @@ -316,13 +340,18 @@ class MyCache(apt.Cache): # if it dosn't remove other packages depending on it # that are not obsolete as well self.create_snapshot() - self[pkgname].markDelete() - for pkg in self.getChanges(): - if pkg.name not in remove_candidates or \ - pkg.name in foreign_pkgs or \ - self._inRemovalBlacklist(pkg.name): - self.restore_snapshot() - return False + try: + self[pkgname].markDelete() + for pkg in self.getChanges(): + if pkg.name not in remove_candidates or \ + pkg.name in foreign_pkgs or \ + self._inRemovalBlacklist(pkg.name): + self.restore_snapshot() + return False + except (SystemError,KeyError),e: + loggging.warning("_tryMarkObsoleteForRemoval failed for '%s' (%s)" % (pkgname,e)) + self.restore_snapshot() + return False return True def _getObsoletesPkgs(self): diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 7b255cf0..7b35f3c8 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -75,7 +75,7 @@ class AptCdrom(object): _("There was a error adding the CD, the " "upgrade will abort. Please report this as " "a bug if this is a valid Ubuntu CD.\n\n" - "The error message was:\n'%s'" % e)) + "The error message was:\n'%s'") % e) return False logging.debug("AptCdrom.add() returned: %s" % res) return res @@ -142,7 +142,11 @@ class DistUpgradeControler(object): def prepare(self): """ initial cache opening, sanity checking, network checking """ - self.openCache() + try: + self.openCache() + except SystemError, e: + logging.error("openCache() failed: '%s'" % e) + return False if not self.cache.sanityCheck(self._view): return False # FIXME: we may try to find out a bit more about the network @@ -368,6 +372,18 @@ class DistUpgradeControler(object): "packages of former installations using " "'sudo apt-get clean'.") + # gather/log some staticts + mnt_map = {} + for d in ["/","/usr","/var","/boot"]: + st = os.statvfs(d) + free = st[statvfs.F_BAVAIL]*st[statvfs.F_FRSIZE] + if st in mnt_map: + logging.debug("Dir %s mounted on %s" % (d,mnt_map[st])) + else: + logging.debug("Free space on %s: %s" % (d,free)) + mnt_map[st] = d + del mnt_map + # first check for /var (or where the archives are downloaded too) archivedir = apt_pkg.Config.FindDir("Dir::Cache::archives") st_archivedir = os.statvfs(archivedir) @@ -613,7 +629,7 @@ class DistUpgradeControler(object): uri = match.group(1) + path apt_pkg.GetPkgAcqFile(fetcher, uri=uri, size=ver.Size, - descr=_("Fetching backport of '%s'" % pkgname)) + descr=_("Fetching backport of '%s'") % pkgname) res = fetcher.Run() if res != fetcher.ResultContinue: # ick! error ... @@ -644,7 +660,7 @@ class DistUpgradeControler(object): else: args.append("--without-network") os.execve(sys.argv[0],args, os.environ) - + # this is the core def edgyUpgrade(self): # sanity check (check for ubuntu-desktop, brokenCache etc) @@ -652,7 +668,14 @@ class DistUpgradeControler(object): self._view.setStep(1) if not self.prepare(): - self.abort(1) + self._view.error(_("Preparing the upgrade failed"), + _("Preparing the system for the upgrade " + "failed. Please report this as a bug " + "against the 'update-manager' " + "package and include the files in " + "/var/log/dist-upgrade/ " + "in the bugreport." )) + sys.exit(1) # mvo: commented out for now, see #54234, this needs to be # refactored to use a arch=any tarball diff --git a/DistUpgrade/DistUpgradeView.py b/DistUpgrade/DistUpgradeView.py index a9cd16d7..40617774 100644 --- a/DistUpgrade/DistUpgradeView.py +++ b/DistUpgrade/DistUpgradeView.py @@ -35,8 +35,8 @@ def estimatedDownloadTime(requiredDownload): """ get the estimated download time """ timeModem = requiredDownload/(56*1024/8) # 56 kbit timeDSL = requiredDownload/(1024*1024/8) # 1Mbit = 1024 kbit - s= _("This download will take about %s with a 56k modem and about %s with " - "a 1Mbit DSL connection" % (FuzzyTimeToStr(timeModem), FuzzyTimeToStr(timeDSL))) + s= _("This download will take about %s with a 1Mbit DSL connection " + "and about %s with a 56k modem" % (FuzzyTimeToStr(timeDSL),FuzzyTimeToStr(timeModem))) return s diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 1385d18f..e77fe858 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -97,7 +97,7 @@ class GtkFetchProgressAdapter(apt.progress.FetchProgress): self.parent = parent def mediaChange(self, medium, drive): #print "mediaChange %s %s" % (medium, drive) - msg = _("Please insert '%s' into the drive '%s'" % (medium,drive)) + msg = _("Please insert '%s' into the drive '%s'") % (medium,drive) dialog = gtk.MessageDialog(parent=self.parent.window_main, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_QUESTION, @@ -126,10 +126,10 @@ class GtkFetchProgressAdapter(apt.progress.FetchProgress): currentItem = self.totalItems if self.currentCPS > 0: - self.status.set_text(_("Fetching file %li of %li at %s/s" % (currentItem, self.totalItems, apt_pkg.SizeToStr(self.currentCPS)))) + self.status.set_text(_("Fetching file %li of %li at %s/s") % (currentItem, self.totalItems, apt_pkg.SizeToStr(self.currentCPS))) self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(self.eta)) else: - self.status.set_text(_("Fetching file %li of %li" % (currentItem, self.totalItems))) + self.status.set_text(_("Fetching file %li of %li") % (currentItem, self.totalItems)) self.progress.set_text(" ") while gtk.events_pending(): @@ -184,7 +184,7 @@ class GtkInstallProgressAdapter(InstallProgress): logging.error("got an error from dpkg for pkg: '%s': '%s'" % (pkg, errormsg)) #self.expander_terminal.set_expanded(True) self.parent.dialog_error.set_transient_for(self.parent.window_main) - summary = _("Could not install '%s'" % pkg) + summary = _("Could not install '%s'") % pkg msg = _("The upgrade aborts now. Please report this bug against the 'update-manager' " "package and include the files in /var/log/dist-upgrade/ in the bugreport.") markup="<big><b>%s</b></big>\n\n%s" % (summary, msg) @@ -200,9 +200,9 @@ class GtkInstallProgressAdapter(InstallProgress): logging.debug("got a conffile-prompt from dpkg for file: '%s'" % current) #self.expander.set_expanded(True) prim = _("Replace the customized configuration file\n'%s'?") % current - sec = _("You will loose all customizations, that have been made by " - "yourself or by a script, if you replace the file by its " - "latest version.") + sec = _("You will lose any changes you have made to this " + "configuration file if you choose to replace it with " + "a newer version.") markup = "<span weight=\"bold\" size=\"larger\">%s </span> \n\n%s" % (prim, sec) self.parent.label_conffile.set_markup(markup) self.parent.dialog_conffile.set_transient_for(self.parent.window_main) @@ -500,8 +500,8 @@ class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp): pkgs_upgrade) % pkgs_upgrade msg +=" " if downloadSize > 0: - msg += _("\n\nYou have to download a total of %s. " %\ - apt_pkg.SizeToStr(downloadSize)) + msg += _("\n\nYou have to download a total of %s. ") %\ + apt_pkg.SizeToStr(downloadSize) msg += estimatedDownloadTime(downloadSize) msg += "." @@ -532,11 +532,11 @@ class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp): # fill in the details self.details_list.clear() for rm in self.toRemove: - self.details_list.append([_("<b>Remove %s</b>" % rm)]) + self.details_list.append([_("<b>Remove %s</b>") % rm]) for inst in self.toInstall: - self.details_list.append([_("Install %s" % inst)]) + self.details_list.append([_("Install %s") % inst]) for up in self.toUpgrade: - self.details_list.append([_("Upgrade %s" % up)]) + self.details_list.append([_("Upgrade %s") % up]) self.treeview_details.scroll_to_cell((0,)) self.dialog_changes.set_transient_for(self.window_main) self.dialog_changes.realize() diff --git a/DistUpgrade/DistUpgradeViewText.py b/DistUpgrade/DistUpgradeViewText.py new file mode 100644 index 00000000..b3bd61e3 --- /dev/null +++ b/DistUpgrade/DistUpgradeViewText.py @@ -0,0 +1,196 @@ +# DistUpgradeViewText.py +# +# Copyright (c) 2004-2006 Canonical +# +# Author: Michael Vogt <michael.vogt@ubuntu.com> +# +# 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 + +import sys +import logging +import time +import subprocess + +import apt +import apt_pkg +import os + +from apt.progress import InstallProgress +from DistUpgradeView import DistUpgradeView, FuzzyTimeToStr, estimatedDownloadTime + +import gettext +from gettext import gettext as _ + +class TextCdromProgressAdapter(apt.progress.CdromProgress): + """ Report the cdrom add progress """ + def update(self, text, step): + """ update is called regularly so that the gui can be redrawn """ + if text: + print "%s (%f)" % (text, step/float(self.totalSteps)*100) + def askCdromName(self): + return (False, "") + def changeCdrom(self): + return False + + +class DistUpgradeViewText(DistUpgradeView): + " text frontend of the distUpgrade tool " + def __init__(self, datadir=None): + if not datadir: + localedir=os.path.join(os.getcwd(),"mo") + else: + localedir="/usr/share/locale/update-manager" + + try: + gettext.bindtextdomain("update-manager", localedir) + gettext.textdomain("update-manager") + except Exception, e: + logging.warning("Error setting locales (%s)" % e) + + self.last_step = 0 # keep a record of the latest step + self._opCacheProgress = apt.progress.OpTextProgress() + self._fetchProgress = apt.progress.TextFetchProgress() + self._cdromProgress = TextCdromProgressAdapter() + self._installProgress = apt.progress.InstallProgress() + sys.excepthook = self._handleException + + def _handleException(self, type, value, tb): + import traceback + lines = traceback.format_exception(type, value, tb) + logging.error("not handled expection:\n%s" % "\n".join(lines)) + self.error(_("A fatal error occured"), + _("Please report this as a bug and include the " + "files /var/log/dist-upgrade/main.log and " + "/var/log/dist-upgrade/apt.log " + "in your report. The upgrade aborts now.\n" + "Your original sources.list was saved in " + "/etc/apt/sources.list.distUpgrade."), + "\n".join(lines)) + sys.exit(1) + + def getFetchProgress(self): + return self._fetchProgress + def getInstallProgress(self, cache): + self._installProgress._cache = cache + return self._installProgress + def getOpCacheProgress(self): + return self._opCacheProgress + def getCdromProgress(self): + return self._cdromProgress + def updateStatus(self, msg): + print msg + def abort(self): + print _("Aborting") + def setStep(self, step): + self.last_step = step + def information(self, summary, msg, extended_msg=None): + print summary + print msg + if extended_msg: + print extended_msg + def error(self, summary, msg, extended_msg=None): + print summary + print msg + if extended_msg: + print extended_msg + return False + def confirmChanges(self, summary, changes, downloadSize, actions=None): + DistUpgradeView.confirmChanges(self, summary, changes, downloadSize, actions) + pkgs_remove = len(self.toRemove) + pkgs_inst = len(self.toInstall) + pkgs_upgrade = len(self.toUpgrade) + msg = "" + + if pkgs_remove > 0: + # FIXME: make those two seperate lines to make it clear + # that the "%" applies to the result of ngettext + msg += gettext.ngettext("%d package is going to be removed.", + "%d packages are going to be removed.", + pkgs_remove) % pkgs_remove + msg += " " + if pkgs_inst > 0: + msg += gettext.ngettext("%d new package is going to be " + "installed.", + "%d new packages are going to be " + "installed.",pkgs_inst) % pkgs_inst + msg += " " + if pkgs_upgrade > 0: + msg += gettext.ngettext("%d package is going to be upgraded.", + "%d packages are going to be upgraded.", + pkgs_upgrade) % pkgs_upgrade + msg +=" " + if downloadSize > 0: + msg += _("\n\nYou have to download a total of %s. ") %\ + apt_pkg.SizeToStr(downloadSize) + msg += estimatedDownloadTime(downloadSize) + msg += "." + if (pkgs_upgrade + pkgs_inst + pkgs_remove) > 100: + msg += "\n\n%s" % _("Fetching and installing the upgrade can take several hours and "\ + "cannot be canceled at any time later.") + + # Show an error if no actions are planned + if (pkgs_upgrade + pkgs_inst + pkgs_remove) < 1: + # FIXME: this should go into DistUpgradeController + summary = _("Your system is up-to-date") + msg = _("There are no upgrades available for your system. " + "The upgrade will now be canceled.") + self.error(summary, msg) + return False + + return self.askYesNoQuestion(summary, msg) + + def askYesNoQuestion(self, summary, msg): + print summary + print msg + print _("Continue [Yn] "), + res = sys.stdin.readline() + if res.strip().lower().startswith("y"): + return True + return False + + def confirmRestart(self): + return self.askYesNoQuestion(_("Restart required"), + _("To fully ugprade, please restart")) + + +if __name__ == "__main__": + + view = DistUpgradeViewText() + view.confirmChanges("xx",[], 100) + sys.exit(0) + + fp = apt.progress.TextFetchProgress() + ip = apt.progress.InstallProgress() + + cache = apt.Cache() + for pkg in sys.argv[1:]: + cache[pkg].markInstall() + cache.commit(fp,ip) + + #sys.exit(0) + view.getTerminal().call(["dpkg","--configure","-a"]) + #view.getTerminal().call(["ls","-R","/usr"]) + view.error("short","long", + "asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n" + "asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n" + "asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n" + "asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n" + "asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n" + "asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n" + "asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n" + ) + view.confirmChanges("xx",[], 100) + print view.askYesNoQuestion("hello", "Icecream?") |
