toaster: show full list of dependents to remove
PATCH 1/3 toaster: show full list of dependents to remove
From: Dave Lerner <[email protected]>
When a package is to be removed, show the full list of packages that are dependent on that package, telling user that these packages will also be removed.
[YOCTO #9121]
--- .../toaster/toastergui/static/js/customrecipe.js | 72 ++++++++++++++++++++-- 1 file changed, 66 insertions(+), 6 deletions(-)
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +66 -6
@@ -89,7 +89,21 @@ function customRecipePageInit(ctx) { var depsList = modal.find("#package-reverse-dep-list"); var deps = pkgData.reverse_dependencies; + var depsCount = deps.length; + var vDepends = "depends"; + var vPackage = "package"; + var vThis = "this"; + if (depsCount > 1) { + vDepends = "depend"; + vPackage = "packages"; + vThis = "these"; + } modal.find(".package-to-rm-name").text(targetPkg.name); + modal.find(".reverse-deps-count").text(depsCount); + modal.find(".reverse-deps-count-plus1").text((depsCount+1) + " packages"); + modal.find(".reverse-deps-depends").text(vDepends); + modal.find(".reverse-deps-package").text(vPackage); + modal.find(".reverse-deps-this").text(vThis); depsList.text("");
@@ -103,6 +117,8 @@ function customRecipePageInit(ctx) { modal.find("#package-reverse-deps-total-size").text( pkgData.reverse_dependencies_size_formatted); + targetPkg.depsRemoved = deps; + rmdPkgReverseDepsModalBtn.data(targetPkg); modal.modal('show'); }
@@ -121,6 +137,10 @@ function customRecipePageInit(ctx) { var btnCell = $("#package-btn-cell-" + targetPkg.id); var inlineNotify = btnCell.children(".inline-notification"); + var i; + var dep; + var depBtnCell; + if (targetPkg.directive === 'add') { method = 'PUT'; /* If the package had dependencies also notify that they were added */
@@ -132,15 +152,15 @@ function customRecipePageInit(ctx) { msg += " packages to " + ctx.recipe.name + ": "; msg += "<strong>" + targetPkg.name + "</strong> and its dependencies"; - for (var i in targetPkg.depsAdded){ - var dep = targetPkg.depsAdded[i]; + for (i in targetPkg.depsAdded){ + dep = targetPkg.depsAdded[i]; msg += " <strong>" + dep.name + "</strong>"; /* Add any cells currently in view to the list of cells which get * an inline notification inside them and which change add/rm state */ - var depBtnCell = $("#package-btn-cell-" + dep.pk); + depBtnCell = $("#package-btn-cell-" + dep.pk); btnCell = btnCell.add(depBtnCell); inlineNotify = inlineNotify.add(
@@ -159,9 +179,49 @@ function customRecipePageInit(ctx) { } else if (targetPkg.directive === 'remove') { method = 'DELETE'; - msg += "removed 1 package from "+ctx.recipe.name+":"; - msg += ' <strong>' + targetPkg.name + '<strong>'; - inlineNotify.text("1 package removed"); + var numPackageString = "1 package "; + var revDepList = ""; + if (targetPkg.hasOwnProperty('depsRemoved') && + targetPkg.depsRemoved.length > 0) { + var depsRemovedLength = targetPkg.depsRemoved.length; + var ending = "y: "; + var maxRevDepsDisplayed = 5; + var d = 0; + if (depsRemovedLength > 1) { + ending = "ies: "; + } + numPackageString = (depsRemovedLength + 1) + " packages"; + revDepList = " and its " + depsRemovedLength + " reverse dependenc" + ending; + for (i in targetPkg.depsRemoved){ + /* include up to maxRevDepsDisplayed rev deps on the page notification */ + var notShownCount = depsRemovedLength - maxRevDepsDisplayed; + dep = targetPkg.depsRemoved[i]; + if (d < maxRevDepsDisplayed) { + if (d > 0) { + revDepList += ", "; + } + revDepList += dep.name; + d++; + if ((d === maxRevDepsDisplayed) && (notShownCount > 0)) { + revDepList += " and " + notShownCount + " more"; + } + } + + /* Add any cells currently in view to the list of cells which get + * an inline notification inside them and which change add/rm state + */ + depBtnCell = $("#package-btn-cell-" + dep.pk); + btnCell = btnCell.add(depBtnCell); + + inlineNotify = inlineNotify.add( + depBtnCell.children(".inline-notification")); + } + } + msg+= "removed " + numPackageString + " from " + ctx.recipe.name + ":"; + msg += " <strong>" + targetPkg.name + "</strong>"; + msg += revDepList; + + inlineNotify.text(numPackageString + " removed"); } else { throw("Unknown package directive: should be add or remove"); }
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 2/3 toaster: new customise package-remove modal dlg
From: Dave Lerner <[email protected]>
For customised image package removal, show a different modal dialog that lists ALL of the packages dependent on this package, with a Remove All button - implying that all of the dependents will be removed.
[YOCTO #9121]
--- bitbake/lib/toaster/toastergui/templates/customrecipe.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
bitbake/lib/toaster/toastergui/templates/customrecipe.html +3 -2
@@ -66,13 +66,14 @@ <h3><span class="package-to-rm-name"></span> reverse dependencies</h3> </div> <div class="modal-body"> - <p>Based on information from a previous build it is likely that <strong class="package-to-rm-name"></strong> may be added again as the following packages directly depend on it for your custom image:</p> + <p> <strong class="reverse-deps-count"></strong> <span class="reverse-deps-package"></span> in your image <span class="reverse-deps-depends"></span> on <strong class="package-to-rm-name"></strong>:</p> <ul id="package-reverse-dep-list"> </ul> + <p>In order to remove <strong class="package-to-rm-name"></strong>, you must remove <span class="reverse-deps-this"></span> <strong class="reverse-deps-count"></strong> <span class="reverse-deps-package"></span> as well.</p> </div> <div class="modal-footer"> <p class="help-block text-left">Total package size: <strong id="package-reverse-deps-total-size"></strong></p> - <button id="rm-package-reverse-deps-modal-btn" type="submit" class="btn btn-primary" data-dismiss="modal">Remove package</button> + <button id="rm-package-reverse-deps-modal-btn" type="submit" class="btn btn-primary" data-dismiss="modal">Remove all <span class="reverse-deps-count-plus1"></button> <button class="btn" data-dismiss="modal">Cancel</button> </div> </div>
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 3/3 toaster: get all dependents for pkg for removal
In reply to Elliot SmithFrom: Dave Lerner <[email protected]>
For customised image package removal change behavior.
From:
Only display the immediate dependents of the requested package to remove, not the full dependent list, that is dependents of dependents ...
Do not remove the displayed dependents, just notify the user of the list.
To:
Display the complete dependent tree, traversing all reverse dependencies starting from the package to be removed and then it's dependents.
Change the modal dialog to note that all of these dependents will be removed automatically.
[YOCTO #9121]
--- bitbake/lib/toaster/toastergui/views.py | 91 ++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 12 deletions(-)
bitbake/lib/toaster/toastergui/views.py +79 -12
@@ -2538,6 +2538,60 @@ if True: return response + def _traverse_dependents(next_package_id, rev_deps, all_current_packages, tree_level=0): + """ + Recurse through reverse dependency tree for next_package_id. + Limit the reverse dependency search to packages not already scanned, + that is, not already in rev_deps. + Limit the scan to a depth (tree_level) not exceeding the count of + all packages in the custom image, and if that depth is exceeded + return False, pop out of the recursion, and write a warning + to the log, but this is unlikely, suggesting a dependency loop + not caught by bitbake. + On return, the input/output arg rev_deps is appended with queryset + dictionary elements, annotated for use in the customimage template. + The list has unsorted, but unique elements. + """ + max_dependency_tree_depth = all_current_packages.count() + if tree_level >= max_dependency_tree_depth: + logger.warning( + "The number of reverse dependencies " + "for this package exceeds " + max_dependency_tree_depth + + " and the remaining reverse dependencies will not be removed") + return True + + package = CustomImagePackage.objects.get(id=next_package_id) + dependents = \ + package.package_dependencies_target.annotate( + name=F('package__name'), + pk=F('package__pk'), + size=F('package__size'), + ).values("name", "pk", "size").exclude( + ~Q(pk__in=all_current_packages) + ) + + for pkg in dependents: + if pkg in rev_deps: + # already seen, skip dependent search + continue + + rev_deps.append(pkg) + if (_traverse_dependents( + pkg["pk"], rev_deps, all_current_packages, tree_level+1)): + return True + + return False + + def _get_all_dependents(package_id, all_current_packages): + """ + Returns sorted list of recursive reverse dependencies for package_id, + as a list of dictionary items, by recursing through dependency + relationships. + """ + rev_deps = [] + _traverse_dependents(package_id, rev_deps, all_current_packages) + rev_deps = sorted(rev_deps, key=lambda x: x["name"]) + return rev_deps @xhr_response def xhr_customrecipe_packages(request, recipe_id, package_id):
@@ -2606,15 +2660,9 @@ if True: ) # Reverse dependencies which are needed by packages that are - # in the image - reverse_deps = package.package_dependencies_target.annotate( - name=F('package__name'), - pk=F('package__pk'), - size=F('package__size'), - ).values("name", "pk", "size").exclude( - ~Q(pk__in=all_current_packages) - ) - + # in the image. Recursive search providing all dependents, + # not just immediate dependents. + reverse_deps = _get_all_dependents(package_id, all_current_packages) total_size_deps = 0 total_size_reverse_deps = 0
@@ -2658,6 +2706,11 @@ if True: else: recipe.appends_set.add(package) + # Make sure that package is not in the excludes set + try: + recipe.excludes_set.remove(package) + except: + pass # Add the dependencies we think will be added to the recipe # as a result of appending this package. # TODO this should recurse down the entire deps tree
@@ -2668,11 +2721,12 @@ if True: recipe.includes_set.add(cust_package) try: - # when adding the pre-requisite package make sure it's not in the - # excluded list from a prior removal. + # When adding the pre-requisite package, make + # sure it's not in the excluded list from a + # prior removal. recipe.excludes_set.remove(cust_package) except Package.DoesNotExist: - # Don't care if the package had never been excluded + # Don't care if the package had never been excluded pass except: logger.warning("Could not add package's suggested"
@@ -2688,6 +2742,19 @@ if True: recipe.excludes_set.add(package) else: recipe.appends_set.remove(package) + all_current_packages = recipe.get_all_packages() + reverse_deps_dictlist = _get_all_dependents(package.pk, all_current_packages) + ids = [entry['pk'] for entry in reverse_deps_dictlist] + reverse_deps = CustomImagePackage.objects.filter(id__in=ids) + for r in reverse_deps: + try: + if r.id in included_packages: + recipe.excludes_set.add(r) + else: + recipe.appends_set.remove(r) + except: + pass + return {"error": "ok"} except CustomImageRecipe.DoesNotExist: return {"error": "Tried to remove package that wasn't present"}
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.