From 040c4c726d15962c942f0b286299da2c48e9bccb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Sep 2006 12:07:36 +0200 Subject: * DistUpgrade/DistUpgradeControler.py: - start a initial backports feature --- DistUpgrade/DistUpgrade.cfg | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'DistUpgrade/DistUpgrade.cfg') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index 7a8ebba9..03388b07 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -39,5 +39,9 @@ To=edgy ValidOrigin=Ubuntu ValidMirrors = mirrors.cfg +[Backports] +Packages=apt,dpkg,python-apt +DebLine=deb http://people.ubuntu.com/~mvo/backports/dapper/ / + [Network] MaxRetries=3 \ No newline at end of file -- cgit v1.2.3 From 2f0d800812e27c97be60a9e9da7d7b1645d0533d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Sep 2006 13:10:22 +0200 Subject: * DistUpgrade/DistUpgrade.cfg: - added version identifier to the config to ensure that we get the right version of backported packages (currently set to ~dapper) * DistUpgrade/DistUpgradeControler.py: - check the versionlist of the backported packages to find the one we need --- DistUpgrade/DistUpgrade.cfg | 2 ++ DistUpgrade/DistUpgradeControler.py | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'DistUpgrade/DistUpgrade.cfg') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index 03388b07..62a4bb8b 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -41,7 +41,9 @@ ValidMirrors = mirrors.cfg [Backports] Packages=apt,dpkg,python-apt +VersionIdent=~edgy DebLine=deb http://people.ubuntu.com/~mvo/backports/dapper/ / + [Network] MaxRetries=3 \ No newline at end of file diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 0ae879dc..4d8e9bf5 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -558,7 +558,9 @@ class DistUpgradeControler(object): " download the backports specified in DistUpgrade.cfg " # save cachedir and setup new one cachedir = apt_pkg.Config.Find("Dir::Cache::archives") + cwd = os.getcwd() backportsdir = os.path.join(os.getcwd(),"backports") + os.chdir(backportsdir) if not os.path.exists(backportsdir): os.mkdir(backportsdir) if not os.path.exists(os.path.join(backportsdir,"partial")): @@ -568,16 +570,33 @@ class DistUpgradeControler(object): # mark the backports for upgrade and get them fetcher = apt_pkg.GetAcquire(self._view.getFetchProgress()) # FIXME: add a version line to the cfg file to make sure - # we get the right version file! + # we get the right version file! and add sanity checking + # that we don't get (accidently) the edgy version for pkgname in self.config.getlist("Backports","Packages"): pkg = self.cache[pkgname] - pkg._lookupRecord(True) + # look for the right version (backport) + for ver in pkg._pkg.VersionList: + print ver.VerStr + if self.config.get("Backports","VersionIdent") in ver.VerStr: + break + else: + # FIXME: be more clever here (exception) + print "No backport found!?!" + return False + if ver.FileList == None: + print "No FileList for: %s " % self._pkg.Name() + return False + f, index = ver.FileList.pop(0) + pkg._records.Lookup((f,index)) path = apt_pkg.ParseSection(pkg._records.Record)["Filename"] cand = pkg._depcache.GetCandidateVer(pkg._pkg) for (packagefile,i) in cand.FileList: indexfile = self.cache._list.FindIndex(packagefile) if indexfile: - uri = indexfile.ArchiveURI(path) + match = re.match(r"<.*ArchiveURI='(.*)'>$", + str(indexfile)) + if match: + uri = match.group(1) + path apt_pkg.GetPkgAcqFile(fetcher, uri=uri, descr=_("Fetching backport of '%s'" % pkgname)) res = fetcher.Run() @@ -587,6 +606,7 @@ class DistUpgradeControler(object): # reset the cache dir apt_pkg.Config.Set("Dir::Cache::archives",cachedir) + os.chdir(cwd) return self.setupRequiredBackports(backportsdir) def setupRequiredBackports(self, backportsdir): -- cgit v1.2.3 From 34a9ff9157da1e60b0fc63b7cf583f8d38a0016e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Sep 2006 13:39:13 +0200 Subject: * DistUpgrade/DistUpgrade.cfg: use ~dapper as identifier * DistUpgrade/DistUpgradeControler.py, DistUpgrade/dist-upgrade.py: - add "--haveBackports" to skip parts of the procedure - re-exec itself when all the backports are in place --- DistUpgrade/DistUpgrade.cfg | 4 +- DistUpgrade/DistUpgradeControler.py | 103 +++++++++++++++++++----------------- DistUpgrade/dist-upgrade.py | 4 +- 3 files changed, 59 insertions(+), 52 deletions(-) (limited to 'DistUpgrade/DistUpgrade.cfg') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index 62a4bb8b..b7bc5216 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -41,9 +41,9 @@ ValidMirrors = mirrors.cfg [Backports] Packages=apt,dpkg,python-apt -VersionIdent=~edgy +VersionIdent=~dapper DebLine=deb http://people.ubuntu.com/~mvo/backports/dapper/ / [Network] -MaxRetries=3 \ No newline at end of file +MaxRetries=3 diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 4d8e9bf5..1481769c 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -87,7 +87,7 @@ class AptCdrom(object): class DistUpgradeControler(object): """ this is the controler that does most of the work """ - def __init__(self, distUpgradeView, cdromPath=None, datadir=None): + def __init__(self, distUpgradeView, options=None, datadir=None): # setup the pathes localedir = "/usr/share/locale/update-manager/" if datadir == None: @@ -96,6 +96,8 @@ class DistUpgradeControler(object): gladedir = datadir self.datadir = datadir + self.options = options + # init gettext gettext.bindtextdomain("update-manager",localedir) gettext.textdomain("update-manager") @@ -106,8 +108,8 @@ class DistUpgradeControler(object): self.cache = None # specific for the CDROM based upgrade - self.aptcdrom = AptCdrom(distUpgradeView, cdromPath) self.useNetwork = True + self.aptcdrom = AptCdrom(distUpgradeView, options.cdromPath) # the configuration self.config = DistUpgradeConfig(datadir) @@ -620,63 +622,66 @@ class DistUpgradeControler(object): os.putenv("LD_LIBRARY_PATH",os.path.join(backportsdir,"/usr/lib")) os.putenv("PYTHONPATH",os.path.join(backportsdir,"/usr/lib/python2.4/")) os.putenv("PATH","%s:%s" % (os.path.join(backportsdir,"/usr/bin"),os.getenv("PATH"))) - return True + + # now exec self again + os.execl(sys.argv[0],["--haveBackports"]) # this is the core def edgyUpgrade(self): - # sanity check (check for ubuntu-desktop, brokenCache etc) - self._view.updateStatus(_("Checking package manager")) - self._view.setStep(1) - - if not self.prepare(): - self.abort(1) + if not self.options.haveBackports: + # sanity check (check for ubuntu-desktop, brokenCache etc) + self._view.updateStatus(_("Checking package manager")) + self._view.setStep(1) + + if not self.prepare(): + self.abort(1) - # run a "apt-get update" now - if not self.doUpdate(): - sys.exit(1) + # run a "apt-get update" now + if not self.doUpdate(): + sys.exit(1) - # do pre-upgrade stuff (calc list of obsolete pkgs etc) - self.doPreUpgrade() + # do pre-upgrade stuff (calc list of obsolete pkgs etc) + self.doPreUpgrade() - # update sources.list - self._view.setStep(2) - self._view.updateStatus(_("Updating repository information")) - if not self.updateSourcesList(): - self.abort() - - # add cdrom (if we have one) - if (self.aptcdrom and - not self.aptcdrom.add(self.sources_backup_ext)): - sys.exit(1) + # update sources.list + self._view.setStep(2) + self._view.updateStatus(_("Updating repository information")) + if not self.updateSourcesList(): + self.abort() - # then update the package index files - if not self.doUpdate(): - self.abort() + # add cdrom (if we have one) + if (self.aptcdrom and + not self.aptcdrom.add(self.sources_backup_ext)): + sys.exit(1) - # then open the cache (again) - self._view.updateStatus(_("Checking package manager")) - self.openCache() - # now check if we still have some key packages after the update - # if not something went seriously wrong - for pkg in self.config.getlist("Distro","BaseMetaPkgs"): - if not self.cache.has_key(pkg): - # FIXME: we could offer to add default source entries here, - # but we need to be careful to not duplicate them - # (i.e. the error here could be something else than - # missing sources entires but network errors etc) - logging.error("No '%s' after sources.list rewrite+update") - self._view.error(_("Invalid package information"), - _("After your package information was " - "updated the essential package '%s' can " - "not be found anymore.\n" - "This indicates a serious error, please " - "report this bug against the 'update-manager' " - "package and include the files in /var/log/dist-upgrade/ " - "in the bugreport.") % pkg) + # then update the package index files + if not self.doUpdate(): self.abort() - # get backported packages (if needed) - self.getRequiredBackports() + # then open the cache (again) + self._view.updateStatus(_("Checking package manager")) + self.openCache() + # now check if we still have some key packages after the update + # if not something went seriously wrong + for pkg in self.config.getlist("Distro","BaseMetaPkgs"): + if not self.cache.has_key(pkg): + # FIXME: we could offer to add default source entries here, + # but we need to be careful to not duplicate them + # (i.e. the error here could be something else than + # missing sources entires but network errors etc) + logging.error("No '%s' after sources.list rewrite+update") + self._view.error(_("Invalid package information"), + _("After your package information was " + "updated the essential package '%s' can " + "not be found anymore.\n" + "This indicates a serious error, please " + "report this bug against the 'update-manager' " + "package and include the files in /var/log/dist-upgrade/ " + "in the bugreport.") % pkg) + self.abort() + + # get backported packages (if needed) + self.getRequiredBackports() # calc the dist-upgrade and see if the removals are ok/expected # do the dist-upgrade diff --git a/DistUpgrade/dist-upgrade.py b/DistUpgrade/dist-upgrade.py index 07320fb9..3f5bf61b 100755 --- a/DistUpgrade/dist-upgrade.py +++ b/DistUpgrade/dist-upgrade.py @@ -12,6 +12,8 @@ if __name__ == "__main__": parser = OptionParser() parser.add_option("-c", "--cdrom", dest="cdromPath", default=None, help="Use the given path to search for a cdrom with upgradable packages") + parser.add_option("-b", "--have-backports", dest="haveBackports", + default=False) (options, args) = parser.parse_args() if not os.path.exists("/var/log/dist-upgrade"): @@ -31,7 +33,7 @@ if __name__ == "__main__": logging.error("can't import view '%s'" % requested_view) print "can't find %s" % requested_view sys.exit(1) - app = DistUpgradeControler(view, cdromPath=options.cdromPath) + app = DistUpgradeControler(view, options) app.run() -- cgit v1.2.3 From b117e7ca7ed21fe11a3c9554b3848544822a55e2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Sep 2006 16:30:59 +0200 Subject: * DistUpgrade/backport-source.list: - the sources.list fragment for the backports * DistUpgrade/DistUpgradeControler.py: - run the backports fetching as early as possible --- DistUpgrade/DistUpgrade.cfg | 2 +- DistUpgrade/DistUpgradeControler.py | 107 ++++++++++++++++++------------------ DistUpgrade/backport-source.list | 2 + DistUpgrade/dist-upgrade.py | 2 +- 4 files changed, 58 insertions(+), 55 deletions(-) create mode 100644 DistUpgrade/backport-source.list (limited to 'DistUpgrade/DistUpgrade.cfg') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index b7bc5216..767f555e 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -42,7 +42,7 @@ ValidMirrors = mirrors.cfg [Backports] Packages=apt,dpkg,python-apt VersionIdent=~dapper -DebLine=deb http://people.ubuntu.com/~mvo/backports/dapper/ / +SourcesList=backport-source.list [Network] diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 22039aae..fca2abaf 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -274,11 +274,6 @@ class DistUpgradeControler(object): else: self.abort() - # add the backports URI (if we have it) - line = self.config.get("Backports","DebLine") - if line and (not SourceEntry(line) in self.sources.list): - self.sources.list.append(SourceEntry(line)) - # write (well, backup first ;) ! self.sources.backup(self.sources_backup_ext) self.sources.save() @@ -558,6 +553,11 @@ class DistUpgradeControler(object): def getRequiredBackports(self): " download the backports specified in DistUpgrade.cfg " + # add the backports sources.list fragment + shutil.copy(self.config.get("Backports","SourcesList"), + apt_pkg.FindDir("Dir::Etc::sourceparts")) + # run update + self.doUpdate() # save cachedir and setup new one cachedir = apt_pkg.Config.Find("Dir::Cache::archives") cwd = os.getcwd() @@ -606,6 +606,7 @@ class DistUpgradeControler(object): return False # reset the cache dir + os.unlink(apt_pkg.FindDir("Dir::Etc::sourceparts")+"/backport-source.list") apt_pkg.Config.Set("Dir::Cache::archives",cachedir) os.chdir(cwd) return self.setupRequiredBackports(backportsdir) @@ -623,64 +624,64 @@ class DistUpgradeControler(object): os.putenv("PATH","%s:%s" % (os.path.join(backportsdir,"/usr/bin"),os.getenv("PATH"))) # now exec self again - os.execv(sys.argv[0],[sys.argv[0],"--haveBackports"]) + os.execv(sys.argv[0],[sys.argv[0],"--have-backports"]) # this is the core def edgyUpgrade(self): - if not self.options.haveBackports: - # sanity check (check for ubuntu-desktop, brokenCache etc) - self._view.updateStatus(_("Checking package manager")) - self._view.setStep(1) - - if not self.prepare(): - self.abort(1) + # sanity check (check for ubuntu-desktop, brokenCache etc) + self._view.updateStatus(_("Checking package manager")) + self._view.setStep(1) + + if not self.prepare(): + self.abort(1) - # run a "apt-get update" now - if not self.doUpdate(): - sys.exit(1) + if not self.options.haveBackports: + # get backported packages (if needed) + self.getRequiredBackports() - # do pre-upgrade stuff (calc list of obsolete pkgs etc) - self.doPreUpgrade() + # run a "apt-get update" now + if not self.doUpdate(): + sys.exit(1) - # update sources.list - self._view.setStep(2) - self._view.updateStatus(_("Updating repository information")) - if not self.updateSourcesList(): - self.abort() + # do pre-upgrade stuff (calc list of obsolete pkgs etc) + self.doPreUpgrade() - # add cdrom (if we have one) - if (self.aptcdrom and - not self.aptcdrom.add(self.sources_backup_ext)): - sys.exit(1) + # update sources.list + self._view.setStep(2) + self._view.updateStatus(_("Updating repository information")) + if not self.updateSourcesList(): + self.abort() - # then update the package index files - if not self.doUpdate(): - self.abort() + # add cdrom (if we have one) + if (self.aptcdrom and + not self.aptcdrom.add(self.sources_backup_ext)): + sys.exit(1) - # then open the cache (again) - self._view.updateStatus(_("Checking package manager")) - self.openCache() - # now check if we still have some key packages after the update - # if not something went seriously wrong - for pkg in self.config.getlist("Distro","BaseMetaPkgs"): - if not self.cache.has_key(pkg): - # FIXME: we could offer to add default source entries here, - # but we need to be careful to not duplicate them - # (i.e. the error here could be something else than - # missing sources entires but network errors etc) - logging.error("No '%s' after sources.list rewrite+update") - self._view.error(_("Invalid package information"), - _("After your package information was " - "updated the essential package '%s' can " - "not be found anymore.\n" - "This indicates a serious error, please " - "report this bug against the 'update-manager' " - "package and include the files in /var/log/dist-upgrade/ " - "in the bugreport.") % pkg) - self.abort() + # then update the package index files + if not self.doUpdate(): + self.abort() - # get backported packages (if needed) - self.getRequiredBackports() + # then open the cache (again) + self._view.updateStatus(_("Checking package manager")) + self.openCache() + # now check if we still have some key packages after the update + # if not something went seriously wrong + for pkg in self.config.getlist("Distro","BaseMetaPkgs"): + if not self.cache.has_key(pkg): + # FIXME: we could offer to add default source entries here, + # but we need to be careful to not duplicate them + # (i.e. the error here could be something else than + # missing sources entires but network errors etc) + logging.error("No '%s' after sources.list rewrite+update") + self._view.error(_("Invalid package information"), + _("After your package information was " + "updated the essential package '%s' can " + "not be found anymore.\n" + "This indicates a serious error, please " + "report this bug against the 'update-manager' " + "package and include the files in /var/log/dist-upgrade/ " + "in the bugreport.") % pkg) + self.abort() # calc the dist-upgrade and see if the removals are ok/expected # do the dist-upgrade diff --git a/DistUpgrade/backport-source.list b/DistUpgrade/backport-source.list new file mode 100644 index 00000000..5945e218 --- /dev/null +++ b/DistUpgrade/backport-source.list @@ -0,0 +1,2 @@ +# sources.list fragment for backported apt/dpkg/python-apt +deb http://people.ubuntu.com/~mvo/backports/dapper / \ No newline at end of file diff --git a/DistUpgrade/dist-upgrade.py b/DistUpgrade/dist-upgrade.py index 3f5bf61b..7174ce17 100755 --- a/DistUpgrade/dist-upgrade.py +++ b/DistUpgrade/dist-upgrade.py @@ -13,7 +13,7 @@ if __name__ == "__main__": parser.add_option("-c", "--cdrom", dest="cdromPath", default=None, help="Use the given path to search for a cdrom with upgradable packages") parser.add_option("-b", "--have-backports", dest="haveBackports", - default=False) + action="store_true",default=False) (options, args) = parser.parse_args() if not os.path.exists("/var/log/dist-upgrade"): -- cgit v1.2.3 From 1417e173a98b36e10d0e876f668caef090d7b4b7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Sep 2006 17:09:05 +0200 Subject: * DistUpgrade/DistUpgrade.cfg: - use python2.4-apt * DistUpgrade/DistUpgradeControler.py: -fix pathes --- DistUpgrade/DistUpgrade.cfg | 2 +- DistUpgrade/DistUpgradeControler.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'DistUpgrade/DistUpgrade.cfg') diff --git a/DistUpgrade/DistUpgrade.cfg b/DistUpgrade/DistUpgrade.cfg index 767f555e..60c3ca9f 100644 --- a/DistUpgrade/DistUpgrade.cfg +++ b/DistUpgrade/DistUpgrade.cfg @@ -40,7 +40,7 @@ ValidOrigin=Ubuntu ValidMirrors = mirrors.cfg [Backports] -Packages=apt,dpkg,python-apt +Packages=apt,dpkg,python2.4-apt VersionIdent=~dapper SourcesList=backport-source.list diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index b443bf45..7d48db69 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -126,9 +126,8 @@ class DistUpgradeControler(object): # turn on debuging in the cache apt_pkg.Config.Set("Debug::pkgProblemResolver","true") apt_pkg.Config.Set("Debug::pkgDepCache::AutoInstall","true") - # FIXME: make this "append"? fd = os.open("/var/log/dist-upgrade/apt.log", - os.O_RDWR|os.O_CREAT|os.O_TRUNC, 0644) + os.O_RDWR|os.O_CREAT|os.O_APPEND, 0644) os.dup2(fd,1) os.dup2(fd,2) @@ -583,7 +582,7 @@ class DistUpgradeControler(object): break else: # FIXME: be more clever here (exception) - print "No backport found!?!" + raise Exception, "No backport found!?!" return False if ver.FileList == None: print "No FileList for: %s " % self._pkg.Name() @@ -613,15 +612,15 @@ class DistUpgradeControler(object): def setupRequiredBackports(self, backportsdir): " setup the required backports in a evil way " - backportsdir = os.path.normpath(backportsdir) # unpack it for deb in glob.glob(backportsdir+"/*.deb"): ret = os.system("dpkg-deb -x %s %s" % (deb, backportsdir)) # FIXME: do error checking # setup some pathes to make sure the new stuff is used - os.environ["LD_LIBRARY_PATH"] = os.path.join(backportsdir,"/usr/lib") - os.environ["PYTHONPATH"] = os.path.join(backportsdir,"/usr/lib/python2.4/") - os.environ["PATH"] = "%s:%s" % (os.path.join(backportsdir,"/usr/bin"),os.getenv("PATH")) + os.environ["LD_LIBRARY_PATH"] = backportsdir+"/usr/lib" + os.environ["PYTHONPATH"] = backportsdir+"/usr/lib/python2.4/site-packages/" + os.environ["PATH"] = "%s:%s" % (backportsdir+"/usr/bin", + os.getenv("PATH")) # now exec self again os.execve(sys.argv[0],[sys.argv[0],"--have-backports"], os.environ) @@ -635,7 +634,7 @@ class DistUpgradeControler(object): if not self.prepare(): self.abort(1) - if not self.options.haveBackports: + if self.options.haveBackports == False: # get backported packages (if needed) self.getRequiredBackports() -- cgit v1.2.3