From 28d131b543b638589c243abb6b1c247c8c653321 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Thu, 23 Feb 2006 13:24:40 +0100 Subject: * Move the mime type handling of sources.lists to gnome-software-properties * Renamed mime type to text/x-apt-sources-list * Remove all depricated add-software-channel code * Add a schemas file for update-manager * Use dh_gconf * Software Properties: - Move the channel buttons to the bottom of the notebook to get more vertical space for the channels - Set a global window icon for SoftwareProperties and its children - Add drag and drop support for sources.list on the treeview_sources - Allow to enable and disable channels - Do not use so much space for rendering the sources lista - Use the comment instead of the URI in the channel list if we don't find a nice name - Show the type only on source channels - "binary" is too technial - Add some small sanity checks to aptsources - Use single quotes in the predefind distru names * Dialog add: - merge the custom and the default add dialog - sanity checks for the custom apt line, that do not allow to add a wrong one * Update Manager: - add an option to hide the reload reminder --- UpdateManager/UpdateManager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'UpdateManager') diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index 8b757bd1..e6394223 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -28,6 +28,7 @@ pygtk.require('2.0') import gtk import gtk.gdk import gtk.glade +import gconf import gobject import apt import apt_pkg @@ -40,7 +41,6 @@ import os.path import urllib2 import re import tempfile -import gconf import pango import subprocess import pwd @@ -290,6 +290,10 @@ class UpdateManager(SimpleGladeApp): self.restore_state() + def on_checkbutton_reminder_toggled(self, checkbutton): + self.gconfclient.set_bool("/apps/update-manager/remind_reload", + not checkbutton.get_active()) + def close(self, widget, data=None): if self.window_main.get_property("sensitive") is False: return True @@ -812,6 +816,10 @@ class UpdateManager(SimpleGladeApp): def check_auto_update(self): # Check if automatic update is enabled. If not show a dialog to inform # the user about the need of manual "reloads" + remind = self.gconfclient.get_bool("/apps/update-manager/remind_reload") + if remind == False: + return + update_days = apt_pkg.Config.FindI("APT::Periodic::Update-Package-Lists") if update_days < 1: self.dialog_manual_update.set_transient_for(self.window_main) -- cgit v1.2.3 From a06fbb1dcf05c9b21dc30a011048e556e037a33d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Feb 2006 15:23:23 +0100 Subject: * formating --- UpdateManager/UpdateManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'UpdateManager') diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index e6394223..22c7a6a5 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -480,7 +480,7 @@ class UpdateManager(SimpleGladeApp): lock = thread.allocate_lock() lock.acquire() t = thread.start_new_thread(self.run_synaptic, - (self.window_main.window.xid ,action,lock)) + (self.window_main.window.xid,action,lock)) while lock.locked(): while gtk.events_pending(): gtk.main_iteration() -- cgit v1.2.3 From 15c800a63e03039f55f06540f49975d1663be25a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Feb 2006 20:43:26 +0100 Subject: * move the fetcher code out into UpdateManager/DistUpgradeFetcher.py * add authentication --- UpdateManager/DistUpgradeFetcher.py | 197 ++++++++++++++++++++++++++++++++++++ UpdateManager/MetaRelease.py | 4 +- UpdateManager/UpdateManager.py | 118 +-------------------- 3 files changed, 203 insertions(+), 116 deletions(-) create mode 100644 UpdateManager/DistUpgradeFetcher.py (limited to 'UpdateManager') diff --git a/UpdateManager/DistUpgradeFetcher.py b/UpdateManager/DistUpgradeFetcher.py new file mode 100644 index 00000000..7af32865 --- /dev/null +++ b/UpdateManager/DistUpgradeFetcher.py @@ -0,0 +1,197 @@ +# DistUpgradeFetcher.py +# +# Copyright (c) 2006 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 + +import pygtk +pygtk.require('2.0') +import gtk +import os +import apt_pkg +import tarfile +import urllib2 +import tempfile +import GnuPGInterface +from gettext import gettext as _ + +import GtkProgress +from ReleaseNotesViewer import ReleaseNotesViewer + + +class DistUpgradeFetcher(object): + + def __init__(self, parent, new_dist): + self.parent = parent + self.window_main = parent.window_main + self.new_dist = new_dist + + def showReleaseNotes(self): + # FIXME: care about i18n! (append -$lang or something) + if self.new_dist.releaseNotesURI != None: + uri = self.new_dist.releaseNotesURI + self.window_main.set_sensitive(False) + self.window_main.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) + while gtk.events_pending(): + gtk.main_iteration() + + # download/display the release notes + # FIXME: add some progress reporting here + res = gtk.RESPONSE_CANCEL + try: + release_notes = urllib2.urlopen(uri) + notes = release_notes.read() + textview_release_notes = ReleaseNotesViewer(notes) + textview_release_notes.show() + self.parent.scrolled_notes.add(textview_release_notes) + self.parent.dialog_release_notes.set_transient_for(self.window_main) + res = self.parent.dialog_release_notes.run() + self.parent.dialog_release_notes.hide() + except urllib2.HTTPError: + primary = "%s" % \ + _("Could not find the release notes") + secondary = _("The server may be overloaded. ") + dialog = gtk.MessageDialog(self.window_main,gtk.DIALOG_MODAL, + gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE,"") + dialog.set_title("") + dialog.set_markup(primary); + dialog.format_secondary_text(secondary); + dialog.run() + dialog.destroy() + except IOError: + primary = "%s" % \ + _("Could not download the release notes") + secondary = _("Please check your internet connection.") + dialog = gtk.MessageDialog(self.window_main,gtk.DIALOG_MODAL, + gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE,"") + dialog.set_title("") + dialog.set_markup(primary); + dialog.format_secondary_text(secondary); + dialog.run() + dialog.destroy() + self.window_main.set_sensitive(True) + self.window_main.window.set_cursor(None) + # user clicked cancel + if res == gtk.RESPONSE_CANCEL: + return False + return True + + def authenticate(self, file, signature, keyring='/etc/apt/trusted.gpg'): + """ authenticated a file against a given signature, if no keyring + is given use the apt default keyring + """ + gpg = GnuPGInterface.GnuPG() + gpg.options.extra_args = ['--no-default-keyring', + '--keyring', keyring] + proc = gpg.run(['--verify', signature, file], + create_fhs=['status','logger','stderr']) + gpgres = proc.handles['status'].read() + if "VALIDSIG" in gpgres: + return True + return False + + def extractDistUpgrader(self): + # extract the tarbal + print "extracting '%s'" % (self.tmpdir+"/"+os.path.basename(self.uri)) + tar = tarfile.open(self.tmpdir+"/"+os.path.basename(self.uri),"r") + for tarinfo in tar: + tar.extract(tarinfo) + tar.close() + return True + + def verifyDistUprader(self): + # FIXME: check a internal dependency file to make sure + # that the script will run correctly + + # see if we have a script file that we can run + self.script = script = "%s/%s" % (self.tmpdir, self.new_dist.name) + if not os.path.exists(script): + # no script file found in extracted tarbal + primary = "%s" % \ + _("Could not run the upgrade tool") + secondary = _("This is most likely a bug in the upgrade tool. " + "Please report it as a bug") + dialog = gtk.MessageDialog(self.window_main,gtk.DIALOG_MODAL, + gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE,"") + dialog.set_title("") + dialog.set_markup(primary); + dialog.format_secondary_text(secondary); + dialog.run() + dialog.destroy() + return False + return True + + def fetchDistUpgrader(self): + # now download the tarball with the upgrade script + self.tmpdir = tmpdir = tempfile.mkdtemp() + os.chdir(tmpdir) + if self.new_dist.upgradeTool != None: + progress = GtkProgress.GtkFetchProgress(self.parent, + _("Downloading the upgrade " + "tool"), + _("The upgrade tool will " + "guide you through the " + "upgrade process.")) + fetcher = apt_pkg.GetAcquire(progress) + self.uri = self.new_dist.upgradeTool + af = apt_pkg.GetPkgAcqFile(fetcher,self.uri, descr=_("Upgrade tool")) + if fetcher.Run() != fetcher.ResultContinue: + return False + return True + + def runDistUpgrader(self): + #print "runing: %s" % script + os.execv(script,[]) + + def cleanup(self): + # cleanup + os.chdir("..") + # del tmpdir + for root, dirs, files in os.walk(self.tmpdir, topdown=False): + for name in files: + os.remove(os.path.join(root, name)) + #print "would remove file: %s" % os.path.join(root, name) + for name in dirs: + os.rmdir(os.path.join(root, name)) + #print "would remove dir: %s" % os.path.join(root, name) + os.rmdir(self.tmpdir) + + def run(self): + # see if we have release notes + if not self.showReleaseNotes(): + return + if not self.fetchDistUpgrader(): + print "Fetch failed" + return + if not self.extractDistUpgrader(): + print "extract failed" + return + if not self.verifyDistUprader(): + print "verify failed" + self.cleanup() + return + #if not self.authenticate(distUpgradeTar, distUpgradeSig): + # print "authenticate failed" + # self.cleanup() + # return + self.runDistUpgrader() + + +if __name__ == "__main__": + d = DistUpgradeFetcher(None) + print d.authenticate('/tmp/Release','/tmp/Release.gpg') diff --git a/UpdateManager/MetaRelease.py b/UpdateManager/MetaRelease.py index 0bc8dc05..cd56970f 100644 --- a/UpdateManager/MetaRelease.py +++ b/UpdateManager/MetaRelease.py @@ -42,8 +42,8 @@ class Dist(object): class MetaRelease(gobject.GObject): # some constants - METARELEASE_URI = "http://changelogs.ubuntu.com/meta-release" - #METARELEASE_URI = "http://people.ubuntu.com/~mvo/dist-upgrader/meta-release-test.save" + #METARELEASE_URI = "http://changelogs.ubuntu.com/meta-release" + METARELEASE_URI = "http://people.ubuntu.com/~mvo/dist-upgrader/meta-release-test.save" METARELEASE_FILE = "/var/lib/update-manager/meta-release" __gsignals__ = { diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index 22c7a6a5..9aaad85d 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -1,6 +1,6 @@ # UpdateManager.py # -# Copyright (c) 2004,2005 Canonical +# Copyright (c) 2004-2006 Canonical # 2004 Michiel Sikkes # 2005 Martin Willemoes Hansen # @@ -48,14 +48,12 @@ import time import thread import xml.sax.saxutils -# dist-upgrade tool -import tarfile from gettext import gettext as _ from Common.utils import * from Common.SimpleGladeApp import SimpleGladeApp -from ReleaseNotesViewer import ReleaseNotesViewer +from DistUpgradeFetcher import DistUpgradeFetcher import GtkProgress from MetaRelease import Dist, MetaRelease @@ -629,116 +627,8 @@ class UpdateManager(SimpleGladeApp): def on_button_dist_upgrade_clicked(self, button): print "on_button_dist_upgrade_clicked" - - # see if we have release notes - - # FIXME: care about i18n! (append -$lang or something) - if self.new_dist.releaseNotesURI != None: - uri = self.new_dist.releaseNotesURI - print uri - self.window_main.set_sensitive(False) - self.window_main.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) - while gtk.events_pending(): - gtk.main_iteration() - - # download/display the release notes - # FIXME: add some progress reporting here - res = gtk.RESPONSE_CANCEL - try: - release_notes = urllib2.urlopen(uri) - notes = release_notes.read() - textview_release_notes = ReleaseNotesViewer(notes) - textview_release_notes.show() - self.scrolled_notes.add(textview_release_notes) - self.dialog_release_notes.set_transient_for(self.window_main) - res = self.dialog_release_notes.run() - self.dialog_release_notes.hide() - except urllib2.HTTPError: - primary = "%s" % \ - _("Could not find the release notes") - secondary = _("The server may be overloaded. ") - dialog = gtk.MessageDialog(self.window_main,gtk.DIALOG_MODAL, - gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE,"") - dialog.set_title("") - dialog.set_markup(primary); - dialog.format_secondary_text(secondary); - dialog.run() - dialog.destroy() - except IOError: - primary = "%s" % \ - _("Could not download the release notes") - secondary = _("Please check your internet connection.") - dialog = gtk.MessageDialog(self.window_main,gtk.DIALOG_MODAL, - gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE,"") - dialog.set_title("") - dialog.set_markup(primary); - dialog.format_secondary_text(secondary); - dialog.run() - dialog.destroy() - self.window_main.set_sensitive(True) - self.window_main.window.set_cursor(None) - # user clicked cancel - if res == gtk.RESPONSE_CANCEL: - return - - # now download the tarball with the upgrade script - tmpdir = tempfile.mkdtemp() - os.chdir(tmpdir) - if self.new_dist.upgradeTool != None: - progress = GtkProgress.GtkFetchProgress(self, - _("Downloading the upgrade " - "tool"), - _("The upgrade tool will " - "guide you through the " - "upgrade process.")) - fetcher = apt_pkg.GetAcquire(progress) - uri = self.new_dist.upgradeTool - #print "Downloading %s to %s" % (uri, tmpdir) - af = apt_pkg.GetPkgAcqFile(fetcher,uri, - descr=_("Upgrade tool")) - fetcher.Run() - #print "Done downloading" - - # extract the tarbal - print "extracting" - tar = tarfile.open(tmpdir+"/"+os.path.basename(uri),"r") - for tarinfo in tar: - tar.extract(tarinfo) - tar.close() - - # FIXME: check a internal dependency file to make sure - # that the script will run correctly - - # see if we have a script file that we can run - script = "%s/%s" % (tmpdir, self.new_dist.name) - if not os.path.exists(script): - # no script file found in extracted tarbal - primary = "%s" % \ - _("Could not run the upgrade tool") - secondary = _("This is most likely a bug in the upgrade tool. " - "Please report it as a bug") - dialog = gtk.MessageDialog(self.window_main,gtk.DIALOG_MODAL, - gtk.MESSAGE_ERROR,gtk.BUTTONS_CLOSE,"") - dialog.set_title("") - dialog.set_markup(primary); - dialog.format_secondary_text(secondary); - dialog.run() - dialog.destroy() - else: - #print "runing: %s" % script - os.execv(script,[]) - - # cleanup - os.chdir("..") - # del tmpdir - for root, dirs, files in os.walk(tmpdir, topdown=False): - for name in files: - os.remove(os.path.join(root, name)) - #print "would remove file: %s" % os.path.join(root, name) - for name in dirs: - os.rmdir(os.path.join(root, name)) - #print "would remove dir: %s" % os.path.join(root, name) - os.rmdir(tmpdir) + fetcher = DistUpgradeFetcher(self, self.new_dist) + fetcher.run() def new_dist_available(self, meta_release, upgradable_to): print "new_dist_available: %s" % upgradable_to.name -- cgit v1.2.3 From 9f1f9070d249457871a92d52eb3817c73e6fe0ac Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Sat, 25 Feb 2006 20:10:28 +0100 Subject: * Use nice grammer #32864 * Show a warning about the time an upgrade can take * Show a warning that the upgrade cannot be canceled * Show a warning to close all apps and documents before upgrading * Only show the download size if there are upgrades --- DistUpgrade/DistUpgrade.glade | 3 ++- DistUpgrade/DistUpgradeViewGtk.py | 35 ++++++++++++++++++++++++----------- UpdateManager/UpdateManager.py | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) (limited to 'UpdateManager') diff --git a/DistUpgrade/DistUpgrade.glade b/DistUpgrade/DistUpgrade.glade index c28b20ad..e50476e2 100644 --- a/DistUpgrade/DistUpgrade.glade +++ b/DistUpgrade/DistUpgrade.glade @@ -586,12 +586,13 @@ True + True False True GTK_JUSTIFY_LEFT True - False + True 0 0.5 0 diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 3697a49e..7298b31e 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -126,6 +126,7 @@ class GtkInstallProgressAdapter(InstallProgress): reaper.connect("child-exited", self.child_exited) # some options for dpkg to make it die less easily apt_pkg.Config.Set("DPkg::Options::","--force-overwrite") + def startUpdate(self): self.finished = False # FIXME: add support for the timeout @@ -161,15 +162,19 @@ class GtkInstallProgressAdapter(InstallProgress): def fork(self): pid = self.term.forkpty(envv=self.env) return pid + def child_exited(self, term, pid, status): self.apt_status = os.WEXITSTATUS(status) self.finished = True + def waitChild(self): while not self.finished: self.updateInterface() return self.apt_status + def finishUpdate(self): self.label_status.set_text("") + def updateInterface(self): InstallProgress.updateInterface(self) self.progress.set_fraction(self.percent/100.0) @@ -181,9 +186,6 @@ class GtkInstallProgressAdapter(InstallProgress): class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp): " gtk frontend of the distUpgrade tool " - - - def __init__(self): # FIXME: i18n must be somewhere relative do this dir bindtextdomain("update-manager",os.path.join(os.getcwd(),"mo")) @@ -237,6 +239,7 @@ class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp): self._terminal_lines = [] self._terminal_log = open("/var/log/dist-upgrade-term.log","w") return self._term + def _term_content_changed(self, term): " called when the *visible* part of the terminal changes " @@ -277,7 +280,6 @@ class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp): attrlist.insert(attr) label.set_property("attributes",attrlist) - def error(self, summary, msg, extended_msg=None): self.dialog_error.set_transient_for(self.window_main) #self.expander_terminal.set_expanded(True) @@ -309,30 +311,41 @@ class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp): pkgs_remove, "%s packages are going to be removed." %\ pkgs_remove, pkgs_remove) - msg +=" " + msg += " " if pkgs_inst > 0: msg += gettext.ngettext("%s new package is going to be "\ "installed." % pkgs_inst, "%s new packages are going to be "\ "installed." % pkgs_inst, pkgs_inst) - msg +=" " + msg += " " if pkgs_upgrade > 0: msg += gettext.ngettext("%s package is going to be upgraded." %\ pkgs_upgrade, "%s packages are going to be upgraded." %\ pkgs_upgrade, pkgs_upgrade) msg +=" " - if msg == "": + + if downloadSize > 0: + msg += _("You have to download a total of %s." %\ + apt_pkg.SizeToStr(downloadSize)) + + if (pkgs_upgrade + pkgs_inst + pkgs_remove) > 100: + msg += "\n\n%s" % _("The upgrade can take several hours and "\ + "cannot be canceled at any time later.") + + msg += "\n\n%s" % _("To prevent data loss close all open "\ + "applications and documents.") + + # Show an error if no actions are planned + if (pkgs_upgrade + pkgs_inst + pkgs_remove) < 1: # FIXME: this should go into DistUpgradeController summary = _("Could not find any upgrades") msg = _("Your system has already been upgraded.") self.error(summary, msg) return False - else: - msg += _("You have to download a total of %s." %\ - apt_pkg.SizeToStr(downloadSize)) + self.label_summary.set_markup("%s" % summary) - self.label_changes.set_text(msg) + self.label_changes.set_markup(msg) # fill in the details self.details_list.clear() for rm in self.toRemove: diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index e6394223..e6437d3b 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -179,7 +179,7 @@ class UpdateList: #print "WARNING, keeping packages" msg = ("%s\n\n%s" % \ (_("Cannot install all available updates"), - _("Some updates require to remove further software. " + _("Some updates require the removal of further software. " "Use the function \"Smart Upgrade\" of the package manager " "\"Synaptic\" or run \"sudo apt-get dist-upgrade\" in a " "terminal to update your system completely."))) -- cgit v1.2.3 From 9184e9d648fb8ff3f8a437817cb67d5cf17e2010 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Sun, 26 Feb 2006 09:26:33 +0100 Subject: * Use the dist name from lsbrelease in the add channel dialog --- SoftwareProperties/aptsources.py | 4 +++- SoftwareProperties/dialog_add.py | 6 ++++++ UpdateManager/Common/DistInfo.py | 5 ++++- data/SoftwarePropertiesDialogs.glade | 6 +++--- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'UpdateManager') diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py index 397ebb38..532600fd 100644 --- a/SoftwareProperties/aptsources.py +++ b/SoftwareProperties/aptsources.py @@ -450,7 +450,7 @@ class SourcesList: # templates for the add dialog class SourceEntryTemplate(SourceEntry): - def __init__(self,a_type,uri,dist,description,comps): + def __init__(self, a_type, uri, dist, description, comps): self.comps = [] self.comps_descriptions = [] self.type = a_type @@ -472,6 +472,8 @@ class SourceEntryTemplates: dinfo = DistInfo (base_dir=datadir+"channels/") + self.dist = dinfo.dist + for suite in dinfo.suites: comps = [] for comp in suite.components: diff --git a/SoftwareProperties/dialog_add.py b/SoftwareProperties/dialog_add.py index effd9f24..8ccd2080 100644 --- a/SoftwareProperties/dialog_add.py +++ b/SoftwareProperties/dialog_add.py @@ -26,6 +26,7 @@ import os import gobject import gtk import gtk.glade +from gettext import gettext as _ import aptsources @@ -52,6 +53,11 @@ class dialog_add: self.combo.pack_start(cell, True) self.combo.add_attribute(cell, 'text', 0) self.fill_combo(self.combo) + self.label_dist = self.gladexml.get_widget("label_dist") + if self.templatelist.dist != "": + # TRANSLATORS: %s is the distribution name, eg. Ubuntu or Debian + self.label_dist.set_markup("%s" % \ + _("%s channels" % self.templatelist.dist)) # Setup the custom channel widgets self.entry = self.gladexml.get_widget("entry_source_line") diff --git a/UpdateManager/Common/DistInfo.py b/UpdateManager/Common/DistInfo.py index df244a51..102b981c 100644 --- a/UpdateManager/Common/DistInfo.py +++ b/UpdateManager/Common/DistInfo.py @@ -22,6 +22,7 @@ import os import gettext +from os import getenv import ConfigParser _ = gettext.gettext @@ -51,6 +52,8 @@ class DistInfo: pipe.close() del pipe + self.dist = dist + dist_fname = "%s/%s.info" % (base_dir, dist) dist_file = open (dist_fname) if not dist_file: @@ -100,7 +103,7 @@ class DistInfo: if __name__ == "__main__": - d = DistInfo ("Debian", "../distribution-data") + d = DistInfo ("Debian", "../../channels") print d.changelogs_uri for suite in d.suites: print suite.name diff --git a/data/SoftwarePropertiesDialogs.glade b/data/SoftwarePropertiesDialogs.glade index 3e4be82f..175d152b 100644 --- a/data/SoftwarePropertiesDialogs.glade +++ b/data/SoftwarePropertiesDialogs.glade @@ -92,9 +92,9 @@ - + True - <b>Official Ubuntu Channel</b> + False True GTK_JUSTIFY_LEFT @@ -247,7 +247,7 @@ True - <b>Custom Channel</b> + <b>Custom channel</b> False True GTK_JUSTIFY_LEFT -- cgit v1.2.3 From 4a1c03022c92d3c477c333c1592c888cf216b19d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 27 Feb 2006 18:37:25 +0100 Subject: * UpdateManager/MetaRelease.py, DistUpgradeFetcher: - make the authentication work reliable * DistUpgrade/DistUpgradeViewGtk.py: - exit on fatal uncaught exceptions * SoftwareProperties/SoftwareProperties.py: - fix a indent error when adding gpg keys --- DistUpgrade/DistUpgradeViewGtk.py | 1 + SoftwareProperties/SoftwareProperties.py | 2 +- UpdateManager/DistUpgradeFetcher.py | 48 +++++++++++++++++++++++--------- UpdateManager/MetaRelease.py | 8 ++++-- 4 files changed, 43 insertions(+), 16 deletions(-) (limited to 'UpdateManager') diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 7298b31e..2f7e3fed 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -230,6 +230,7 @@ class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp): "files ~/dist-upgrade.log and ~/dist-upgrade-apt.log " "in your report. The upgrade aborts now. "), "\n".join(lines)) + sys.exit(1) def create_terminal(self, arg1,arg2,arg3,arg4): " helper to create a vte terminal " diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py index 1c6963a0..0e892182 100644 --- a/SoftwareProperties/SoftwareProperties.py +++ b/SoftwareProperties/SoftwareProperties.py @@ -486,7 +486,7 @@ class SoftwareProperties(SimpleGladeApp): _("Error importing selected file"), _("The selected file may not be a GPG key file " \ "or it might be corrupt.")) - self.reload_keyslist() + self.reload_keyslist() def remove_key_clicked(self, widget): selection = self.treeview2.get_selection() diff --git a/UpdateManager/DistUpgradeFetcher.py b/UpdateManager/DistUpgradeFetcher.py index 7af32865..676f064b 100644 --- a/UpdateManager/DistUpgradeFetcher.py +++ b/UpdateManager/DistUpgradeFetcher.py @@ -91,7 +91,19 @@ class DistUpgradeFetcher(object): return False return True - def authenticate(self, file, signature, keyring='/etc/apt/trusted.gpg'): + def authenticate(self): + if self.new_dist.upgradeToolSig: + f = self.tmpdir+"/"+os.path.basename(self.new_dist.upgradeTool) + sig = self.tmpdir+"/"+os.path.basename(self.new_dist.upgradeToolSig) + print "authenticate '%s' against '%s' " % (f,sig) + if not self.gpgauthenticate(f, sig): + return False + + # we may return False here by default if we want to make a sig + # mandatory + return True + + def gpgauthenticate(self, file, signature, keyring='/etc/apt/trusted.gpg'): """ authenticated a file against a given signature, if no keyring is given use the apt default keyring """ @@ -101,6 +113,7 @@ class DistUpgradeFetcher(object): proc = gpg.run(['--verify', signature, file], create_fhs=['status','logger','stderr']) gpgres = proc.handles['status'].read() + proc.wait() if "VALIDSIG" in gpgres: return True return False @@ -140,23 +153,32 @@ class DistUpgradeFetcher(object): # now download the tarball with the upgrade script self.tmpdir = tmpdir = tempfile.mkdtemp() os.chdir(tmpdir) + + # turn debugging on here (if required) + #apt_pkg.Config.Set("Debug::Acquire::http","1") + + progress = GtkProgress.GtkFetchProgress(self.parent, + _("Downloading the upgrade " + "tool"), + _("The upgrade tool will " + "guide you through the " + "upgrade process.")) + fetcher = apt_pkg.GetAcquire(progress) + + if self.new_dist.upgradeToolSig != None: + uri = self.new_dist.upgradeToolSig + af = apt_pkg.GetPkgAcqFile(fetcher,uri, descr=_("Upgrade tool signature")) if self.new_dist.upgradeTool != None: - progress = GtkProgress.GtkFetchProgress(self.parent, - _("Downloading the upgrade " - "tool"), - _("The upgrade tool will " - "guide you through the " - "upgrade process.")) - fetcher = apt_pkg.GetAcquire(progress) self.uri = self.new_dist.upgradeTool af = apt_pkg.GetPkgAcqFile(fetcher,self.uri, descr=_("Upgrade tool")) if fetcher.Run() != fetcher.ResultContinue: return False return True + return False def runDistUpgrader(self): #print "runing: %s" % script - os.execv(script,[]) + os.execv(self.script,[]) def cleanup(self): # cleanup @@ -185,10 +207,10 @@ class DistUpgradeFetcher(object): print "verify failed" self.cleanup() return - #if not self.authenticate(distUpgradeTar, distUpgradeSig): - # print "authenticate failed" - # self.cleanup() - # return + if not self.authenticate(): + print "authenticate failed" + self.cleanup() + return self.runDistUpgrader() diff --git a/UpdateManager/MetaRelease.py b/UpdateManager/MetaRelease.py index cd56970f..fde705bb 100644 --- a/UpdateManager/MetaRelease.py +++ b/UpdateManager/MetaRelease.py @@ -38,12 +38,13 @@ class Dist(object): self.supported = supported self.releaseNotesURI = None self.upgradeTool = None + self.upgradeToolSig = None class MetaRelease(gobject.GObject): # some constants - #METARELEASE_URI = "http://changelogs.ubuntu.com/meta-release" - METARELEASE_URI = "http://people.ubuntu.com/~mvo/dist-upgrader/meta-release-test.save" + METARELEASE_URI = "http://changelogs.ubuntu.com/meta-release" + #METARELEASE_URI = "http://people.ubuntu.com/~mvo/dist-upgrader/meta-release-test2" METARELEASE_FILE = "/var/lib/update-manager/meta-release" __gsignals__ = { @@ -73,6 +74,7 @@ class MetaRelease(gobject.GObject): if res != 0: sys.stderr.write("lsb_release returned exitcode: %i\n" % res) dist = string.strip(p.stdout.readline()) + #dist = "breezy" return dist def check(self): @@ -107,6 +109,8 @@ class MetaRelease(gobject.GObject): dist.releaseNotesURI = index_tag.Section["ReleaseNotes"] if index_tag.Section.has_key("UpgradeTool"): dist.upgradeTool = index_tag.Section["UpgradeTool"] + if index_tag.Section.has_key("UpgradeToolSignature"): + dist.upgradeToolSig = index_tag.Section["UpgradeToolSignature"] dists.append(dist) if name == current_dist_name: current_dist = dist -- cgit v1.2.3