summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-02-06 10:38:09 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2006-02-06 10:38:09 +0100
commit7520aea4b9ea79e180aa9dca5eed719158b70d91 (patch)
tree58897c0bf74e68970643bff5eb85a47b5e4e4470
parent6164b21e46fbd5b56b7c8245f577c137bda9ba11 (diff)
parentf593c02a4051313dd0044888a26d7ab3f4ba1133 (diff)
downloadpython-apt-7520aea4b9ea79e180aa9dca5eed719158b70d91.tar.gz
* merged from the laptop branch
-rw-r--r--DistUpgrade/DistUpgrade.cfg33
-rw-r--r--DistUpgrade/DistUpgradeCache.py18
-rw-r--r--DistUpgrade/DistUpgradeConfigParser.py20
-rw-r--r--DistUpgrade/DistUpgradeControler.py65
-rw-r--r--DistUpgrade/DistUpgradeViewNonInteractive.py75
-rwxr-xr-xDistUpgrade/dist-upgrade.py1
-rw-r--r--SoftwareProperties/aptsources.py2
-rw-r--r--debian/changelog3
8 files changed, 184 insertions, 33 deletions
diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg
new file mode 100644
index 00000000..cf97d16f
--- /dev/null
+++ b/DistUpgrade/DistUpgrade.cfg
@@ -0,0 +1,33 @@
+[General]
+Frontend=GtkDistUpgradeView
+
+# 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
+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..2836d297 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 DistUpgradeConfig
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 = DistUpgradeConfig()
+
# 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..c87e2f1b
--- /dev/null
+++ b/DistUpgrade/DistUpgradeConfigParser.py
@@ -0,0 +1,20 @@
+from ConfigParser import ConfigParser, NoOptionError
+
+
+class DistUpgradeConfig(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 6ab77103..3a43d517 100644
--- a/DistUpgrade/DistUpgradeControler.py
+++ b/DistUpgrade/DistUpgradeControler.py
@@ -28,8 +28,8 @@ import subprocess
import logging
import re
import statvfs
+from DistUpgradeConfigParser import DistUpgradeConfig
-from UpdateManager.Common.SimpleGladeApp import SimpleGladeApp
from SoftwareProperties.aptsources import SourcesList, SourceEntry
from gettext import gettext as _
from DistUpgradeCache import MyCache
@@ -42,22 +42,18 @@ class DistUpgradeControler(object):
self._view.updateStatus(_("Reading cache"))
self.cache = None
+ self.config = DistUpgradeConfig()
+ self.sources_backup_ext = "."+self.config.get("Files","BackupExt")
+
# some constants here
- #self.fromDist = "hoary"
- #self.toDist = "breezy"
- self.fromDist = "breezy"
- self.toDist = "dapper"
-
- self.origin = "Ubuntu"
+ 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")
+ # forced purges
+ self.forced_purges = self.config.getlist("Distro","ForcedPurges")
def openCache(self):
self.cache = MyCache(self._view.getOpCacheProgress())
@@ -81,15 +77,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 +100,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,12 +112,14 @@ 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()
# 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()
@@ -239,18 +237,36 @@ 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 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 \
@@ -266,7 +282,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) """
@@ -280,9 +295,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/DistUpgrade/DistUpgradeViewNonInteractive.py b/DistUpgrade/DistUpgradeViewNonInteractive.py
new file mode 100644
index 00000000..e8236565
--- /dev/null
+++ b/DistUpgrade/DistUpgradeViewNonInteractive.py
@@ -0,0 +1,75 @@
+# DistUpgradeView.py
+#
+# Copyright (c) 2004,2005 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 apt
+import logging
+
+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)
+
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
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/")
diff --git a/debian/changelog b/debian/changelog
index 70e94e66..fc2375ef 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,8 +3,9 @@ update-manager (0.42.2ubuntu1) dapper; urgency=low
* UpdateManager/MetaRelease.py:
- never offer a upgrade to a unsupported (i.e. developer) dist
* data/gnome-software-properties.desktop.in: use X-KDE-SubstituteUID=true
+ * small UI layout changes (should fix the cancel/close button problem)
- -- Michael Vogt <michael.vogt@ubuntu.com> Fri, 27 Jan 2006 22:57:43 +0100
+ -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 31 Jan 2006 09:48:13 +0000
update-manager (0.42.1ubuntu1) dapper; urgency=low