def mark_upgrades():
    '''Mark packages that can upgrade to upgrade during install'''
    from apt.cache import Cache
    cache = Cache()
    to_install = []
    for key in cache.keys():
        if cache[key].is_upgradable:
            to_install.append(key)
    del cache
    return to_install
示例#2
0
def mark_upgrades():
    '''Mark packages that can upgrade to upgrade during install'''
    from apt.cache import Cache
    cache = Cache()
    to_install = []
    for key in cache.keys():
        if cache[key].is_upgradable:
            to_install.append(key)
    del cache
    return to_install
示例#3
0
    def list(self, query=None):
        """
        Generator for all packages.

        :param query: Search string
        :type query: string
        :return: Package object
        :rtype:Package object
        """

        cache = apt.Cache()
        for _id in cache.keys():
            yield self.__make_package(cache[_id])
def mark_packages(recovery_partition):
    '''Finds packages to install:
        * any debs from debs/main that we want unconditionally installed
          (but ONLY the latest version on the media)
        * upgrades
        * dell-recovery - if recovery partition
        * dell-eula - if it exists
    '''
    import apt_inst
    import apt_pkg
    from apt.cache import Cache

    def parse(fname):
        """ read a deb """
        control = apt_inst.DebFile(fname).control.extractdata("control")
        sections = apt_pkg.TagSection(control)
        if "Modaliases" in sections:
            modaliases = sections["Modaliases"]
        else:
            modaliases = ''
        return (sections["Architecture"], sections["Package"], modaliases)

    #process debs/main
    to_install = []
    my_arch = fetch_output(['dpkg', '--print-architecture']).strip()
    for top in [ISO_MOUNT, CDROM_MOUNT]:
        repo = os.path.join(top, 'debs', 'main')
        if os.path.isdir(repo):
            for fname in os.listdir(repo):
                if '.deb' in fname:
                    arch, package, modaliases = parse(os.path.join(
                        repo, fname))
                    if not modaliases and (arch == "all" or arch == my_arch):
                        to_install.append(package)

    #mark upgrades and dell-recovery/dell-eula
    cache = Cache()
    for key in cache.keys():
        if cache[key].is_upgradable:
            to_install.append(key)
            continue
        #only install if present on the media
        if key == 'dell-eula' and recovery_partition:
            to_install.append(key)
    del cache

    #only install if using recovery partition
    if recovery_partition:
        to_install.append('dell-recovery')

    return to_install
示例#5
0
 def list(self, query=None):
     cache = apt.Cache()
     for _id in cache.keys():
         yield self.__make_package(cache[_id])
示例#6
0
 def list(self, query=None):
     cache = apt.Cache()
     for _id in cache.keys():
         yield self.__make_package(cache[_id])