3
# FIXME: strip "TryExec" from the extracted menu files (and noDisplay)
6
# - emacs21 ships it's icon in emacs-data, deal with this
7
# - some stuff needs to be blacklisted (e.g. gnome-about)
8
# - lots of packages have there desktop file in "-data", "-comon" (e.g. anjuta)
9
# - lots of packages have multiple desktop files for the same application
10
# abiword, abiword-gnome, abiword-gtk
12
from __future__ import print_function
17
warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning)
22
ARCHES = ["i386","amd64"]
25
# pkgs in main for the given dist
27
def __init__(self,name):
29
self.pkgs_in_comp = {}
32
def get_replace(cache, pkgname):
34
if not cache.has_key(pkgname):
35
#print("can not find '%s'" % pkgname)
38
ver = cache._depcache.get_candidate_ver(pkg._pkg)
41
depends = ver.depends_list
42
for t in ["Replaces"]:
43
if not depends.has_key(t):
45
for depVerList in depends[t]:
46
for depOr in depVerList:
47
replaces.add(depOr.target_pkg.name)
51
if __name__ == "__main__":
54
apt_pkg.config.set("Dir::state","./apt/")
55
apt_pkg.config.set("Dir::Etc","./apt")
56
apt_pkg.config.set("Dir::State::status","./apt/status")
58
os.makedirs("apt/lists/partial")
62
old = Dist(sys.argv[1]) # Dist("gutsy")
63
new = Dist(sys.argv[2]) # Dist("hardy")
65
# go over the dists to find main pkgs
66
for dist in [old, new]:
68
for comp in ["main", "restricted", "universe", "multiverse"]:
69
line = "deb http://archive.ubuntu.com/ubuntu %s %s\n" % (dist.name,comp)
70
with open("apt/sources.list", "w") as sources_list:
71
sources_list.write(line)
72
dist.pkgs_in_comp[comp] = set()
76
apt_pkg.config.set("APT::Architecture",arch)
77
cache = apt.Cache(apt.progress.base.OpProgress())
78
prog = apt.progress.base.AcquireProgress()
80
cache.open(apt.progress.base.OpProgress())
84
dist.pkgs_in_comp[comp].add(pkg.name)
86
# check what is no longer in main
87
no_longer_main = old.pkgs_in_comp["main"] - new.pkgs_in_comp["main"]
88
no_longer_main |= old.pkgs_in_comp["restricted"] - new.pkgs_in_comp["restricted"]
90
# check what moved to universe and what was removed (or renamed)
91
in_universe = lambda pkg: pkg in new.pkgs_in_comp["universe"] or pkg in new.pkgs_in_comp["multiverse"]
94
#print([pkg for pkg in no_longer_main if not in_universe(pkg)])
96
# this stuff was demoted and is in universe
97
demoted = [pkg for pkg in no_longer_main if in_universe(pkg)]
100
# remove items that are now in universe, but are replaced by something
101
# in main (pidgin, gaim) etc
102
#print("Looking for replaces")
103
line = "deb http://archive.ubuntu.com/ubuntu %s %s\n" % (new.name, "main")
104
with open("apt/sources.list", "w") as sources_list:
105
sources_list.write(line)
106
dist.pkgs_in_comp[comp] = set()
108
apt_pkg.config.set("APT::Architecture",arch)
109
cache = apt.Cache(apt.progress.base.OpProgress())
110
prog = apt.progress.base.AcquireProgress()
112
cache.open(apt.progress.base.OpProgress())
113
# go over the packages in "main" and check if they replaces something
114
# that we think is a demotion
115
for pkgname in new.pkgs_in_comp["main"]:
116
replaces = get_replace(cache, pkgname)
119
#print("found '%s' that is demoted but replaced by '%s'" % (r, pkgname))
122
#outfile = "demoted.cfg"
123
#print("writing the demotion info to '%s'" % outfile)
125
#out = open(outfile,"w")
126
#out.write("# demoted packages\n")
127
#out.write("\n".join(demoted))
128
print("# demoted packages from %s to %s" % (sys.argv[1], sys.argv[2]))
129
print("\n".join(demoted))