~mvo/update-manager/not-automatic

« back to all changes in this revision

Viewing changes to utils/demotions.py

  • Committer: Michael Vogt
  • Date: 2006-05-12 13:01:33 UTC
  • Revision ID: michael.vogt@ubuntu.com-20060512130133-cfcb3c5a85e250ad
* utils/demotions.py: added tool to calculate demotions from main
                      to universe

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
#
 
3
# FIXME: strip "TryExec" from the extracted menu files (and noDisplay)
 
4
#        
 
5
# TODO:
 
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
 
11
 
 
12
import os
 
13
import tarfile
 
14
import sys
 
15
import apt
 
16
import apt_pkg
 
17
import apt_inst
 
18
#import xdg.Menu
 
19
import os.path
 
20
import re
 
21
import tempfile
 
22
import subprocess
 
23
import string
 
24
import shutil
 
25
import urllib
 
26
import logging
 
27
 
 
28
 
 
29
# pkgs in main for the given dist
 
30
class Dist(object):
 
31
  def __init__(self,name):
 
32
    self.name = name
 
33
    self.pkgs_in_comp = {}
 
34
 
 
35
if __name__ == "__main__":
 
36
 
 
37
  # init
 
38
  apt_pkg.Config.Set("Dir::state","./apt/")
 
39
  apt_pkg.Config.Set("Dir::Etc","./apt")
 
40
  try:
 
41
    os.makedirs("apt/lists/partial")
 
42
  except OSError:
 
43
    pass
 
44
 
 
45
  breezy = Dist("breezy")
 
46
  dapper = Dist("dapper")
 
47
  
 
48
  # go over the dists to find main pkgs
 
49
  for dist in [breezy, dapper]:
 
50
    
 
51
    for comp in ["main", "restricted", "universe", "multiverse"]:
 
52
      line = "deb http://archive.ubuntu.com/ubuntu %s %s\n" % (dist.name,comp)
 
53
      file("apt/sources.list","w").write(line)
 
54
      dist.pkgs_in_comp[comp] = set()
 
55
 
 
56
      # and the archs
 
57
      for arch in ["i386","amd64", "powerpc"]:
 
58
        apt_pkg.Config.Set("APT::Architecture",arch)
 
59
        cache = apt.Cache(apt.progress.OpTextProgress())
 
60
        prog = apt.progress.TextFetchProgress() 
 
61
        cache.update(prog)
 
62
        cache.open(apt.progress.OpTextProgress())
 
63
        map(lambda pkg: dist.pkgs_in_comp[comp].add(pkg.name), cache)
 
64
 
 
65
  # check what is no longer in main
 
66
  no_longer_main = breezy.pkgs_in_comp["main"] - dapper.pkgs_in_comp["main"]
 
67
  no_longer_main |= breezy.pkgs_in_comp["restricted"] - dapper.pkgs_in_comp["restricted"]
 
68
 
 
69
  # check what moved to universe and what was removed (or renamed)
 
70
  in_universe = lambda pkg: pkg in dapper.pkgs_in_comp["universe"] or pkg in dapper.pkgs_in_comp["multiverse"]
 
71
 
 
72
  # debug
 
73
  #not_in_universe = lambda pkg: not in_universe(pkg)
 
74
  #print filter(not_in_universe, no_longer_main)
 
75
 
 
76
  # this stuff was demoted and is no in universe
 
77
  demoted = filter(in_universe, no_longer_main)
 
78
  demoted.sort()
 
79
 
 
80
  outfile = "demoted.cfg"
 
81
  print "writing the demotion info to '%s'" % outfile
 
82
  # write it out
 
83
  out = open(outfile,"w")
 
84
  out.write("# demoted packages in dapper\n")
 
85
  out.write("\n".join(demoted))