~ubuntu-core-dev/update-manager/main

« back to all changes in this revision

Viewing changes to DistUpgrade/apt-autoinst-fixup.py

  • Committer: Barry Warsaw
  • Date: 2012-06-11 21:26:38 UTC
  • mfrom: (2446.1.6 py3)
  • Revision ID: barry@python.org-20120611212638-jw2m9ugw7nstqt3p
* Switch default view class to Gtk3 and replace python-gobject dependency
  with python-gi.
* Port away from old-style apt.Package candidateFoo and installedFoo
  properties, preferring candidate.foo and installed.foo.  In a number of
  cases we have to check whether candidate/installed is non-None first.
* Use apt_pkg.version_compare rather than apt_pkg.VersionCompare.
* Use apt_pkg.uri_to_filename rather than apt_pkg.URItoFileName.
* Use apt_pkg.TagFile (and related new-style API) rather than
  apt_pkg.ParseTagFile.
* Use apt_pkg.PackageManager rather than apt_pkg.GetPackageManager.
* Use apt_pkg.Acquire rather than apt_pkg.GetAcquire.
* Use mark_foo/marked_foo rather than markFoo/markedFoo.
* Use apt_pkg.ActionGroup rather than apt_pkg.GetPkgActionGroup.
* Use apt_pkg.ProblemResolver rather than apt_pkg.GetPkgProblemResolver.
* Use apt_pkg.read_config_file rather than apt_pkg.ReadConfigFile.
* Use new spelling of apt_pkg.DepCache methods.
* Rename several local cache methods to PEP-8 style to avoid showing up in
  the output of /usr/share/python-apt/migrate-0.8.py.
* Use apt_pkg.size_to_str rather than apt_pkg.SizeToStr.
* Use apt_pkg.PackageManager.get_archives rather than
  apt_pkg.PackageManager.GetArchives.
* Use apt_pkg.Acquire.fetch_needed rather than
  apt_pkg.Acquire.FetchNeeded.
* Use new spelling of apt_pkg.Package/Version/Dependency methods.
* Use apt_pkg.pkgsystem_lock rather than apt_pkg.PkgSystemLock.
* Use new spelling of apt_pkg dependency parsing methods.
* Use new spelling of apt_pkg.SourceList methods.
* Bump python-apt (build-)dependency to >= 0.8.0.
* Merge branch from Michael Terry to drop auto-upgrade-tester
  from update-manager and move it into its own source package
* Begin refactoring of Computer Janitor code by renaming and
  re-situating all of it to janitor/plugincore.  This will eventually be
  removed from here into its own separate branch.
* Merge the temporary Python 3 sprint branch back into trunk, and close
  the py3 sprint branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
cache = apt.Cache()
18
18
 
19
19
min_version = "0.6.20ubuntu13"
20
 
if apt_pkg.VersionCompare(cache["python-apt"].installedVersion, min_version) < 0:
 
20
if apt_pkg.version_compare(getattr(cache["python-apt"].installed, "version", "0"), min_version) < 0:
21
21
    logging.error("Need at least python-apt version %s " % min_version)
22
22
    sys.exit(1)
23
23
 
32
32
for pkg in cache:
33
33
    if pkg.is_installed and pkg.section == "metapackages":
34
34
        logging.debug("Found installed meta-pkg: '%s' " % pkg.name)
35
 
        dependsList = pkg._pkg.CurrentVer.DependsList
 
35
        dependsList = pkg._pkg.current_ver.depends_list
36
36
        for t in ["Depends","PreDepends","Recommends"]:
37
37
            if t in dependsList:
38
38
                for depOr in dependsList[t]:
39
39
                    for dep in depOr:
40
 
                        depname = dep.TargetPkg.Name
 
40
                        depname = dep.target_pkg.name
41
41
                        if (cache[depname].is_installed and
42
42
                            cache._depcache.is_auto_installed(cache[depname]._pkg)):
43
43
                            logging.info("Removed auto-flag from package '%s'" % depname)
50
50
    STATE_FILE = apt_pkg.config.find_dir("Dir::State") + "extended_states"
51
51
    # open the statefile
52
52
    if os.path.exists(STATE_FILE):
53
 
        tagfile = apt_pkg.ParseTagFile(open(STATE_FILE))
 
53
        tagfile = apt_pkg.TagFile(open(STATE_FILE))
54
54
        outfile = open(STATE_FILE+".tmp","w")
55
 
        while tagfile.Step():
56
 
            pkgname = tagfile.Section.get("Package")
57
 
            autoInst = tagfile.Section.get("Auto-Installed")
 
55
        for section in tagfile:
 
56
            pkgname = section.get("Package")
 
57
            autoInst = section.get("Auto-Installed")
58
58
            if pkgname in need_fixup:
59
 
                newsec = apt_pkg.RewriteSection(tagfile.Section,
60
 
                                                [],
61
 
                                       [ ("Auto-Installed",str(action)) ]
62
 
                                       )
 
59
                newsec = apt_pkg.rewrite_section(
 
60
                    section, [], [("Auto-Installed", str(action))])
63
61
                outfile.write(newsec+"\n")
64
62
            else:
65
 
                outfile.write(str(tagfile.Section)+"\n")
 
63
                outfile.write(str(section)+"\n")
66
64
        os.rename(STATE_FILE, STATE_FILE+".fixup-save")
67
65
        os.rename(outfile.name, STATE_FILE)
68
66
        os.chmod(STATE_FILE, 0o644)