def dependents(args): """Display packages which have some form of dependency on the given package Types of dependencies: * Depends * Recommends * Suggests * Replaces * Enhances""" DEPENDENCY_TYPES = [ "Depends", "Recommends", "Suggests", "Replaces", "Enhances", ] cache = apt.cache.Cache() package = util.package_exists(cache, args.package) dependents = { name : [] for name in DEPENDENCY_TYPES } for key in cache.keys(): other_package = cache[key] for dependency_type, specific_dependents in dependents.items(): if package.shortname in \ util.extract_dependencies(other_package, dependency_type): specific_dependents.append(other_package.shortname) for dependency_type, specific_dependents in dependents.items(): if specific_dependents: output = dependency_type.upper(), " ".join(specific_dependents) print("{}: {}".format(*output))
def dependents(args): """Display packages which have some form of dependency on the given package Types of dependencies: * Depends * Recommends * Suggests * Replaces * Enhances """ DEPENDENCY_TYPES = [ "Depends", "Recommends", "Suggests", "Replaces", "Enhances", ] cache = apt.cache.Cache() package = util.package_exists(cache, args.package) dependents = {name : [] for name in DEPENDENCY_TYPES} for key in cache.keys(): other_package = cache[key] for dependency_type, specific_dependents in dependents.items(): if package.shortname in \ util.extract_dependencies(other_package, dependency_type): specific_dependents.append(other_package.shortname) for dependency_type, specific_dependents in dependents.items(): if specific_dependents: print("{}: {}".format( dependency_type.upper(), " ".join(specific_dependents) ))
def installsuggested(args): """Install a package and its Suggests dependencies""" cache = apt.cache.Cache() package = util.package_exists(cache, args.package, ignore_virtual_packages=True) dependencies = list(util.extract_dependencies(package, "Suggests")) for n, dependency in enumerate(dependencies): dependencies[n] = util.package_exists(cache, dependency).shortname dependencies = " ".join(dependencies) command = "/usr/bin/apt-get {} {} {} --auto-remove install {} {}" command = command.format(args.recommends, args.yes, args.noauth, dependencies, args.package) perform.execute(command, root=True, log=True)
def installsuggested(args): """Install a package and its Suggests dependencies""" cache = apt.cache.Cache() package = util.package_exists(cache, args.package, ignore_virtual_packages=True) dependencies = list(util.extract_dependencies(package, "Suggests")) for n, dependency in enumerate(dependencies): dependencies[n] = util.package_exists(cache, dependency).shortname dependencies = " ".join(dependencies) command = "/usr/bin/apt-get {} {} {} --auto-remove install {} {}" command = command.format(args.recommends, args.yes, args.noauth, dependencies, args.package) perform.execute(command, root=True, log=True)