Skip to contentSkip to conversation

Review Request: 9121 Remove direct/indirect dependents of a package

PATCH Superseded Dave Lerner 3 participants 13 messages Mar 11, 2016 – Mar 17, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

Target Branch: toaster-next, master
Contrib Branch: poky-contrib/dlerner/9121-delete-dependent-package-tree

Defect: 9121
Summary: Show and remove direct and indirect dependents when removing package

Commit Summary
==============
fb26f22 toaster: get all dependents for pkg for removal 85553c3 toaster: new customise package-remove modal dlg fc6d99d toaster: show full list of dependents to remove

 .../toaster/toastergui/static/js/customrecipe.js   | 57 +++++++++++--
 .../toaster/toastergui/templates/customrecipe.html |  5 +-
 bitbake/lib/toaster/toastergui/views.py            | 98 +++++++++++++++++++---
 3 files changed, 140 insertions(+), 20 deletions(-)

Comments:
Refactoring on variables in customrecipe.js addRemovePackage suggested by jshint warning. One comment block in related code in views.py changed per pep8 warning.

===========================
TESTS
===========================
Setup:
------
Start toaster with empty build directory, sstate-cache Create a new project, 'myproject'
Build core-image-sato

CASE Remove dependent package that was part of original base image
------------------------------------------------------------------
Create new custom image on core-image-sato, named mysato
Remove libcrypto
Verify that "39 packages in your image depend on libcrypto" are reported and that the
39 packages are unique and in listed in alpha order, where 39 was valid at the time of my test. Verify that the tail of the dialog says "In order to remove libcrypto, you must remove these 39 packges as well." Verification of total package size value can be done in subsequent test.
Verify that button says "Remove all 40 packages".
Click "Remove all..."
Verify that banner says "You have removed 40 packages from mysato: libcrypto and it's 39 dependents". Verification of the transition button-label notification to '40 packages removed' is done in subsequent test.
Build mysato
Click on mysato | packages
Verify that there are 40 packages less than clicking on core-image-sato packages (eg 569 vs 609).

CASE Add back a root dependency (Issue sent in email Mar9)
----------------------------------------------------------
Open custom image mysato
Add libcrypto back
Build
Click All Projects | Custom Images | mysato
Verify libcrypto 'looks' added it, shows "remove package"

CASE Test no interference removing from a 2nd custom image in project
----------------------------------------------------------------------
New custom-image based on core-image-sato 'myminimal'
Build it
Add atk which is dependent on glib-2.0, libffi, libpcre Build myminimal again.
Verify that atk, libffi, libpcre, glib-2.0 have files in the file system For custom image myminimal, enter libpcre, remove package
Verify modal dlg notes atk and glib-2.0 will be removed Remove
Build
Verify atk, glib2.0 libffi are removed.

CASE Test button notifications and banner on removal for package w/ dependents
------------------------------------------------------------------------------
To minimal, add openssl-staticdev which indirectly will bring in libssl Build
Verify that libssl, openssl, openssl-dev are added
On minimal, enter "openssl" to see a set of matching packages. REmove libssl
Verify modal dialog reports both the direct and indirect dependents
openssl, openssl-dev, and openssl-staticdev, will be removed.
Click Remove all
Verify the buttons for openssl (an others that you see on screen) report:
"4 packages removed"
Verify that the banner says:
"You have removed 4 packages from minimal: libssl and it's 3 dependents Verify that buttons transition to Add Package.

#1 lore raw

