~ken-vandine/ubuntu-release-upgrader/core18_snaps

« back to all changes in this revision

Viewing changes to utils/demotions.py

  • Committer: Michael Vogt
  • Date: 2007-12-04 17:31:29 UTC
  • Revision ID: michael.vogt@ubuntu.com-20071204173129-s22zep1ug18pd71v
* DistUpgrade/DistUpgrade.cfg.dapper,
  DistUpgrade/prerequists-sources.list.dapper:
  - add support for dapper->hardy upgrades
* DistUpgrade/DistUpgradeConfigParser.py:
  - add overwrite support for the configuration to support
    upgrades to multiple target releases with the same
    upgrader
* data/update-manager.schemas.in:
  - /apps/update-manager/check_dist_upgrades is deprecated
* utils/demotions.py:
  - make it more flexible to support generating both 
    dapper and gutsy demotions

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
import os
13
13
import tarfile
14
14
import sys
 
15
import warnings
 
16
warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning)
15
17
import apt
16
18
import apt_pkg
17
19
import apt_inst
64
66
  except OSError:
65
67
    pass
66
68
 
67
 
  old = Dist("gutsy")
68
 
  new = Dist("hardy")
 
69
  old = Dist(sys.argv[1]) # Dist("gutsy")
 
70
  new = Dist(sys.argv[2]) # Dist("hardy")
69
71
  
70
72
  # go over the dists to find main pkgs
71
73
  for dist in [old, new]:
78
80
      # and the archs
79
81
      for arch in ARCHES:
80
82
        apt_pkg.Config.Set("APT::Architecture",arch)
81
 
        cache = apt.Cache(apt.progress.OpTextProgress())
82
 
        prog = apt.progress.TextFetchProgress() 
 
83
        cache = apt.Cache(apt.progress.OpProgress())
 
84
        prog = apt.progress.FetchProgress() 
83
85
        cache.update(prog)
84
 
        cache.open(apt.progress.OpTextProgress())
 
86
        cache.open(apt.progress.OpProgress())
85
87
        map(lambda pkg: dist.pkgs_in_comp[comp].add(pkg.name), cache)
86
88
 
87
89
  # check what is no longer in main
101
103
 
102
104
  # remove items that are now in universe, but are replaced by something
103
105
  # in main (pidgin, gaim) etc
104
 
  print "Looking for replaces"
 
106
  #print "Looking for replaces"
105
107
  line = "deb http://archive.ubuntu.com/ubuntu %s %s\n" % (new.name, "main")
106
108
  file("apt/sources.list","w").write(line)
107
109
  dist.pkgs_in_comp[comp] = set()
108
110
  for arch in ARCHES:
109
111
    apt_pkg.Config.Set("APT::Architecture",arch)
110
 
    cache = apt.Cache(apt.progress.OpTextProgress())
111
 
    prog = apt.progress.TextFetchProgress() 
 
112
    cache = apt.Cache(apt.progress.OpProgress())
 
113
    prog = apt.progress.FetchProgress() 
112
114
    cache.update(prog)
113
 
    cache.open(apt.progress.OpTextProgress())
 
115
    cache.open(apt.progress.OpProgress())
114
116
    # go over the packages in "main" and check if they replaces something
115
117
    # that we think is a demotion
116
118
    for pkgname in new.pkgs_in_comp["main"]:
117
119
      replaces = get_replace(cache, pkgname)
118
120
      for r in replaces:
119
121
        if r in demoted:
120
 
          print "found '%s' that is demoted but replaced by '%s'" % (r, pkgname)
 
122
          #print "found '%s' that is demoted but replaced by '%s'" % (r, pkgname)
121
123
          demoted.remove(r)
122
124
 
123
 
  outfile = "demoted.cfg"
124
 
  print "writing the demotion info to '%s'" % outfile
 
125
  #outfile = "demoted.cfg"
 
126
  #print "writing the demotion info to '%s'" % outfile
125
127
  # write it out
126
 
  out = open(outfile,"w")
127
 
  out.write("# demoted packages\n")
128
 
  out.write("\n".join(demoted))
 
128
  #out = open(outfile,"w")
 
129
  #out.write("# demoted packages\n")
 
130
  #out.write("\n".join(demoted))
 
131
  print "# demoted packages from %s to %s" % (sys.argv[1], sys.argv[2])
 
132
  print "\n".join(demoted)