Last active
September 4, 2019 09:01
-
-
Save julian-klode/7c73a2c92fc10e10a3db0c2f54903031 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import apt_pkg, sys | |
apt_pkg.init() | |
cache=apt_pkg.Cache(None) | |
depcache=apt_pkg.DepCache(cache) | |
def mark_stage(roots, width=1, allow_recommends=False): | |
cont=False | |
for ver in roots: | |
if ver.parent_pkg.name == "kde-runtime": | |
print("Investigate", ver, "with", "width =", width, file=sys.stderr) | |
deps_all = ver.depends_list | |
deps = deps_all.get("Depends", []) + deps_all.get("PreDepends", []) | |
if allow_recommends: | |
deps += deps_all.get("Recommends", []) | |
for dep_group in deps: | |
flat_dep_group = [] | |
for dep in dep_group: | |
for tver in dep.all_targets(): | |
if depcache.get_candidate_ver(tver.parent_pkg) == tver or tver.parent_pkg.current_ver == tver: | |
flat_dep_group.append(tver) | |
if ver.parent_pkg.name == "kde-runtime": | |
print(" checking", dep_group, flat_dep_group, file=sys.stderr) | |
# We are satisfied | |
satisfier=list(v for v in flat_dep_group if ((depcache.marked_install(v.parent_pkg) or depcache.marked_upgrade(v.parent_pkg)) and depcache.get_candidate_ver(v.parent_pkg) == v) or v.parent_pkg.current_ver == v) | |
#print(" satisfied by", satisfier) | |
if satisfier: | |
continue | |
#if len(flat_dep_group) > 1: | |
# print("found group", flat_dep_group, file=sys.stderr) | |
# Propagate changes | |
if flat_dep_group: | |
if len(flat_dep_group) <= width: | |
if ver.parent_pkg.name == "kde-runtime": | |
print("Installing", flat_dep_group[0], "for", dep_group, file=sys.stderr) | |
depcache.mark_install(flat_dep_group[0].parent_pkg, False, False) | |
roots.append(flat_dep_group[0]) | |
#mark_stage([], width, allow_recommends) | |
else: | |
if ver.parent_pkg.name == "kde-runtime": | |
print("Continueing due to", flat_dep_group, file=sys.stderr) | |
cont = True | |
return cont | |
def mark_stage_no_roots(width=1, allow_recommends=False): | |
roots= [] | |
for pkg in cache.packages: | |
if depcache.marked_install(pkg) or depcache.marked_upgrade(pkg): | |
roots.append(depcache.get_candidate_ver(pkg)) | |
print("Investigating", len(roots), file=sys.stderr) #" ".join(v.parent_pkg.name + ":" + v.ver_str for v in roots)) | |
return mark_stage(roots, width, allow_recommends) | |
def mark(): | |
width = 1 | |
while mark_stage_no_roots(width=width, allow_recommends=True): | |
width += 1 | |
depcache.mark_install(cache["plasma-desktop"], False) | |
mark() | |
for pkg in cache.packages: | |
if depcache.marked_install(pkg) or depcache.marked_upgrade(pkg): | |
print(pkg.get_fullname() + "=" + depcache.get_candidate_ver(pkg).ver_str) | |
if depcache.marked_delete(pkg): | |
print(pkg.get_fullname() + "-") | |
if depcache.is_now_broken(pkg): | |
print("broken", pkg, file=sys.stderr) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment