Merge lp:~mterry/ubuntu-release-upgrader/pkexec into lp:ubuntu-release-upgrader
- pkexec
- Merge into trunk
| Status: | Merged |
|---|---|
| Merged at revision: | 2519 |
| Proposed branch: | lp:~mterry/ubuntu-release-upgrader/pkexec |
| Merge into: | lp:ubuntu-release-upgrader |
| Diff against target: |
622 lines (+428/-19) 13 files modified
DistUpgrade/DistUpgradeController.py (+0/-3) DistUpgrade/DistUpgradeFetcher.py (+7/-7) DistUpgrade/DistUpgradeViewGtk3.py (+0/-2) DistUpgrade/GtkProgress.py (+97/-0) data/com.ubuntu.release-upgrader.policy.in (+37/-0) data/gtkbuilder/AcquireProgress.ui (+161/-0) debian/ubuntu-release-upgrader-core.install (+2/-0) do-partial-upgrade (+92/-0) do-release-upgrade (+24/-5) po/POTFILES.in (+4/-0) pre-build.sh (+1/-1) setup.cfg (+1/-0) setup.py (+2/-1) |
| To merge this branch: | bzr merge lp:~mterry/ubuntu-release-upgrader/pkexec |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Serge Hallyn | Approve on 2012-06-28 | ||
| Ubuntu Core Development Team | 2012-06-28 | Pending | |
|
Review via email:
|
|||
Commit Message
Description of the Change
This branch makes a few changes to make it easier to run pkexec when doing a release upgrade. It also separates out the code between update-manager and u-r-u slightly better.
This moves some code form u-m to here (that really should have been here, there will be a follow-on branch to drop that stuff from u-m).
It adds a policykit file to provide nice translated user strings when running pkexec on a u-r-u file.
It adds better support for running do-release-upgrade with a GTK frontend.
It adds a new command do-partial-upgrade, which does what update-manager does when it detected a partial upgrade is necessary. I've broken it out here into a new command so that it can more easily be recognized by pkexec and so because the code it used was all from DistUpgrade anyway.
Preview Diff
| 1 | === modified file 'DistUpgrade/DistUpgradeController.py' |
| 2 | --- DistUpgrade/DistUpgradeController.py 2012-06-28 16:12:09 +0000 |
| 3 | +++ DistUpgrade/DistUpgradeController.py 2012-06-28 19:27:18 +0000 |
| 4 | @@ -101,9 +101,6 @@ |
| 5 | if datadir == None: |
| 6 | datadir = os.getcwd() |
| 7 | localedir = os.path.join(datadir,"mo") |
| 8 | - else: |
| 9 | - # FIXME: don't overwrite this, once we move caller from u-m to us |
| 10 | - datadir = "/usr/share/ubuntu-release-upgrader/" |
| 11 | self.datadir = datadir |
| 12 | self.options = options |
| 13 | |
| 14 | |
| 15 | === modified file 'DistUpgrade/DistUpgradeFetcher.py' |
| 16 | --- DistUpgrade/DistUpgradeFetcher.py 2012-06-28 16:12:09 +0000 |
| 17 | +++ DistUpgrade/DistUpgradeFetcher.py 2012-06-28 19:27:18 +0000 |
| 18 | @@ -42,8 +42,6 @@ |
| 19 | |
| 20 | def __init__(self, new_dist, progress, parent, datadir): |
| 21 | DistUpgradeFetcherCore.__init__(self, new_dist, progress) |
| 22 | - # TODO don't override this once we move callers from u-m to u-r-u |
| 23 | - datadir = "/usr/share/ubuntu-release-upgrader/" |
| 24 | uifile = datadir + "gtkbuilder/ReleaseNotes.ui" |
| 25 | self.widgets = SimpleGtkbuilderApp(uifile, "ubuntu-release-upgrader") |
| 26 | self.window_main = parent |
| 27 | @@ -98,9 +96,10 @@ |
| 28 | # FIXME: care about i18n! (append -$lang or something) |
| 29 | if self.new_dist.releaseNotesURI is not None: |
| 30 | uri = self._expandUri(self.new_dist.releaseNotesURI) |
| 31 | - self.window_main.set_sensitive(False) |
| 32 | - self.window_main.get_window().set_cursor( |
| 33 | - Gdk.Cursor.new(Gdk.CursorType.WATCH)) |
| 34 | + if self.window_main: |
| 35 | + self.window_main.set_sensitive(False) |
| 36 | + self.window_main.get_window().set_cursor( |
| 37 | + Gdk.Cursor.new(Gdk.CursorType.WATCH)) |
| 38 | while Gtk.events_pending(): |
| 39 | Gtk.main_iteration() |
| 40 | |
| 41 | @@ -146,8 +145,9 @@ |
| 42 | dialog.run() |
| 43 | dialog.destroy() |
| 44 | socket.setdefaulttimeout(timeout) |
| 45 | - self.window_main.set_sensitive(True) |
| 46 | - self.window_main.get_window().set_cursor(None) |
| 47 | + if self.window_main: |
| 48 | + self.window_main.set_sensitive(True) |
| 49 | + self.window_main.get_window().set_cursor(None) |
| 50 | # user clicked cancel |
| 51 | if res == Gtk.ResponseType.OK: |
| 52 | return True |
| 53 | |
| 54 | === modified file 'DistUpgrade/DistUpgradeViewGtk3.py' |
| 55 | --- DistUpgrade/DistUpgradeViewGtk3.py 2012-06-28 16:12:09 +0000 |
| 56 | +++ DistUpgrade/DistUpgradeViewGtk3.py 2012-06-28 19:27:18 +0000 |
| 57 | @@ -400,8 +400,6 @@ |
| 58 | localedir=os.path.join(os.getcwd(),"mo") |
| 59 | gladedir=os.getcwd() |
| 60 | else: |
| 61 | - # FIXME: don't overwrite this, once we move caller from u-m to us |
| 62 | - datadir = "/usr/share/ubuntu-release-upgrader/" |
| 63 | localedir="/usr/share/locale/" |
| 64 | gladedir=os.path.join(datadir, "gtkbuilder") |
| 65 | |
| 66 | |
| 67 | === added file 'DistUpgrade/GtkProgress.py' |
| 68 | --- DistUpgrade/GtkProgress.py 1970-01-01 00:00:00 +0000 |
| 69 | +++ DistUpgrade/GtkProgress.py 2012-06-28 19:27:18 +0000 |
| 70 | @@ -0,0 +1,97 @@ |
| 71 | +# GtkProgress.py |
| 72 | +# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*- |
| 73 | +# |
| 74 | +# Copyright (c) 2004,2005 Canonical |
| 75 | +# |
| 76 | +# Author: Michael Vogt <michael.vogt@ubuntu.com> |
| 77 | +# |
| 78 | +# This program is free software; you can redistribute it and/or |
| 79 | +# modify it under the terms of the GNU General Public License as |
| 80 | +# published by the Free Software Foundation; either version 2 of the |
| 81 | +# License, or (at your option) any later version. |
| 82 | +# |
| 83 | +# This program is distributed in the hope that it will be useful, |
| 84 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 85 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 86 | +# GNU General Public License for more details. |
| 87 | +# |
| 88 | +# You should have received a copy of the GNU General Public License |
| 89 | +# along with this program; if not, write to the Free Software |
| 90 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 91 | +# USA |
| 92 | + |
| 93 | +from __future__ import absolute_import, print_function |
| 94 | + |
| 95 | +from gi.repository import Gtk, Gdk |
| 96 | +import apt |
| 97 | +from gettext import gettext as _ |
| 98 | +from UpdateManager.Core.utils import humanize_size |
| 99 | +from .SimpleGtk3builderApp import SimpleGtkbuilderApp |
| 100 | + |
| 101 | + |
| 102 | +class GtkAcquireProgress(apt.progress.base.AcquireProgress): |
| 103 | + def __init__(self, parent, datadir, summary="", descr=""): |
| 104 | + uifile = datadir + "gtkbuilder/AcquireProgress.ui" |
| 105 | + self.widgets = SimpleGtkbuilderApp(uifile, "ubuntu-release-upgrader") |
| 106 | + # if this is set to false the download will cancel |
| 107 | + self._continue = True |
| 108 | + # init vars here |
| 109 | + # FIXME: find a more elegant way, this sucks |
| 110 | + self.summary = self.widgets.label_fetch_summary |
| 111 | + self.status = self.widgets.label_fetch_status |
| 112 | + # we need to connect the signal manual here, it won't work |
| 113 | + # from the main window auto-connect |
| 114 | + self.widgets.button_fetch_cancel.connect( |
| 115 | + "clicked", self.on_button_fetch_cancel_clicked) |
| 116 | + self.progress = self.widgets.progressbar_fetch |
| 117 | + self.window_fetch = self.widgets.window_fetch |
| 118 | + self.window_fetch.set_transient_for(parent) |
| 119 | + self.window_fetch.realize() |
| 120 | + self.window_fetch.get_window().set_functions(Gdk.WMFunction.MOVE) |
| 121 | + # set summary |
| 122 | + if summary != "": |
| 123 | + self.summary.set_markup("<big><b>%s</b></big> \n\n%s" % |
| 124 | + (summary, descr)) |
| 125 | + |
| 126 | + def start(self): |
| 127 | + self.progress.set_fraction(0) |
| 128 | + self.window_fetch.show() |
| 129 | + |
| 130 | + def stop(self): |
| 131 | + self.window_fetch.hide() |
| 132 | + |
| 133 | + def on_button_fetch_cancel_clicked(self, widget): |
| 134 | + self._continue = False |
| 135 | + |
| 136 | + def pulse(self, owner): |
| 137 | + apt.progress.base.AcquireProgress.pulse(self, owner) |
| 138 | + current_item = self.current_items + 1 |
| 139 | + if current_item > self.total_items: |
| 140 | + current_item = self.total_items |
| 141 | + if self.current_cps > 0: |
| 142 | + status_text = (_("Downloading file %(current)li of %(total)li " |
| 143 | + "with %(speed)s/s") % { |
| 144 | + "current": current_item, |
| 145 | + "total": self.total_items, |
| 146 | + "speed": humanize_size(self.current_cps)}) |
| 147 | + else: |
| 148 | + status_text = (_("Downloading file %(current)li of %(total)li") % |
| 149 | + {"current": current_item, |
| 150 | + "total": self.total_items}) |
| 151 | + self.progress.set_fraction( |
| 152 | + (self.current_bytes + self.current_items) / |
| 153 | + float(self.total_bytes + self.total_items)) |
| 154 | + self.status.set_markup("<i>%s</i>" % status_text) |
| 155 | + # TRANSLATORS: show the remaining time in a progress bar: |
| 156 | + #if self.current_cps > 0: |
| 157 | + # eta = ((self.total_bytes + self.current_bytes) / |
| 158 | + # float(self.current_cps)) |
| 159 | + #else: |
| 160 | + # eta = 0.0 |
| 161 | + #self.progress.set_text(_("About %s left" % (apt_pkg.TimeToStr(eta)))) |
| 162 | + # FIXME: show remaining time |
| 163 | + self.progress.set_text("") |
| 164 | + |
| 165 | + while Gtk.events_pending(): |
| 166 | + Gtk.main_iteration() |
| 167 | + return self._continue |
| 168 | |
| 169 | === renamed file 'DistUpgrade/DistUpgrade.cfg' => 'data/DistUpgrade.cfg' |
| 170 | === renamed file 'DistUpgrade/DistUpgrade.cfg.dapper' => 'data/DistUpgrade.cfg.dapper' |
| 171 | === renamed file 'DistUpgrade/DistUpgrade.cfg.hardy' => 'data/DistUpgrade.cfg.hardy' |
| 172 | === renamed file 'DistUpgrade/DistUpgrade.cfg.lucid' => 'data/DistUpgrade.cfg.lucid' |
| 173 | === renamed file 'DistUpgrade/additional_pkgs.cfg' => 'data/additional_pkgs.cfg' |
| 174 | === added file 'data/com.ubuntu.release-upgrader.policy.in' |
| 175 | --- data/com.ubuntu.release-upgrader.policy.in 1970-01-01 00:00:00 +0000 |
| 176 | +++ data/com.ubuntu.release-upgrader.policy.in 2012-06-28 19:27:18 +0000 |
| 177 | @@ -0,0 +1,37 @@ |
| 178 | +<?xml version="1.0" encoding="UTF-8"?> |
| 179 | +<!DOCTYPE policyconfig PUBLIC |
| 180 | + "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" |
| 181 | + "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd"> |
| 182 | + |
| 183 | +<policyconfig> |
| 184 | + <vendor>Ubuntu</vendor> |
| 185 | + <vendor_url>http://www.ubuntu.com/</vendor_url> |
| 186 | + <icon_name>system-software-update</icon_name> |
| 187 | + |
| 188 | + <action id="com.ubuntu.release-upgrader.release-upgrade"> |
| 189 | + <_description>Perform a release upgrade</_description> |
| 190 | + <_message>Authentication is required to perform a release upgrade</_message> |
| 191 | + <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/do-release-upgrade</annotate> |
| 192 | + <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> |
| 193 | + |
| 194 | + <defaults> |
| 195 | + <allow_any>no</allow_any> |
| 196 | + <allow_inactive>no</allow_inactive> |
| 197 | + <allow_active>auth_admin</allow_active> |
| 198 | + </defaults> |
| 199 | + </action> |
| 200 | + |
| 201 | + <action id="com.ubuntu.release-upgrader.partial-upgrade"> |
| 202 | + <_description>Perform a partial upgrade</_description> |
| 203 | + <_message>Authentication is required to perform a partial upgrade</_message> |
| 204 | + <annotate key="org.freedesktop.policykit.exec.path">/usr/lib/ubuntu-release-upgrader/do-partial-upgrade</annotate> |
| 205 | + <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> |
| 206 | + |
| 207 | + <defaults> |
| 208 | + <allow_any>no</allow_any> |
| 209 | + <allow_inactive>no</allow_inactive> |
| 210 | + <allow_active>auth_admin</allow_active> |
| 211 | + </defaults> |
| 212 | + </action> |
| 213 | + |
| 214 | +</policyconfig> |
| 215 | |
| 216 | === renamed symlink 'DistUpgrade/demoted.cfg' => 'data/demoted.cfg' |
| 217 | === added file 'data/gtkbuilder/AcquireProgress.ui' |
| 218 | --- data/gtkbuilder/AcquireProgress.ui 1970-01-01 00:00:00 +0000 |
| 219 | +++ data/gtkbuilder/AcquireProgress.ui 2012-06-28 19:27:18 +0000 |
| 220 | @@ -0,0 +1,161 @@ |
| 221 | +<?xml version="1.0" encoding="UTF-8"?> |
| 222 | +<interface> |
| 223 | + <!-- interface-requires gtk+ 3.0 --> |
| 224 | + <object class="GtkWindow" id="window_fetch"> |
| 225 | + <property name="can_focus">False</property> |
| 226 | + <property name="border_width">6</property> |
| 227 | + <property name="modal">True</property> |
| 228 | + <property name="window_position">center-on-parent</property> |
| 229 | + <property name="default_width">400</property> |
| 230 | + <property name="type_hint">dialog</property> |
| 231 | + <property name="skip_taskbar_hint">True</property> |
| 232 | + <property name="skip_pager_hint">True</property> |
| 233 | + <child> |
| 234 | + <object class="GtkVBox" id="pane_fetch"> |
| 235 | + <property name="visible">True</property> |
| 236 | + <property name="can_focus">False</property> |
| 237 | + <property name="spacing">6</property> |
| 238 | + <child> |
| 239 | + <object class="GtkVBox" id="vbox7"> |
| 240 | + <property name="visible">True</property> |
| 241 | + <property name="can_focus">False</property> |
| 242 | + <property name="border_width">6</property> |
| 243 | + <property name="spacing">12</property> |
| 244 | + <child> |
| 245 | + <object class="GtkLabel" id="label_fetch_summary"> |
| 246 | + <property name="visible">True</property> |
| 247 | + <property name="can_focus">False</property> |
| 248 | + <property name="xalign">0</property> |
| 249 | + <property name="use_markup">True</property> |
| 250 | + <property name="wrap">True</property> |
| 251 | + </object> |
| 252 | + <packing> |
| 253 | + <property name="expand">False</property> |
| 254 | + <property name="fill">False</property> |
| 255 | + <property name="position">0</property> |
| 256 | + </packing> |
| 257 | + </child> |
| 258 | + <child> |
| 259 | + <object class="GtkVBox" id="vbox8"> |
| 260 | + <property name="visible">True</property> |
| 261 | + <property name="can_focus">False</property> |
| 262 | + <property name="spacing">6</property> |
| 263 | + <child> |
| 264 | + <object class="GtkProgressBar" id="progressbar_fetch"> |
| 265 | + <property name="visible">True</property> |
| 266 | + <property name="can_focus">False</property> |
| 267 | + <property name="pulse_step">0.10000000149</property> |
| 268 | + </object> |
| 269 | + <packing> |
| 270 | + <property name="expand">True</property> |
| 271 | + <property name="fill">False</property> |
| 272 | + <property name="position">0</property> |
| 273 | + </packing> |
| 274 | + </child> |
| 275 | + <child> |
| 276 | + <object class="GtkLabel" id="label_fetch_status"> |
| 277 | + <property name="visible">True</property> |
| 278 | + <property name="can_focus">False</property> |
| 279 | + <property name="xalign">0</property> |
| 280 | + </object> |
| 281 | + <packing> |
| 282 | + <property name="expand">False</property> |
| 283 | + <property name="fill">False</property> |
| 284 | + <property name="position">1</property> |
| 285 | + </packing> |
| 286 | + </child> |
| 287 | + </object> |
| 288 | + <packing> |
| 289 | + <property name="expand">False</property> |
| 290 | + <property name="fill">False</property> |
| 291 | + <property name="position">1</property> |
| 292 | + </packing> |
| 293 | + </child> |
| 294 | + <child> |
| 295 | + <object class="GtkExpander" id="expander1"> |
| 296 | + <property name="can_focus">True</property> |
| 297 | + <property name="spacing">6</property> |
| 298 | + <child> |
| 299 | + <object class="GtkVBox" id="vbox9"> |
| 300 | + <property name="visible">True</property> |
| 301 | + <property name="can_focus">False</property> |
| 302 | + <property name="spacing">6</property> |
| 303 | + <child> |
| 304 | + <object class="GtkScrolledWindow" id="scrolledwindow6"> |
| 305 | + <property name="height_request">200</property> |
| 306 | + <property name="visible">True</property> |
| 307 | + <property name="can_focus">True</property> |
| 308 | + <property name="shadow_type">in</property> |
| 309 | + <child> |
| 310 | + <object class="GtkTreeView" id="treeview1"> |
| 311 | + <property name="visible">True</property> |
| 312 | + <property name="can_focus">True</property> |
| 313 | + <property name="enable_search">False</property> |
| 314 | + <child internal-child="selection"> |
| 315 | + <object class="GtkTreeSelection" id="treeview-selection"/> |
| 316 | + </child> |
| 317 | + </object> |
| 318 | + </child> |
| 319 | + </object> |
| 320 | + <packing> |
| 321 | + <property name="expand">True</property> |
| 322 | + <property name="fill">True</property> |
| 323 | + <property name="position">0</property> |
| 324 | + </packing> |
| 325 | + </child> |
| 326 | + </object> |
| 327 | + </child> |
| 328 | + <child type="label"> |
| 329 | + <object class="GtkLabel" id="label19"> |
| 330 | + <property name="visible">True</property> |
| 331 | + <property name="can_focus">False</property> |
| 332 | + <property name="label" translatable="yes">Show progress of individual files</property> |
| 333 | + </object> |
| 334 | + </child> |
| 335 | + </object> |
| 336 | + <packing> |
| 337 | + <property name="expand">True</property> |
| 338 | + <property name="fill">True</property> |
| 339 | + <property name="position">2</property> |
| 340 | + </packing> |
| 341 | + </child> |
| 342 | + </object> |
| 343 | + <packing> |
| 344 | + <property name="expand">True</property> |
| 345 | + <property name="fill">True</property> |
| 346 | + <property name="position">0</property> |
| 347 | + </packing> |
| 348 | + </child> |
| 349 | + <child> |
| 350 | + <object class="GtkHButtonBox" id="hbuttonbox7"> |
| 351 | + <property name="visible">True</property> |
| 352 | + <property name="can_focus">False</property> |
| 353 | + <property name="layout_style">end</property> |
| 354 | + <child> |
| 355 | + <object class="GtkButton" id="button_fetch_cancel"> |
| 356 | + <property name="label">gtk-cancel</property> |
| 357 | + <property name="use_action_appearance">False</property> |
| 358 | + <property name="visible">True</property> |
| 359 | + <property name="can_focus">True</property> |
| 360 | + <property name="receives_default">True</property> |
| 361 | + <property name="border_width">5</property> |
| 362 | + <property name="use_action_appearance">False</property> |
| 363 | + <property name="use_stock">True</property> |
| 364 | + </object> |
| 365 | + <packing> |
| 366 | + <property name="expand">False</property> |
| 367 | + <property name="fill">False</property> |
| 368 | + <property name="position">0</property> |
| 369 | + </packing> |
| 370 | + </child> |
| 371 | + </object> |
| 372 | + <packing> |
| 373 | + <property name="expand">False</property> |
| 374 | + <property name="fill">True</property> |
| 375 | + <property name="position">1</property> |
| 376 | + </packing> |
| 377 | + </child> |
| 378 | + </object> |
| 379 | + </child> |
| 380 | + </object> |
| 381 | +</interface> |
| 382 | |
| 383 | === renamed file 'DistUpgrade/mirrors.cfg' => 'data/mirrors.cfg' |
| 384 | === renamed file 'DistUpgrade/removal_blacklist.cfg' => 'data/removal_blacklist.cfg' |
| 385 | === modified file 'debian/ubuntu-release-upgrader-core.install' |
| 386 | --- debian/ubuntu-release-upgrader-core.install 2012-06-13 18:08:14 +0000 |
| 387 | +++ debian/ubuntu-release-upgrader-core.install 2012-06-28 19:27:18 +0000 |
| 388 | @@ -2,6 +2,8 @@ |
| 389 | debian/tmp/etc/update-manager/* |
| 390 | debian/tmp/usr/share/locale |
| 391 | debian/tmp/usr/share/ubuntu-release-upgrader/*.cfg |
| 392 | +debian/tmp/usr/share/polkit-1/actions |
| 393 | +debian/tmp/usr/bin/do-partial-upgrade /usr/lib/ubuntu-release-upgrader |
| 394 | debian/release-upgrade-motd usr/lib/ubuntu-release-upgrader |
| 395 | debian/91-release-upgrade etc/update-motd.d/ |
| 396 | debian/source_ubuntu-release-upgrader.py /usr/share/apport/package-hooks/ |
| 397 | |
| 398 | === added file 'do-partial-upgrade' |
| 399 | --- do-partial-upgrade 1970-01-01 00:00:00 +0000 |
| 400 | +++ do-partial-upgrade 2012-06-28 19:27:18 +0000 |
| 401 | @@ -0,0 +1,92 @@ |
| 402 | +#!/usr/bin/python3 |
| 403 | +# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*- |
| 404 | +# |
| 405 | +# Copyright (c) 2004-2012 Canonical |
| 406 | +# 2004-2008 Michael Vogt |
| 407 | +# 2004 Michiel Sikkes |
| 408 | +# |
| 409 | +# Author: Michiel Sikkes <michiel@eyesopened.nl> |
| 410 | +# Michael Vogt <mvo@debian.org> |
| 411 | +# |
| 412 | +# This program is free software; you can redistribute it and/or |
| 413 | +# modify it under the terms of the GNU General Public License as |
| 414 | +# published by the Free Software Foundation; either version 2 of the |
| 415 | +# License, or (at your option) any later version. |
| 416 | +# |
| 417 | +# This program is distributed in the hope that it will be useful, |
| 418 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 419 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 420 | +# GNU General Public License for more details. |
| 421 | +# |
| 422 | +# You should have received a copy of the GNU General Public License |
| 423 | +# along with this program; if not, write to the Free Software |
| 424 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 425 | +# USA |
| 426 | + |
| 427 | +from __future__ import print_function |
| 428 | + |
| 429 | +from gi.repository import Gtk |
| 430 | +import gi |
| 431 | +gi.require_version("Gtk", "3.0") |
| 432 | + |
| 433 | +import os |
| 434 | +import sys |
| 435 | + |
| 436 | +from DistUpgrade.DistUpgradeVersion import VERSION |
| 437 | +from DistUpgrade.DistUpgradeController import DistUpgradeController |
| 438 | +import locale |
| 439 | +import gettext |
| 440 | + |
| 441 | +from optparse import OptionParser |
| 442 | + |
| 443 | +if __name__ == "__main__": |
| 444 | + |
| 445 | + Gtk.init_check(sys.argv) |
| 446 | + Gtk.Window.set_default_icon_name("system-software-update") |
| 447 | + |
| 448 | + #FIXME: Workaround a bug in optparser which doesn't handle unicode/str |
| 449 | + # correctly, see http://bugs.python.org/issue4391 |
| 450 | + # Should be resolved by Python3 |
| 451 | + gettext.bindtextdomain("ubuntu-release-upgrader", "/usr/share/locale") |
| 452 | + gettext.textdomain("ubuntu-release-upgrader") |
| 453 | + translation = gettext.translation("ubuntu-release-upgrader", fallback=True) |
| 454 | + if sys.version >= '3': |
| 455 | + _ = translation.gettext |
| 456 | + else: |
| 457 | + _ = translation.ugettext |
| 458 | + |
| 459 | + try: |
| 460 | + locale.setlocale(locale.LC_ALL, "") |
| 461 | + except: |
| 462 | + pass |
| 463 | + |
| 464 | + # Begin parsing of options |
| 465 | + parser = OptionParser() |
| 466 | + parser.add_option ("-V", "--version", action="store_true", |
| 467 | + dest="show_version", default=False, |
| 468 | + help=_("Show version and exit")) |
| 469 | + parser.add_option ("--data-dir", "", |
| 470 | + default="/usr/share/ubuntu-release-upgrader/", |
| 471 | + help=_("Directory that contains the data files")) |
| 472 | + parser.add_option ("-f", "--frontend", default="DistUpgradeViewText", |
| 473 | + dest="frontend", |
| 474 | + help=_("Run the specified frontend")) |
| 475 | + |
| 476 | + (options, args) = parser.parse_args() |
| 477 | + |
| 478 | + data_dir = os.path.normpath(options.data_dir)+"/" |
| 479 | + |
| 480 | + if options.show_version: |
| 481 | + print("%s: version %s" % (os.path.basename(sys.argv[0]), VERSION)) |
| 482 | + sys.exit(0) |
| 483 | + |
| 484 | + module_name = "DistUpgrade." + options.frontend |
| 485 | + module = __import__(module_name) |
| 486 | + submodule = getattr(module, options.frontend) |
| 487 | + view_class = getattr(submodule, options.frontend) |
| 488 | + view = view_class(data_dir) |
| 489 | + if options.frontend == "DistUpgradeViewGtk3": |
| 490 | + view.label_title.set_markup("<b><big>%s</big></b>" % |
| 491 | + _("Running partial upgrade")) |
| 492 | + controller = DistUpgradeController(view, datadir=data_dir) |
| 493 | + controller.doPartialUpgrade() |
| 494 | |
| 495 | === modified file 'do-release-upgrade' |
| 496 | --- do-release-upgrade 2012-06-28 16:12:09 +0000 |
| 497 | +++ do-release-upgrade 2012-06-28 19:27:18 +0000 |
| 498 | @@ -4,12 +4,10 @@ |
| 499 | |
| 500 | import warnings |
| 501 | warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning) |
| 502 | -import apt |
| 503 | |
| 504 | from DistUpgrade.DistUpgradeVersion import VERSION |
| 505 | |
| 506 | from UpdateManager.Core.MetaRelease import MetaReleaseCore |
| 507 | -from DistUpgrade.DistUpgradeFetcherCore import DistUpgradeFetcherCore |
| 508 | from optparse import OptionParser |
| 509 | import locale |
| 510 | import gettext |
| 511 | @@ -22,6 +20,26 @@ |
| 512 | RELEASE_AVAILABLE=0 |
| 513 | NO_RELEASE_AVAILABLE=1 |
| 514 | |
| 515 | + |
| 516 | +def get_fetcher(frontend, new_dist, datadir): |
| 517 | + if frontend == "DistUpgradeViewGtk3": |
| 518 | + from DistUpgrade.DistUpgradeFetcher import DistUpgradeFetcherGtk |
| 519 | + from DistUpgrade.GtkProgress import GtkAcquireProgress |
| 520 | + progress = GtkAcquireProgress( |
| 521 | + None, |
| 522 | + datadir, |
| 523 | + _("Downloading the release upgrade tool")) |
| 524 | + return DistUpgradeFetcherGtk(new_dist=new_dist, |
| 525 | + progress=progress, |
| 526 | + parent=None, |
| 527 | + datadir=datadir) |
| 528 | + else: |
| 529 | + from DistUpgrade.DistUpgradeFetcherCore import DistUpgradeFetcherCore |
| 530 | + import apt |
| 531 | + progress = apt.progress.text.AcquireProgress() |
| 532 | + return DistUpgradeFetcherCore |
| 533 | + |
| 534 | + |
| 535 | if __name__ == "__main__": |
| 536 | |
| 537 | #FIXME: Workaround a bug in optparser which doesn't handle unicode/str |
| 538 | @@ -53,6 +71,9 @@ |
| 539 | dest="devel_release", default=False, |
| 540 | help=_("Check if upgrading to the latest devel release " |
| 541 | "is possible")) |
| 542 | + parser.add_option ("--data-dir", "", |
| 543 | + default="/usr/share/ubuntu-release-upgrader/", |
| 544 | + help=_("Directory that contains the data files")) |
| 545 | parser.add_option ("-p", "--proposed", action="store_true", |
| 546 | dest="proposed_release", default=False, |
| 547 | help=_("Try upgrading to the latest release using " |
| 548 | @@ -120,9 +141,7 @@ |
| 549 | print(_("Run 'do-release-upgrade' to upgrade to it.")) |
| 550 | sys.exit(RELEASE_AVAILABLE) |
| 551 | |
| 552 | - progress = apt.progress.text.AcquireProgress() |
| 553 | - fetcher = DistUpgradeFetcherCore(new_dist=m.new_dist, |
| 554 | - progress=progress) |
| 555 | + fetcher = get_fetcher(options.frontend, m.new_dist, options.data_dir) |
| 556 | fetcher.run_options += ["--mode=%s" % options.mode, |
| 557 | "--frontend=%s" % options.frontend, |
| 558 | ] |
| 559 | |
| 560 | === modified file 'po/POTFILES.in' |
| 561 | --- po/POTFILES.in 2012-06-28 16:12:09 +0000 |
| 562 | +++ po/POTFILES.in 2012-06-28 19:27:18 +0000 |
| 563 | @@ -14,10 +14,14 @@ |
| 564 | DistUpgrade/DistUpgradeViewKDE.py |
| 565 | DistUpgrade/DistUpgradeView.py |
| 566 | DistUpgrade/DistUpgradeViewText.py |
| 567 | +DistUpgrade/GtkProgress.py |
| 568 | DistUpgrade/ReleaseNotesViewer.py |
| 569 | DistUpgrade/ReleaseNotesViewerWebkit.py |
| 570 | +[type: gettext/glade]data/gtkbuilder/AcquireProgress.ui |
| 571 | [type: gettext/glade]data/gtkbuilder/DistUpgrade.ui |
| 572 | [type: gettext/glade]data/gtkbuilder/ReleaseNotes.ui |
| 573 | [type: gettext/glade]data/gtkbuilder/UpgradePromptDialog.ui |
| 574 | +[type: gettext/xml]data/com.ubuntu.release-upgrader.policy.in |
| 575 | +do-partial-upgrade |
| 576 | do-release-upgrade |
| 577 | check-new-release-gtk |
| 578 | |
| 579 | === modified file 'pre-build.sh' |
| 580 | --- pre-build.sh 2012-06-22 00:41:25 +0000 |
| 581 | +++ pre-build.sh 2012-06-28 19:27:18 +0000 |
| 582 | @@ -34,7 +34,7 @@ |
| 583 | |
| 584 | # cleanup |
| 585 | rm -rf utils/apt/lists utils/apt/*.bin |
| 586 | -(cd utils && ./update_mirrors.py ../DistUpgrade/mirrors.cfg) |
| 587 | +(cd utils && ./update_mirrors.py ../data/mirrors.cfg) |
| 588 | |
| 589 | # run the test-suit |
| 590 | #echo "Running integrated tests" |
| 591 | |
| 592 | === modified file 'setup.cfg' |
| 593 | --- setup.cfg 2012-06-06 21:23:35 +0000 |
| 594 | +++ setup.cfg 2012-06-28 19:27:18 +0000 |
| 595 | @@ -1,5 +1,6 @@ |
| 596 | [build_i18n] |
| 597 | domain=ubuntu-release-upgrader |
| 598 | +xml-files=[("share/polkit-1/actions", ["data/com.ubuntu.release-upgrader.policy.in"]),] |
| 599 | |
| 600 | [sdist] |
| 601 | formats = bztar |
| 602 | |
| 603 | === modified file 'setup.py' |
| 604 | --- setup.py 2012-06-28 16:12:09 +0000 |
| 605 | +++ setup.py 2012-06-28 19:27:18 +0000 |
| 606 | @@ -23,6 +23,7 @@ |
| 607 | 'DistUpgrade', |
| 608 | ], |
| 609 | scripts=[ |
| 610 | + "do-partial-upgrade", |
| 611 | "do-release-upgrade", |
| 612 | "kubuntu-devel-release-upgrade", |
| 613 | "check-new-release-gtk", |
| 614 | @@ -32,7 +33,7 @@ |
| 615 | glob.glob("data/gtkbuilder/*.ui") |
| 616 | ), |
| 617 | ('share/ubuntu-release-upgrader/', |
| 618 | - glob.glob("DistUpgrade/*.cfg")+ |
| 619 | + glob.glob("data/*.cfg")+ |
| 620 | glob.glob("DistUpgrade/*.ui") |
| 621 | ), |
| 622 | ('share/man/man8', |

I see no obvious gotchas, looks good to me, thanks.