PATCH 1/3 toaster: show full list of dependents to remove

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   | 57 +++++++++++++++++++---
 1 file changed, 51 insertions(+), 6 deletions(-)
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +51 -6
index 3c57899..fbb0298 100644
@@ -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,34 @@ 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 depCountString = "";
+      if (targetPkg.hasOwnProperty('depsRemoved') &&
+              targetPkg.depsRemoved.length > 0) {
+        numPackageString = (targetPkg.depsRemoved.length + 1) + " packages";
+        depCountString = " and it's " + targetPkg.depsRemoved.length + " dependent";
+        if (targetPkg.depsRemoved.length > 1) {
+            depCountString += "s";
+        }
+
+        for (i in targetPkg.depsRemoved){
+          dep = targetPkg.depsRemoved[i];
+
+          /* 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 += depCountString;
+
+      inlineNotify.text(numPackageString + " removed");
     } else {
       throw("Unknown package directive: should be add or remove");
     }
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 1/3] toaster: show full list of dependents to remove

Thanks for this Dave. Comments inline below.

Quoted 87 lines · Dave Lerner

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   | 57
+++++++++++++++++++---
 1 file changed, 51 insertions(+), 6 deletions(-)
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +20 -0
index 3c57899..fbb0298 100644
@@ -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

*/

bitbake/lib/toaster/toastergui/static/js/customrecipe.js +2 -2
@@ -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

            */
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +1 -1
-          var depBtnCell = $("#package-btn-cell-" + dep.pk);
+          depBtnCell = $("#package-btn-cell-" + dep.pk);
           btnCell = btnCell.add(depBtnCell);
 
           inlineNotify = inlineNotify.add(
@@ -159,9 +179,34 @@ function customRecipePageInit(ctx) {
 
     } else if (targetPkg.directive === 'remove') {
       method = 'DELETE';

bitbake/lib/toaster/toastergui/static/js/customrecipe.js function customRecipePageInit(ctx) { · line 188

Quoted 10 lines
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +5 -3
-      msg += "removed 1 package from "+ctx.recipe.name+":";
-      msg += ' <strong>' + targetPkg.name + '<strong>';
-      inlineNotify.text("1 package removed");
+      var numPackageString = "1 package ";
+      var depCountString = "";
+      if (targetPkg.hasOwnProperty('depsRemoved') &&
+              targetPkg.depsRemoved.length > 0) {
+        numPackageString = (targetPkg.depsRemoved.length + 1) + "
 packages";
 

I would set a variable numDepsRemoved and use that for all occurrences of targetPkg.depsRemoved.length in this function, but that's a personal preference.

bitbake/lib/toaster/toastergui/static/js/customrecipe.js function customRecipePageInit(ctx) { · line 190

Quoted 3 lines
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +1 -0
+        depCountString = " and it's " + targetPkg.depsRemoved.length + "
 dependent";

"it's" should be "its".

Quoted 20 lines
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +8 -0
+        if (targetPkg.depsRemoved.length > 1) {
+            depCountString += "s";
+        }
+
+        for (i in targetPkg.depsRemoved){
+          dep = targetPkg.depsRemoved[i];
+
+          /* Add any cells currently in view to the list of cells which

get
+ * an inline notification inside them and which change add/rm
state

bitbake/lib/toaster/toastergui/static/js/customrecipe.js +9 -0
+           */
+          depBtnCell = $("#package-btn-cell-" + dep.pk);
+          btnCell = btnCell.add(depBtnCell);
+
+          inlineNotify = inlineNotify.add(
+            depBtnCell.children(".inline-notification"));
+        }
+      }
+      msg+= "removed " + numPackageString + " from " + ctx.recipe.name +
Quoted 2 lines

":";
+ msg += " <strong>" + targetPkg.name + "</strong>";

+ msg += depCountString;

Quoted 14 lines
bitbake/lib/toaster/toastergui/static/js/customrecipe.js +2 -1
+
+      inlineNotify.text(numPackageString + " removed");
     } else {
       throw("Unknown package directive: should be add or remove");
     }
--

1.9.1

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
#3 lore raw

Re: [PATCH 1/3] toaster: show full list of dependents to remove

Elliot, Belen
Since you both had recommendations, I've implemented both sets of recommendations. The v2 vs v1 changes are attached below the review. The full patch set for 9121 will be emailed shortly.

jshint: no issues in changed segments

Thanks for the review
Dave

Quoted 104 lines

-----Original Message-----
From: Smith, Elliot [mailto:[email protected]]
Sent: Thursday, March 17, 2016 7:45 AM
To: Lerner, Dave
Cc: [email protected]; Belen Barros Pena (Intel); WOOD, MICHAEL
Subject: Re: [Toaster] [PATCH 1/3] toaster: show full list of dependents to remove

Thanks for this Dave. Comments inline below.

On 11 March 2016 at 16:29, Dave Lerner <[email protected]> wrote:

	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]

	Signed-off-by: Dave Lerner <[email protected]>
	---
	 .../toaster/toastergui/static/js/customrecipe.js   | 57 +++++++++++++++++++---
	 1 file changed, 51 insertions(+), 6 deletions(-)

	diff --git a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js

b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js
index 3c57899..fbb0298 100644
--- a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js +++ b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js @@ -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,34 @@ 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 depCountString = "";
+ if (targetPkg.hasOwnProperty('depsRemoved') &&
+ targetPkg.depsRemoved.length > 0) {
+ numPackageString = (targetPkg.depsRemoved.length + 1) + " packages";

Quoted 8 lines

I would set a variable numDepsRemoved and use that for all occurrences of targetPkg.depsRemoved.length in this function, but that's a personal preference.

+ depCountString = " and it's " + targetPkg.depsRemoved.length + "
dependent";

Done

Quoted 3 lines

"it's" should be "its".

Done

Quoted 39 lines

+ if (targetPkg.depsRemoved.length > 1) {
+ depCountString += "s";
+ }
+
+ for (i in targetPkg.depsRemoved){
+ dep = targetPkg.depsRemoved[i];
+
+ /* 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 += depCountString;
+
+ inlineNotify.text(numPackageString + " removed");
} else {
throw("Unknown package directive: should be add or remove");
}
--
1.9.1

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Quoted 5 lines

--

Elliot Smith
Software Engineer
Intel Open Source Technology Centre

======================================
V2 vs V1 diff
======================================

bitbake/lib/toaster/toastergui/static/js/customrecipe.js +22 -7
index fbb0298..f1b8afb 100644
@@ -180,17 +180,32 @@ function customRecipePageInit(ctx) {
     } else if (targetPkg.directive === 'remove') {
       method = 'DELETE';
       var numPackageString = "1 package ";
-      var depCountString = "";
+      var revDepList = "";
       if (targetPkg.hasOwnProperty('depsRemoved') &&
               targetPkg.depsRemoved.length > 0) {
-        numPackageString = (targetPkg.depsRemoved.length + 1) + " packages";
-        depCountString = " and it's " + targetPkg.depsRemoved.length + " dependent";
-        if (targetPkg.depsRemoved.length > 1) {
-            depCountString += "s";
+        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
@@ -204,7 +219,7 @@ function customRecipePageInit(ctx) {
       }
       msg+= "removed " + numPackageString + " from " + ctx.recipe.name + ":";
       msg += " <strong>" + targetPkg.name + "</strong>";
-      msg += depCountString;
+      msg += revDepList;
 
       inlineNotify.text(numPackageString + " removed");
     } else {
#4 lore raw

PATCH 2/3 toaster: new customise package-remove modal dlg

In reply to Dave Lerner

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
index 8cce919..4b58992 100644
@@ -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 · 1 line
1.9.1
#5 lore raw

PATCH 3/3 toaster: get all dependents for pkg for removal

In reply to Dave Lerner

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 | 98 +++++++++++++++++++++++++++++----
 1 file changed, 86 insertions(+), 12 deletions(-)
bitbake/lib/toaster/toastergui/views.py +86 -12
index 85ca9be..4442d33 100755
@@ -2538,6 +2538,67 @@ if True:
 
         return response
 
+    def _traverse_dependents(next_package_id, list, all_current_packages, tree_level):
+        """
+        Recurse through dependents (reverse dependency) tree up to a
+        depth of MAX_DEPENDENCY_TREE_DEPTH just in case their are circular
+        dependencies. A large system has 500 packages, exceeding a
+        dependency chain that long is unlikely.
+        Don't scan for dependencies for a package already in list.
+        Return the updated list with new dependencies.
+        """
+        MAX_DEPENDENCY_TREE_DEPTH = 500
+        if tree_level >= MAX_DEPENDENCY_TREE_DEPTH:
+            logger.warning(
+                "The number of dependents in the dependency tree"
+                "for this package exceeds " + MAX_DEPENDENDENCY_TREE_DEPTH +
+                " and the remaining dependents will not be removed")
+            return list, 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)
+            )
+
+        truncated = False
+        for pkg in dependents:
+            if pkg in list:
+                # already seen, skip dependent search
+                continue
+
+            list.append(pkg)
+            extension, truncated = _traverse_dependents(
+                pkg["pk"], list, all_current_packages, tree_level+1)
+            if truncated:
+                break
+
+        return list, truncated
+
+    def _get_all_dependents(package_id, all_current_packages, flat):
+        """
+        Returns the full list of dependents, also known as reverse
+        dependencies, for package_id, recursing through dependency
+        relationships.
+        Returns either list of dictionary items or a list of CustomImagePackage
+        model objects depending on arg flat=False
+        """
+        import itertools
+        list = []
+        list, truncated = _traverse_dependents(
+            package_id, list, all_current_packages, 0)
+
+        # sort and remove duplicates
+        sortedlist = sorted(list, key=lambda x: x["name"])
+        list = [x[0] for x in itertools.groupby(sortedlist)]
+
+        if flat:
+            list = [CustomImagePackage.objects.get(id=entry["pk"]) for entry in list]
+        return list
 
     @xhr_response
     def xhr_customrecipe_packages(request, recipe_id, package_id):
@@ -2606,15 +2667,10 @@ 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, flat=False)
                 total_size_deps = 0
                 total_size_reverse_deps = 0
 
@@ -2658,6 +2714,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 +2729,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 +2750,18 @@ if True:
                     recipe.excludes_set.add(package)
                 else:
                     recipe.appends_set.remove(package)
+                all_current_packages = recipe.get_all_packages()
+                reverse_deps = _get_all_dependents(
+                    package.pk, all_current_packages, flat=True)
+                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 · 1 line
1.9.1
#6 lore raw

Re: [PATCH 3/3] toaster: get all dependents for pkg for removal

Hi Elliot,
I realized this morning that a line in _get_all_dependents() is benign but not required. The impact is performance - an unnecessary pass through the list of reverse dependendencies. I don't know if that justifies a V2 patch or not.

See the details below, inline.
Dave

Quoted 59 lines

-----Original Message-----
From: Dave Lerner [mailto:[email protected]]
Sent: Friday, March 11, 2016 10:29 AM
To: [email protected]; [email protected]; WOOD, MICHAEL
Cc: Lerner, Dave
Subject: [PATCH 3/3] toaster: get all dependents for pkg for removal

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 | 98 +++++++++++++++++++++++++++++----
 1 file changed, 86 insertions(+), 12 deletions(-)
bitbake/lib/toaster/toastergui/views.py +22 -0
index 85ca9be..4442d33 100755
@@ -2538,6 +2538,67 @@ if True:
 
         return response
 
+    def _traverse_dependents(next_package_id, list, all_current_packages, tree_level):
+        """
+        Recurse through dependents (reverse dependency) tree up to a
+        depth of MAX_DEPENDENCY_TREE_DEPTH just in case their are circular
+        dependencies. A large system has 500 packages, exceeding a
+        dependency chain that long is unlikely.
+        Don't scan for dependencies for a package already in list.
+        Return the updated list with new dependencies.
+        """
+        MAX_DEPENDENCY_TREE_DEPTH = 500
+        if tree_level >= MAX_DEPENDENCY_TREE_DEPTH:
+            logger.warning(
+                "The number of dependents in the dependency tree"
+                "for this package exceeds " + MAX_DEPENDENDENCY_TREE_DEPTH +
+                " and the remaining dependents will not be removed")
+            return list, True
+
+        package = CustomImagePackage.objects.get(id=next_package_id)
+        dependents = \
+            package.package_dependencies_target.annotate(
+                name=F('package__name'),
+                pk=F('package__pk'),

bitbake/lib/toaster/toastergui/views.py if True: · line 2572

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +10 -0
+                size=F('package__size'),
+            ).values("name", "pk", "size").exclude(
+                ~Q(pk__in=all_current_packages)
+            )
+
+        truncated = False
+        for pkg in dependents:
+            if pkg in list:
+                # already seen, skip dependent search
+                continue

The scan prevents duplicate packages in the list and therefor the groupby list line below to make list entries unique is not required.

Quoted 14 lines
bitbake/lib/toaster/toastergui/views.py +14 -0
+            list.append(pkg)
+            extension, truncated = _traverse_dependents(
+                pkg["pk"], list, all_current_packages, tree_level+1)
+            if truncated:
+                break
+
+        return list, truncated
+
+    def _get_all_dependents(package_id, all_current_packages, flat):
+        """
+        Returns the full list of dependents, also known as reverse
+        dependencies, for package_id, recursing through dependency
+        relationships.
+        Returns either list of dictionary items or a list of CustomImagePackage

bitbake/lib/toaster/toastergui/views.py if True: · line 2597

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +10 -0
+        model objects depending on arg flat=False
+        """
+        import itertools
+        list = []
+        list, truncated = _traverse_dependents(
+            package_id, list, all_current_packages, 0)
+
+        # sort and remove duplicates
+        sortedlist = sorted(list, key=lambda x: x["name"])
+        list = [x[0] for x in itertools.groupby(sortedlist)]

The above line is should not be necessary, the list entries are already unique.

Quoted 78 lines
bitbake/lib/toaster/toastergui/views.py +14 -10
+
+
+        if flat:
+            list = [CustomImagePackage.objects.get(id=entry["pk"]) for entry in list]
+        return list
 
     @xhr_response
     def xhr_customrecipe_packages(request, recipe_id, package_id):
@@ -2606,15 +2667,10 @@ 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, flat=False)
                 total_size_deps = 0
                 total_size_reverse_deps = 0
 
@@ -2658,6 +2714,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 +2729,12 @@ if True:
 
                         recipe.includes_set.add(cust_package)
                         try:
-                            # when adding the pre-requisite package make sure it's not

in the

bitbake/lib/toaster/toastergui/views.py +16 -3
-                            #   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 +2750,18 @@ if True:
                     recipe.excludes_set.add(package)
                 else:
                     recipe.appends_set.remove(package)
+                all_current_packages = recipe.get_all_packages()
+                reverse_deps = _get_all_dependents(
+                    package.pk, all_current_packages, flat=True)
+                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"}
--

1.9.1

#7 lore raw

Re: [PATCH 3/3] toaster: get all dependents for pkg for removal

It might be a good idea to do a v2, but you can wait until I've had a better look through the other code if you like, in case there's anything else.

Elliot

Quoted 207 lines · David M (Wind River)

Hi Elliot,
I realized this morning that a line in _get_all_dependents() is benign but not required. The impact is performance - an unnecessary pass through the list of reverse dependendencies. I don't know if that justifies a V2 patch or not.

See the details below, inline.
Dave

Quoted 4 lines

-----Original Message-----
From: Dave Lerner [mailto:[email protected]]
Sent: Friday, March 11, 2016 10:29 AM
To: [email protected]; [email protected]; WOOD,

MICHAEL

Quoted 17 lines

Cc: Lerner, Dave
Subject: [PATCH 3/3] toaster: get all dependents for pkg for removal

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.

Quoted 5 lines

[YOCTO #9121]

---
 bitbake/lib/toaster/toastergui/views.py | 98

+++++++++++++++++++++++++++++----

bitbake/lib/toaster/toastergui/views.py if True: · line 2541

Quoted 12 lines
 1 file changed, 86 insertions(+), 12 deletions(-)
bitbake/lib/toaster/toastergui/views.py +1 -0
index 85ca9be..4442d33 100755
@@ -2538,6 +2538,67 @@ if True:
 
         return response
 
+    def _traverse_dependents(next_package_id, list,

all_current_packages, tree_level):

bitbake/lib/toaster/toastergui/views.py if True:

Quoted 3 lines
bitbake/lib/toaster/toastergui/views.py +3 -0
+        """
+        Recurse through dependents (reverse dependency) tree up to a
+        depth of MAX_DEPENDENCY_TREE_DEPTH just in case their are

circular

bitbake/lib/toaster/toastergui/views.py if True:

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +10 -0
+        dependencies. A large system has 500 packages, exceeding a
+        dependency chain that long is unlikely.
+        Don't scan for dependencies for a package already in list.
+        Return the updated list with new dependencies.
+        """
+        MAX_DEPENDENCY_TREE_DEPTH = 500
+        if tree_level >= MAX_DEPENDENCY_TREE_DEPTH:
+            logger.warning(
+                "The number of dependents in the dependency tree"
+                "for this package exceeds " +

MAX_DEPENDENDENCY_TREE_DEPTH +

Quoted 8 lines
bitbake/lib/toaster/toastergui/views.py +8 -0
+                " and the remaining dependents will not be removed")
+            return list, True
+
+        package = CustomImagePackage.objects.get(id=next_package_id)
+        dependents = \
+            package.package_dependencies_target.annotate(
+                name=F('package__name'),
+                pk=F('package__pk'),

bitbake/lib/toaster/toastergui/views.py if True: · line 2572

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +10 -0
+                size=F('package__size'),
+            ).values("name", "pk", "size").exclude(
+                ~Q(pk__in=all_current_packages)
+            )
+
+        truncated = False
+        for pkg in dependents:
+            if pkg in list:
+                # already seen, skip dependent search
+                continue

The scan prevents duplicate packages in the list and therefor the groupby list line below to make list entries unique is not required.

Quoted 4 lines
bitbake/lib/toaster/toastergui/views.py +4 -0
+            list.append(pkg)
+            extension, truncated = _traverse_dependents(
+                pkg["pk"], list, all_current_packages, tree_level+1)
+            if truncated:

bitbake/lib/toaster/toastergui/views.py if True:

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +10 -0
+                break
+
+        return list, truncated
+
+    def _get_all_dependents(package_id, all_current_packages, flat):
+        """
+        Returns the full list of dependents, also known as reverse
+        dependencies, for package_id, recursing through dependency
+        relationships.
+        Returns either list of dictionary items or a list of

CustomImagePackage

bitbake/lib/toaster/toastergui/views.py if True: · line 2597

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +10 -0
+        model objects depending on arg flat=False
+        """
+        import itertools
+        list = []
+        list, truncated = _traverse_dependents(
+            package_id, list, all_current_packages, 0)
+
+        # sort and remove duplicates
+        sortedlist = sorted(list, key=lambda x: x["name"])
+        list = [x[0] for x in itertools.groupby(sortedlist)]

The above line is should not be necessary, the list entries are already unique.

bitbake/lib/toaster/toastergui/views.py if True:

Quoted 4 lines
bitbake/lib/toaster/toastergui/views.py +4 -0
+
+
+        if flat:
+            list = [CustomImagePackage.objects.get(id=entry["pk"]) for

entry in list]

bitbake/lib/toaster/toastergui/views.py if True: · line 2669

Quoted 8 lines
bitbake/lib/toaster/toastergui/views.py +1 -0
+        return list
 
     @xhr_response
     def xhr_customrecipe_packages(request, recipe_id, package_id):
@@ -2606,15 +2667,10 @@ if True:
                 )
 
                 # Reverse dependencies which are needed by packages

that are

bitbake/lib/toaster/toastergui/views.py if True: · line 2610

Quoted 2 lines
bitbake/lib/toaster/toastergui/views.py +0 -2
-                # in the image
-                reverse_deps =

package.package_dependencies_target.annotate(

bitbake/lib/toaster/toastergui/views.py if True:

Quoted 8 lines
bitbake/lib/toaster/toastergui/views.py +1 -7
-                    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,

Quoted 7 lines
bitbake/lib/toaster/toastergui/views.py +3 -0
+                # not just immediate dependents.
+                reverse_deps = _get_all_dependents(
+                    package_id, all_current_packages, flat=False)
                 total_size_deps = 0
                 total_size_reverse_deps = 0
 

bitbake/lib/toaster/toastergui/views.py if True: · line 2722

Quoted 9 lines
bitbake/lib/toaster/toastergui/views.py +5 -0
@@ -2658,6 +2714,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

bitbake/lib/toaster/toastergui/views.py if True: · line 2671

Quoted 7 lines
bitbake/lib/toaster/toastergui/views.py +0 -1
                 # as a result of appending this package.
                 # TODO this should recurse down the entire deps tree
@@ -2668,11 +2729,12 @@ if True:
 
                         recipe.includes_set.add(cust_package)
                         try:
-                            # when adding the pre-requisite package

make sure it's not

bitbake/lib/toaster/toastergui/views.py

Quoted 3 lines

in the

bitbake/lib/toaster/toastergui/views.py +1 -1
-                            #   excluded list from a prior removal.
+                            # When adding the pre-requisite package,

make

bitbake/lib/toaster/toastergui/views.py if True:

Quoted 5 lines
bitbake/lib/toaster/toastergui/views.py +2 -1
+                            # 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

Quoted 1 line

+ # Don't care if the package had never been

excluded

Quoted 3 lines

pass
except:
logger.warning("Could not add package's

suggested"

Quoted 9 lines
bitbake/lib/toaster/toastergui/views.py +5 -0
@@ -2688,6 +2750,18 @@ if True:
                     recipe.excludes_set.add(package)
                 else:
                     recipe.appends_set.remove(package)
+                all_current_packages = recipe.get_all_packages()
+                reverse_deps = _get_all_dependents(
+                    package.pk, all_current_packages, flat=True)
+                for r in reverse_deps:
+                    try:

bitbake/lib/toaster/toastergui/views.py if True: · line 2767

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +7 -0
+                        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"}

Quoted 2 lines

--
1.9.1

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
#8 lore raw

Re: [PATCH 3/3] toaster: get all dependents for pkg for removal

In reply to Dave Lerner

Thanks for this, Dave. My comments are inline below.

NB I have just done a code review, and haven't actually run the code.

Quoted 48 lines · Dave Lerner

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 | 98
+++++++++++++++++++++++++++++----
 1 file changed, 86 insertions(+), 12 deletions(-)
bitbake/lib/toaster/toastergui/views.py +1 -0
index 85ca9be..4442d33 100755
@@ -2538,6 +2538,67 @@ if True:
 
         return response
 
+    def _traverse_dependents(next_package_id, list, all_current_packages,

tree_level):

bitbake/lib/toaster/toastergui/views.py +13 -0
+        """
+        Recurse through dependents (reverse dependency) tree up to a
+        depth of MAX_DEPENDENCY_TREE_DEPTH just in case their are circular
+        dependencies. A large system has 500 packages, exceeding a
+        dependency chain that long is unlikely.
+        Don't scan for dependencies for a package already in list.
+        Return the updated list with new dependencies.
+        """
+        MAX_DEPENDENCY_TREE_DEPTH = 500
+        if tree_level >= MAX_DEPENDENCY_TREE_DEPTH:
+            logger.warning(
+                "The number of dependents in the dependency tree"
+                "for this package exceeds " +

MAX_DEPENDENDENCY_TREE_DEPTH +

bitbake/lib/toaster/toastergui/views.py if True: · line 2556

Quoted 2 lines
bitbake/lib/toaster/toastergui/views.py +2 -0
+                " and the remaining dependents will not be removed")
+            return list, True

This makes me a bit nervous, but I'm not sure if there's a better way to deal with it.

Could we reduce the maximum depth of the tree, e.g. set it to the smaller of 500 or len(all_current_packages)? (I'm not sure what all_current_packages has in it, but if it means all packages in the image, then the max depth of a genuine dependency chain would be equal to the number of packages - 1.)

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +9 -0
+
+        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)

bitbake/lib/toaster/toastergui/views.py if True: · line 2575

Quoted 10 lines
bitbake/lib/toaster/toastergui/views.py +10 -0
+            )
+
+        truncated = False
+        for pkg in dependents:
+            if pkg in list:
+                # already seen, skip dependent search
+                continue
+
+            list.append(pkg)
+            extension, truncated = _traverse_dependents(

I was slightly confused by the use of extension, then realised that it's not actually used for anything. Maybe a comment there to that effect?

I'm also not 100% sure about the structure of this, as the method is being used in two modes, each of which only cares about one of the return values; and the value we're actually interested in is an argument which is being updated in place. Though I can't think of a better alternative right now.

bitbake/lib/toaster/toastergui/views.py if True: · line 2580

Quoted 5 lines
bitbake/lib/toaster/toastergui/views.py +5 -0
+                pkg["pk"], list, all_current_packages, tree_level+1)
+            if truncated:
+                break
+
+        return list, truncated

+

bitbake/lib/toaster/toastergui/views.py if True: · line 2590

Quoted 11 lines
bitbake/lib/toaster/toastergui/views.py +6 -0
+    def _get_all_dependents(package_id, all_current_packages, flat):
+        """
+        Returns the full list of dependents, also known as reverse
+        dependencies, for package_id, recursing through dependency
+        relationships.
+        Returns either list of dictionary items or a list of

CustomImagePackage

bitbake/lib/toaster/toastergui/views.py +3 -0
+        model objects depending on arg flat=False
+        """
+        import itertools

My preference would be for all imports to be at the top of the file.

bitbake/lib/toaster/toastergui/views.py if True: · line 2593

Quoted 4 lines
bitbake/lib/toaster/toastergui/views.py +3 -0
+        list = []
+        list, truncated = _traverse_dependents(
+            package_id, list, all_current_packages, 0)

Rather than pass 0 and [] here, I would change the signature of _traverse_dependents to:

def _traverse_dependents(next_package_id, all_current_packages, list=[], tree_level=0):

Then call it here with:

        list, truncated = _traverse_dependents(
            package_id, all_current_packages)

+

bitbake/lib/toaster/toastergui/views.py if True: · line 2597

Quoted 4 lines
bitbake/lib/toaster/toastergui/views.py +3 -0
+        # sort and remove duplicates
+        sortedlist = sorted(list, key=lambda x: x["name"])
+        list = [x[0] for x in itertools.groupby(sortedlist)]

(This is the line you marked as unnecessary, as the list already contains unique elements.)

Quoted 5 lines
bitbake/lib/toaster/toastergui/views.py +3 -0
+
+        if flat:
+            list = [CustomImagePackage.objects.get(id=entry["pk"]) for

entry in list]

Could this be done with one query, e.g.

if flat:
ids = [entry['pk'] for entry in list]
list = list(CustomImagePackage.objects.filter(id__in=ids))

?

Otherwise we run a query for each entry in the list.

By the way, is the cast to list necessary, as the queryset is iterable and countable?

I suggest changing the variable name "list" to something else, too.

Quoted 87 lines
bitbake/lib/toaster/toastergui/views.py +1 -0
+        return list
 
     @xhr_response
     def xhr_customrecipe_packages(request, recipe_id, package_id):
@@ -2606,15 +2667,10 @@ if True:
                 )
 
                 # Reverse dependencies which are needed by packages that

are

bitbake/lib/toaster/toastergui/views.py +0 -2
-                # in the image
-                reverse_deps =

package.package_dependencies_target.annotate(

bitbake/lib/toaster/toastergui/views.py +9 -7
-                    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, flat=False)
                 total_size_deps = 0
                 total_size_reverse_deps = 0
@@ -2658,6 +2714,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
bitbake/lib/toaster/toastergui/views.py +0 -1
@@ -2668,11 +2729,12 @@ if True:
 
                         recipe.includes_set.add(cust_package)
                         try:
-                            # when adding the pre-requisite package make

sure it's not in the

bitbake/lib/toaster/toastergui/views.py +3 -2
-                            #   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"

bitbake/lib/toaster/toastergui/views.py +12 -0
@@ -2688,6 +2750,18 @@ if True:
                     recipe.excludes_set.add(package)
                 else:
                     recipe.appends_set.remove(package)
+                all_current_packages = recipe.get_all_packages()
+                reverse_deps = _get_all_dependents(
+                    package.pk, all_current_packages, flat=True)
+                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"}
--
1.9.1

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
#9 lore raw

Re: [PATCH 3/3] toaster: get all dependents for pkg for removal

On 16 March 2016 at 18:25, Smith, Elliot <[email protected]> wrote:
...

Quoted 8 lines

I was slightly confused by the use of extension, then realised that it's not actually used for anything. Maybe a comment there to that effect?

I'm also not 100% sure about the structure of this, as the method is being used in two modes, each of which only cares about one of the return values; and the value we're actually interested in is an argument which is being updated in place. Though I can't think of a better alternative right now.

As a colleague pointed out, the Python convention is to use _ for unused variables, e.g.

_, truncated = _traverse_dependents(...)

Elliot

Quoted 169 lines

bitbake/lib/toaster/toastergui/views.py if True: · line 2580

Quoted 7 lines
bitbake/lib/toaster/toastergui/views.py +5 -0
+                pkg["pk"], list, all_current_packages, tree_level+1)
+            if truncated:
+                break
+
+        return list, truncated

+

bitbake/lib/toaster/toastergui/views.py if True: · line 2590

Quoted 11 lines
bitbake/lib/toaster/toastergui/views.py +6 -0
+    def _get_all_dependents(package_id, all_current_packages, flat):
+        """
+        Returns the full list of dependents, also known as reverse
+        dependencies, for package_id, recursing through dependency
+        relationships.
+        Returns either list of dictionary items or a list of

CustomImagePackage

bitbake/lib/toaster/toastergui/views.py +3 -0
+        model objects depending on arg flat=False
+        """
+        import itertools

My preference would be for all imports to be at the top of the file.

bitbake/lib/toaster/toastergui/views.py if True: · line 2593

Quoted 4 lines
bitbake/lib/toaster/toastergui/views.py +3 -0
+        list = []
+        list, truncated = _traverse_dependents(
+            package_id, list, all_current_packages, 0)

Rather than pass 0 and [] here, I would change the signature of _traverse_dependents to:

def _traverse_dependents(next_package_id, all_current_packages, list=[], tree_level=0):

Then call it here with:

        list, truncated = _traverse_dependents(
            package_id, all_current_packages)

+

bitbake/lib/toaster/toastergui/views.py if True: · line 2597

Quoted 4 lines
bitbake/lib/toaster/toastergui/views.py +3 -0
+        # sort and remove duplicates
+        sortedlist = sorted(list, key=lambda x: x["name"])
+        list = [x[0] for x in itertools.groupby(sortedlist)]

(This is the line you marked as unnecessary, as the list already contains unique elements.)

Quoted 5 lines
bitbake/lib/toaster/toastergui/views.py +3 -0
+
+        if flat:
+            list = [CustomImagePackage.objects.get(id=entry["pk"]) for

entry in list]

Could this be done with one query, e.g.

if flat:
ids = [entry['pk'] for entry in list]
list = list(CustomImagePackage.objects.filter(id__in=ids))

?

Otherwise we run a query for each entry in the list.

By the way, is the cast to list necessary, as the queryset is iterable and countable?

I suggest changing the variable name "list" to something else, too.

Quoted 83 lines
bitbake/lib/toaster/toastergui/views.py +1 -0
+        return list
 
     @xhr_response
     def xhr_customrecipe_packages(request, recipe_id, package_id):
@@ -2606,15 +2667,10 @@ if True:
                 )
 
                 # Reverse dependencies which are needed by packages that

are

(quoted diff) +0 -2
-                # in the image
-                reverse_deps =

package.package_dependencies_target.annotate(

bitbake/lib/toaster/toastergui/views.py +1 -7
-                    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,

bitbake/lib/toaster/toastergui/views.py +8 -0
+                # not just immediate dependents.
+                reverse_deps = _get_all_dependents(
+                    package_id, all_current_packages, flat=False)
                 total_size_deps = 0
                 total_size_reverse_deps = 0
@@ -2658,6 +2714,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
bitbake/lib/toaster/toastergui/views.py +0 -1
@@ -2668,11 +2729,12 @@ if True:
 
                         recipe.includes_set.add(cust_package)
                         try:
-                            # when adding the pre-requisite package make

sure it's not in the

bitbake/lib/toaster/toastergui/views.py +3 -2
-                            #   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"

bitbake/lib/toaster/toastergui/views.py +12 -0
@@ -2688,6 +2750,18 @@ if True:
                     recipe.excludes_set.add(package)
                 else:
                     recipe.appends_set.remove(package)
+                all_current_packages = recipe.get_all_packages()
+                reverse_deps = _get_all_dependents(
+                    package.pk, all_current_packages, flat=True)
+                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"}
--
1.9.1

Quoted 6 lines

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

--
Elliot Smith
Software Engineer
Intel Open Source Technology Centre

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
#10 lore raw

Re: [PATCH 3/3] toaster: get all dependents for pkg for removal

In reply to Smith, Elliot

Hi Elliot,

All but two recommendations implemented - see inline.
v1 vs v2 is attached to this email. The complete v2 will be sent out separately.

Thanks for the helpful review,
Dave

Quoted 65 lines

-----Original Message-----
From: Smith, Elliot [mailto:[email protected]]
Sent: Wednesday, March 16, 2016 1:26 PM
To: Lerner, Dave
Cc: [email protected]; Belen Barros Pena (Intel); WOOD, MICHAEL
Subject: Re: [Toaster] [PATCH 3/3] toaster: get all dependents for pkg for removal

Thanks for this, Dave. My comments are inline below.

NB I have just done a code review, and haven't actually run the code.

On 11 March 2016 at 16:29, Dave Lerner <[email protected]> wrote:

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 | 98 +++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 12 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/views.py
b/bitbake/lib/toaster/toastergui/views.py

	index 85ca9be..4442d33 100755
	--- a/bitbake/lib/toaster/toastergui/views.py
	+++ b/bitbake/lib/toaster/toastergui/views.py
	@@ -2538,6 +2538,67 @@ if True:

	         return response

	+    def _traverse_dependents(next_package_id, list, all_current_packages,
tree_level):
	+        """
	+        Recurse through dependents (reverse dependency) tree up to a
	+        depth of MAX_DEPENDENCY_TREE_DEPTH just in case their are circular
	+        dependencies. A large system has 500 packages, exceeding a
	+        dependency chain that long is unlikely.
	+        Don't scan for dependencies for a package already in list.
	+        Return the updated list with new dependencies.
	+        """
	+        MAX_DEPENDENCY_TREE_DEPTH = 500
	+        if tree_level >= MAX_DEPENDENCY_TREE_DEPTH:

+ logger.warning(
+ "The number of dependents in the dependency tree"
+ "for this package exceeds " + MAX_DEPENDENDENCY_TREE_DEPTH +
+ " and the remaining dependents will not be removed")
+ return list, True

Quoted 6 lines

This makes me a bit nervous, but I'm not sure if there's a better way to deal with it.

Could we reduce the maximum depth of the tree, e.g. set it to the smaller of 500 or len(all_current_packages)? (I'm not sure what all_current_packages has in it, but if it means all packages in the image, then the max depth of a genuine dependency chain would be equal to the number of packages - 1.)

Good idea, fixed.

Quoted 23 lines

+
+ 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)
+ )
+
+ truncated = False
+ for pkg in dependents:
+ if pkg in list:
+ # already seen, skip dependent search
+ continue
+
+ list.append(pkg)
+ extension, truncated = _traverse_dependents(

Quoted 2 lines

I was slightly confused by the use of extension, then realised that it's not actually used for anything. Maybe a comment there to that effect?

Sorry for the confusion, cruft got left in from the first implementation of the function that appended trees rather than single packages. Now 'extension' is removed, only one variable returned, what was formerly written to 'truncated'.

Quoted 11 lines

I'm also not 100% sure about the structure of this, as the method is being used in two modes, each of which only cares about one of the return values; and the value we're actually interested in is an argument which is being updated in place. Though I can't think of a better alternative right now.

+ pkg["pk"], list, all_current_packages, tree_level+1)
+ if truncated:
+ break
+
+ return list, truncated

Only one value returned, and a return of True, is the flag to exit the scan.

Quoted 13 lines

+
+ def _get_all_dependents(package_id, all_current_packages, flat):
+ """
+ Returns the full list of dependents, also known as reverse
+ dependencies, for package_id, recursing through dependency
+ relationships.
+ Returns either list of dictionary items or a list of CustomImagePackage
+ model objects depending on arg flat=False
+ """
+ import itertools

Quoted 2 lines

My preference would be for all imports to be at the top of the file.

Done

Quoted 8 lines

+ list = []
+ list, truncated = _traverse_dependents(
+ package_id, list, all_current_packages, 0)

Rather than pass 0 and [] here, I would change the signature of _traverse_dependents to:

Quoted 8 lines

def _traverse_dependents(next_package_id, all_current_packages, list=[], tree_level=0):

Then call it here with:

        list, truncated = _traverse_dependents(
            package_id, all_current_packages)

I'd rather not declare the returned reverse dependency in the signature. Because I've changed the _traverse function so that only one parameter is returned, the exit early flag, shown above as the poorly named 'truncated'. The referenced reverse dependencies list then must be explicitly passed in so that the caller can see it. This seems cleaner than returning two values, one of which is ignored during the recursion, which as you noted is confusing and requires a comment, because just for declaring the empty reverse_package list in the signature. The resulting code looks much cleaner to me. Look for the V2 patch.

Quoted 11 lines

+
+ # sort and remove duplicates
+ sortedlist = sorted(list, key=lambda x: x["name"])
+ list = [x[0] for x in itertools.groupby(sortedlist)]

(This is the line you marked as unnecessary, as the list already contains unique elements.)

Removed.

Quoted 9 lines

+
+ if flat:
+ list = [CustomImagePackage.objects.get(id=entry["pk"]) for entry in
list]

Could this be done with one query, e.g.

Quoted 7 lines

if flat:
ids = [entry['pk'] for entry in list]
list = list(CustomImagePackage.objects.filter(id__in=ids))

?

By the way, is the cast to list necessary, as the queryset is iterable and countable?

Within xhr_customrecipe_packages(), the new recursive call replaces two queries, each requiring a slightly different list:
1) to populate the modal dialog, a list of dictionaries with annotated field names, not model instances,
2) to apply removing the packages from the database, a list of model instances.

I've simplified _get_all_dependents and reduced coupling to always return the first format, list of dictionaries, and changed the code in the caller when model instances are needed, getting them with your more efficient query.

Quoted 5 lines

I suggest changing the variable name "list" to something else, too.

+ return list

Fixed, renamed to rev_deps.

Quoted 83 lines

@xhr_response
def xhr_customrecipe_packages(request, recipe_id, package_id):
@@ -2606,15 +2667,10 @@ 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, flat=False)
total_size_deps = 0
total_size_reverse_deps = 0

@@ -2658,6 +2714,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 +2729,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 +2750,18 @@ if True:
recipe.excludes_set.add(package)
else:
recipe.appends_set.remove(package)
+ all_current_packages = recipe.get_all_packages()
+ reverse_deps = _get_all_dependents(
+ package.pk, all_current_packages, flat=True)
+ 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"}
--
1.9.1

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Quoted 5 lines

--

Elliot Smith
Software Engineer
Intel Open Source Technology Centre

V1 versus V2 changes. V2 patch and RR will be sent separately
==============================================================
commit f4555f162bd116ef1438123ee0bde5c850111145

Author: Dave Lerner <[email protected]>
Date:   Thu Mar 17 08:16:19 2016 -0500

toaster: recursive package dependency removal

Clean up per code review.

[Yocto #9151]

bitbake/lib/toaster/toastergui/views.py +35 -42
index 4442d33..9944c8d 100755
@@ -2538,22 +2538,27 @@ if True:
 
         return response
 
-    def _traverse_dependents(next_package_id, list, all_current_packages, tree_level):
+    def _traverse_dependents(next_package_id, rev_deps, all_current_packages, tree_level=0):
         """
-        Recurse through dependents (reverse dependency) tree up to a
-        depth of MAX_DEPENDENCY_TREE_DEPTH just in case their are circular
-        dependencies. A large system has 500 packages, exceeding a
-        dependency chain that long is unlikely.
-        Don't scan for dependencies for a package already in list.
-        Return the updated list with new dependencies.
+        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 = 500
-        if tree_level >= MAX_DEPENDENCY_TREE_DEPTH:
+        max_dependency_tree_depth = all_current_packages.count()
+        if tree_level >= max_dependency_tree_depth:
             logger.warning(
-                "The number of dependents in the dependency tree"
-                "for this package exceeds " + MAX_DEPENDENDENCY_TREE_DEPTH +
-                " and the remaining dependents will not be removed")
-            return list, True
+                "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 = \
@@ -2565,40 +2570,28 @@ if True:
                 ~Q(pk__in=all_current_packages)
             )
 
-        truncated = False
         for pkg in dependents:
-            if pkg in list:
+            if pkg in rev_deps:
                 # already seen, skip dependent search
                 continue
 
-            list.append(pkg)
-            extension, truncated = _traverse_dependents(
-                pkg["pk"], list, all_current_packages, tree_level+1)
-            if truncated:
-                break
+            rev_deps.append(pkg)
+            if (_traverse_dependents(
+                pkg["pk"], rev_deps, all_current_packages, tree_level+1)):
+                return True
 
-        return list, truncated
+        return False
 
-    def _get_all_dependents(package_id, all_current_packages, flat):
+    def _get_all_dependents(package_id, all_current_packages):
         """
-        Returns the full list of dependents, also known as reverse
-        dependencies, for package_id, recursing through dependency
+        Returns sorted list of recursive reverse dependencies for package_id,
+        as a list of dictionary items, by recursing through dependency
         relationships.
-        Returns either list of dictionary items or a list of CustomImagePackage
-        model objects depending on arg flat=False
         """
-        import itertools
-        list = []
-        list, truncated = _traverse_dependents(
-            package_id, list, all_current_packages, 0)
-
-        # sort and remove duplicates
-        sortedlist = sorted(list, key=lambda x: x["name"])
-        list = [x[0] for x in itertools.groupby(sortedlist)]
-
-        if flat:
-            list = [CustomImagePackage.objects.get(id=entry["pk"]) for entry in list]
-        return list
+        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):
@@ -2669,8 +2662,7 @@ if True:
                 # Reverse dependencies which are needed by packages that are
                 # in the image. Recursive search providing all dependents,
                 # not just immediate dependents.
-                reverse_deps = _get_all_dependents(
-                    package_id, all_current_packages, flat=False)
+                reverse_deps = _get_all_dependents(package_id, all_current_packages)
                 total_size_deps = 0
                 total_size_reverse_deps = 0
 
@@ -2751,8 +2743,9 @@ if True:
                 else:
                     recipe.appends_set.remove(package)
                 all_current_packages = recipe.get_all_packages()
-                reverse_deps = _get_all_dependents(
-                    package.pk, all_current_packages, flat=True)
+                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:
#11 lore raw
In reply to Dave Lerner
Quoted 6 lines · On 11/03/2016 16:29, "[email protected] on behalf of Dave…

Target Branch: toaster-next, master
Contrib Branch: poky-contrib/dlerner/9121-delete-dependent-package-tree

Defect: 9121
Summary: Show and remove direct and indirect dependents when removing package

This seems to be working for me. Only one small note below about one of the test cases.

The other thing we might change is the notification message. Apologies: I realise this was not covered in the design document I attached to Bugzilla.

* In the dialog we use the expression "reverse dependencies". We know is not perfect as expressions go, but it is used consistently across Toaster. The notification message, however, uses the word "dependents" instead. I think we should also use "reverse dependencies" there so that we are consistently awful ;) So we would say something like:

"You have removed 3 packages from <custom-image-name>: libpcre and it's 2 reverse dependencies"

Or

"You have removed 2 packages from <custom-image-name>: libpcre and its reverse dependency"

* When you add a package we show the dependency names. I think we should do the same when removing reverse dependencies. Obviously, we need to set some kind of limit (we can't really list 39 packages). But often we will be dealing with 2 to 5 packages, and in those cases it is useful I think to show the names. So we would say something like:

"You have removed 3 packages from <custom-image-name>: libpcre and its reverse dependencies atk and glib-2.0"

In any case, this should not stop merging these patches: it's a minor issue, and we can make the changes later on.

Quoted 12 lines

CASE Test no interference removing from a 2nd custom image in project
----------------------------------------------------------------------
New custom-image based on core-image-sato 'myminimal'
Build it
Add atk which is dependent on glib-2.0, libffi, libpcre Build myminimal again.
Verify that atk, libffi, libpcre, glib-2.0 have files in the file system For custom image myminimal, enter libpcre, remove package
Verify modal dlg notes atk and glib-2.0 will be removed Remove
Build
Verify atk, glib2.0 libffi are removed.

This is probably a typo, but just in case: after building, atk, glib2.0 and libpcre were removed. libffi was not removed, neither before nor after the build, but it was not mentioned in the dialog either when removing libpcre, so from the outside it looks like Toaster did the right thing.

Thanks!

Belén

Quoted 6 lines
Signature · 5 lines
-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster
#12 lore raw

Hi Belen,

Per your comments, I won't submit a version 2.

Regarding something that you wanted checked...

Quoted 4 lines

This is probably a typo, but just in case: after building, atk, glib2.0 and libpcre were removed. libffi was not removed, neither before nor after the build, but it was not mentioned in the dialog either when removing libpcre, so from the outside it looks like Toaster did the right thing.

You were right, it was a typo, libpcre does not have libffi as a direct or indirect reverse dependency.

Thanks,
Dave

Quoted 82 lines

-----Original Message-----
From: Barros Pena, Belen [mailto:[email protected]]
Sent: Monday, March 14, 2016 11:18 AM
To: Lerner, Dave; [email protected]
Subject: Re: [Toaster] Review Request: 9121 Remove direct/indirect dependents of a package

Quoted 6 lines · On 11/03/2016 16:29, "[email protected] on behalf of Dave…

Target Branch: toaster-next, master
Contrib Branch: poky-contrib/dlerner/9121-delete-dependent-package-tree

Defect: 9121
Summary: Show and remove direct and indirect dependents when removing package

This seems to be working for me. Only one small note below about one of the test cases.

The other thing we might change is the notification message. Apologies: I realise this was not covered in the design document I attached to Bugzilla.

* In the dialog we use the expression "reverse dependencies". We know is not perfect as expressions go, but it is used consistently across Toaster. The notification message, however, uses the word "dependents" instead. I think we should also use "reverse dependencies" there so that we are consistently awful ;) So we would say something like:

"You have removed 3 packages from <custom-image-name>: libpcre and it's 2 reverse dependencies"

Or

"You have removed 2 packages from <custom-image-name>: libpcre and its reverse dependency"

* When you add a package we show the dependency names. I think we should do the same when removing reverse dependencies. Obviously, we need to set some kind of limit (we can't really list 39 packages). But often we will be dealing with 2 to 5 packages, and in those cases it is useful I think to show the names. So we would say something like:

"You have removed 3 packages from <custom-image-name>: libpcre and its reverse dependencies atk and glib-2.0"

In any case, this should not stop merging these patches: it's a minor issue, and we can make the changes later on.

Quoted 12 lines

CASE Test no interference removing from a 2nd custom image in project
----------------------------------------------------------------------
New custom-image based on core-image-sato 'myminimal'
Build it
Add atk which is dependent on glib-2.0, libffi, libpcre Build myminimal again.
Verify that atk, libffi, libpcre, glib-2.0 have files in the file system For custom image myminimal, enter libpcre, remove package
Verify modal dlg notes atk and glib-2.0 will be removed Remove
Build
Verify atk, glib2.0 libffi are removed.

This is probably a typo, but just in case: after building, atk, glib2.0 and libpcre were removed. libffi was not removed, neither before nor after the build, but it was not mentioned in the dialog either when removing libpcre, so from the outside it looks like Toaster did the right thing. Thanks!

Belén

Quoted 6 lines

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster