示例#1
0
 def commit(self):
     os.environ["DEBIAN_FRONTEND"] = "noninteractive"
     os.environ["DEBONF_NONINTERACTIVE_SEEN"] = "true"
     print("Commiting changes ...")
     self.cache.commit(ElbeAcquireProgress(),
                       ElbeInstallProgress(fileno=sys.stdout.fileno()))
     self.cache.open(progress=ElbeOpProgress())
示例#2
0
 def commit(self):
     os.environ["DEBIAN_FRONTEND"] = "noninteractive"
     os.environ["DEBONF_NONINTERACTIVE_SEEN"] = "true"
     self.cache.commit(ElbeAcquireProgress(),
                       ElbeInstallProgress(fileno=self.logfile.fileno()))
     self.cache.open(progress=ElbeOpProgress())
示例#3
0
文件: updated.py 项目: lwalewski/elbe
def _apply_update(fname, status):

    try:
        xml = etree(fname)
    except:
        return "read %s failed" % fname

    fpl = xml.node("fullpkgs")

    sources = apt_pkg.SourceList()
    sources.read_main_list()

    status.log("initialize apt")
    apt_pkg.init()
    cache = apt_pkg.Cache(progress=ElbeOpProgress(cb=status.log))

    status.set_progress(1)
    status.log("updating package cache")
    cache.update(ElbeAcquireProgress(cb=status.log), sources)
    # quote from python-apt api doc: "A call to this method does not affect the
    # current Cache object, instead a new one should be created in order to use
    # the changed index files."
    cache = apt_pkg.Cache(progress=ElbeOpProgress(cb=status.log))
    depcache = apt_pkg.DepCache(cache)
    hl_cache = apt.cache.Cache(progress=ElbeOpProgress(cb=status.log))
    hl_cache.update(fetch_progress=ElbeAcquireProgress(cb=status.log))

    # go through package cache, if a package is in the fullpkg list of the XML
    #  mark the package for installation (with the specified version)
    #  if it is not mentioned in the fullpkg list purge the package out of the
    #  system.
    status.set_progress(2)
    status.log("calculating packages to install/remove")
    count = len(hl_cache)
    step = count / 10
    i = 0
    percent = 0
    for p in hl_cache:
        i = i + 1
        if not (i % step):
            percent = percent + 10
            status.log(str(percent) + "% - " + str(i) + "/" + str(count))
            status.set_progress(2, str(percent) + "%")

        pkg = cache[p.name]
        marked = False
        for fpi in fpl:
            if pkg.name == fpi.et.text:
                mark_install(depcache, pkg, fpi.et.get('version'),
                             fpi.et.get('auto'), status)
                marked = True

        if not marked:
            depcache.mark_delete(pkg, True)

    status.set_progress(3)
    status.log("applying snapshot")
    depcache.commit(ElbeAcquireProgress(cb=status.log),
                    ElbeInstallProgress(cb=status.log))
    del depcache
    del hl_cache
    del cache
    del sources

    version_file = open("/etc/updated_version", "w")
    version_file.write(xml.text("/project/version"))
    version_file.close()
示例#4
0
 def commit(self):
     os.environ["DEBIAN_FRONTEND"]="noninteractive"
     os.environ["DEBONF_NONINTERACTIVE_SEEN"]="true"
     self.cache.commit( ElbeAcquireProgress(cb=self.co_cb),
                        ElbeInstallProgress(cb=self.co_cb) )
     self.cache.open()