summaryrefslogtreecommitdiff
path: root/DistUpgrade
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-02-02 15:50:23 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2006-02-02 15:50:23 +0000
commit0f3e83010710cf3493c0c9f2bab16e5f028c114c (patch)
treecbc4290f4582fc81eb4147f75502357d4e0cb348 /DistUpgrade
parent442066f04db10be923c15455d16155358a6d5321 (diff)
downloadpython-apt-0f3e83010710cf3493c0c9f2bab16e5f028c114c.tar.gz
* make the Config-File more usable
Diffstat (limited to 'DistUpgrade')
-rw-r--r--DistUpgrade/DistUpgrade.cfg28
-rw-r--r--DistUpgrade/DistUpgradeCache.py18
-rw-r--r--DistUpgrade/DistUpgradeConfigParser.py20
-rw-r--r--DistUpgrade/DistUpgradeControler.py38
4 files changed, 74 insertions, 30 deletions
diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg
index 979d7c0c..b9cb2cc3 100644
--- a/DistUpgrade/DistUpgrade.cfg
+++ b/DistUpgrade/DistUpgrade.cfg
@@ -1,4 +1,30 @@
+# Distro contains global information about the upgrade
[Distro]
+# the meta-pkgs we support
+MetaPkgs=ubuntu-desktop, kubuntu-desktop, edubuntu-desktop, xubuntu-desktop
+BaseMetaPkgs=ubuntu-base
+ForcedPurges=xorg-common
+
+# information about the individual meta-pkgs
+[ubuntu-desktop]
+KeyDependencies=gdm, gnome-panel, ubuntu-artwork
+ForcedObsoletes=xscreensaver
+
+[kubuntu-desktop]
+KeyDependencies=kdm, kicker, kubuntu-artwork-usplash
+
+[edubuntu-desktop]
+KeyDependencies=edubuntu-artwork, tuxpaint
+
+[xubuntu-desktop]
+KeyDependencies=xubuntu-artwork-usplash, xubuntu-default-settings, xfce4
+
+
+[Files]
+BackupExt=distUpgrade
+
+[Sources]
From=breezy
-To=Dapper
+To=dapper
ValidOrigin=Ubuntu
+ValidMirrors = http://archive.ubuntu.com/ubuntu, http://security.ubuntu.com/ubuntu, http://archive.distrosprint/ubuntu/ \ No newline at end of file
diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py
index c7cb89f3..45d892c7 100644
--- a/DistUpgrade/DistUpgradeCache.py
+++ b/DistUpgrade/DistUpgradeCache.py
@@ -5,6 +5,7 @@ import os
import re
import logging
from gettext import gettext as _
+from DistUpgradeConfigParser import DistUpgradeConfigParser
class MyCache(apt.Cache):
# init
@@ -12,6 +13,9 @@ class MyCache(apt.Cache):
apt.Cache.__init__(self, progress)
self.to_install = []
self.to_remove = []
+
+ self.config = DistUpgradeConfigParser()
+
# turn on debuging
apt_pkg.Config.Set("Debug::pkgProblemResolver","true")
fd = os.open(os.path.expanduser("~/dist-upgrade-apt.log"), os.O_RDWR|os.O_CREAT|os.O_TRUNC)
@@ -161,14 +165,12 @@ class MyCache(apt.Cache):
return metapkg_found
# now check for ubuntu-desktop, kubuntu-desktop, edubuntu-desktop
- metapkgs = {"ubuntu-desktop": ["gdm","gnome-panel", "ubuntu-artwork"],
- "kubuntu-desktop": ["kdm", "kicker",
- "kubuntu-artwork-usplash"],
- "edubuntu-desktop": ["edubuntu-artwork", "tuxpaint"]
- }
+ metapkgs = self.config.getlist("Distro","MetaPkgs")
# we never go without ubuntu-base
- self["ubuntu-base"].markInstall()
+ for pkg in self.config.getlist("Distro","BaseMetaPkgs"):
+ self[pkg].markInstall()
+
# every meta-pkg that is installed currently, will be marked
# install (that result in a upgrade and removes a markDelete)
for key in metapkgs:
@@ -182,7 +184,7 @@ class MyCache(apt.Cache):
logging.debug("no {ubuntu,edubuntu,kubuntu}-desktop pkg installed")
for key in metapkgs:
deps_found = True
- for pkg in metapkgs[key]:
+ for pkg in self.config.getlist(key,"KeyDependencies"):
deps_found &= self.has_key(pkg) and self[pkg].isInstalled
if deps_found:
logging.debug("guessing '%s' as missing meta-pkg" % key)
@@ -208,8 +210,6 @@ class MyCache(apt.Cache):
"above first using synaptic or "
"apt-get before proceeding."))
return False
-
- # FIXME: check for ubuntu-desktop, kubuntu-dekstop, edubuntu-desktop
return True
def _inRemovalBlacklist(self, pkgname):
diff --git a/DistUpgrade/DistUpgradeConfigParser.py b/DistUpgrade/DistUpgradeConfigParser.py
new file mode 100644
index 00000000..449e67b2
--- /dev/null
+++ b/DistUpgrade/DistUpgradeConfigParser.py
@@ -0,0 +1,20 @@
+from ConfigParser import ConfigParser, NoOptionError
+
+
+class DistUpgradeConfigParser(ConfigParser):
+ def __init__(self):
+ ConfigParser.__init__(self)
+ self.read(['DistUpgrade.cfg'])
+ def getlist(self, section, option):
+ try:
+ tmp = self.get(section, option)
+ except NoOptionError:
+ return []
+ items = [x.strip() for x in tmp.split(",")]
+ return items
+
+
+if __name__ == "__main__":
+ c = DistUpgradeConfigParser()
+ print c.getlist("Distro","MetaPkgs")
+ print c.getlist("Distro","ForcedPurges")
diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py
index 1ba0f7e0..fd9a0cbe 100644
--- a/DistUpgrade/DistUpgradeControler.py
+++ b/DistUpgrade/DistUpgradeControler.py
@@ -28,7 +28,7 @@ import subprocess
import logging
import re
import statvfs
-import ConfigParser
+from DistUpgradeConfigParser import DistUpgradeConfigParser
from SoftwareProperties.aptsources import SourcesList, SourceEntry
from gettext import gettext as _
@@ -42,21 +42,16 @@ class DistUpgradeControler(object):
self._view.updateStatus(_("Reading cache"))
self.cache = None
- self.config = ConfigParser.ConfigParser()
- self.config.read(['DistUpgrade.cfg'])
-
+ self.config = DistUpgradeConfigParser()
+ self.sources_backup_ext = "."+self.config.get("Files","BackupExt")
+
# some constants here
- self.fromDist = self.config.get("Distro","From")
- self.toDist = self.config.get("Distro","To")
- self.origin = self.config.get("Distro","ValidOrigin")
+ self.fromDist = self.config.get("Sources","From")
+ self.toDist = self.config.get("Sources","To")
+ self.origin = self.config.get("Sources","ValidOrigin")
# forced obsoletes
- self.forced_obsoletes = []
- for line in open("forced_obsoletes.txt").readlines():
- line = line.strip()
- if not line == "" or line.startswith("#"):
- self.forced_obsoletes.append(line)
- logging.debug("forced obsoletes '%s'" % line)
+ self.forced_obsoletes = self.config.getlist("Distro","ForcedObsoletes")
def openCache(self):
@@ -81,15 +76,16 @@ class DistUpgradeControler(object):
]
# list of valid mirrors that we can add
- valid_mirrors = ["http://archive.ubuntu.com/ubuntu",
- "http://security.ubuntu.com/ubuntu"]
+ valid_mirrors = self.config.getlist("Sources","ValidMirrors")
# look over the stuff we have
foundToDist = False
for entry in self.sources:
# check if it's a mirror (or offical site)
+ validMirror = False
for mirror in valid_mirrors:
if self.sources.is_mirror(mirror,entry.uri):
+ validMirror = True
if entry.dist in toDists:
# so the self.sources.list is already set to the new
# distro
@@ -103,10 +99,9 @@ class DistUpgradeControler(object):
entry.disabled = True
# it can only be one valid mirror, so we can break here
break
- else:
- # disable non-official entries that point to dist
- if entry.dist == self.fromDist:
- entry.disabled = True
+ # disable anything that is not from a official mirror
+ if not validMirror:
+ entry.disabled = True
if not foundToDist:
# FIXME: offer to write a new self.sources.list entry
@@ -116,7 +111,6 @@ class DistUpgradeControler(object):
"the upgrade was found.\n"))
# write (well, backup first ;) !
- self.sources_backup_ext = ".distUpgrade"
self.sources.backup(self.sources_backup_ext)
self.sources.save()
@@ -279,9 +273,13 @@ class DistUpgradeControler(object):
self._view.updateStatus(_("Checking package manager"))
self._view.setStep(1)
self.openCache()
+
if not self.cache.sanityCheck(self._view):
abort(1)
+ # run a "apt-get update" now
+ self.doUpdate()
+
# do pre-upgrade stuff (calc list of obsolete pkgs etc)
self.doPreUpdate()