Пример #1
0
    def __init__(self,
                 rfs,
                 log,
                 arch,
                 notifier=None,
                 norecommend=False,
                 noauth=True):
        sys.stdout = open(log, 'a', buffering=0)
        sys.stderr = open(log, 'a', buffering=0)
        self.logfile = open(log, 'a', buffering=0)

        InChRootObject.__init__(self, rfs)

        self.notifier = notifier
        config.set("APT::Architecture", arch)
        if norecommend:
            config.set("APT::Install-Recommends", "1")
        else:
            config.set("APT::Install-Recommends", "0")

        if noauth:
            config.set("APT::Get::AllowUnauthenticated", "1")
        else:
            config.set("APT::Get::AllowUnauthenticated", "0")

        self.cache = Cache(progress=ElbeOpProgress())
        self.cache.open(progress=ElbeOpProgress())
Пример #2
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())
Пример #3
0
    def __init__(self,
                 rfs,
                 arch,
                 notifier=None,
                 norecommend=False,
                 noauth=True):

        # pylint: disable=too-many-arguments
        InChRootObject.__init__(self, rfs)

        self.notifier = notifier
        config.set("APT::Architecture", arch)
        if norecommend:
            config.set("APT::Install-Recommends", "0")
        else:
            config.set("APT::Install-Recommends", "1")

        if noauth:
            config.set("APT::Get::AllowUnauthenticated", "1")
        else:
            config.set("APT::Get::AllowUnauthenticated", "0")

        self.cache = Cache(progress=ElbeOpProgress())
        self.cache.open(progress=ElbeOpProgress())
Пример #4
0
 def update(self):
     self.cache.update(fetch_progress=ElbeAcquireProgress())
     self.cache.open(progress=ElbeOpProgress())
Пример #5
0
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()
Пример #6
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())