Followup-For: Bug #342787
Package: deborphan
Version: 1.7.23

Hi Peter,
i've also been bitten by the problem with 'provides', where redundant packages
providing the same functionality don't show up as orphans, even though only one
is really needed. At the time  i'd got around it by writing some custom script
that only took the 'Depends' field into account, which was really helpful in
identifying additional orphans.

i suggest a --ignore-provides option like the one in this patch. Even though
the packages returned in this case are only *potential* orphans, it's still
very useful in practice.

and btw, since there's already a --nice-mode, how about a --aggressive-mode
which which could stand for something like
    -n -a -p 1 --ignore-provides

Cheers
-- Matt


*** diff
--- deborphan-1.7.23.orig/doc/deborphan.1
+++ deborphan-1.7.23/doc/deborphan.1
@@ -55,10 +55,17 @@
 .SS "SEARCH MODIFIERS"
 .TP
 \fB\-n, \-\-nice\-mode\fP
-Turn off nice-mode.
+Turn OFF nice-mode.
 Nice-mode checks if there is a package `suggesting' or `recommending' the
package.
 If one is found, the package will be marked as in use, or, when
\fB\-\-show\-deps\fR is used, print out the package suggesting the package as if
it were depending on it.
 .TP
+\fB\-\-ignore\-provides\fP
+Ignore packages' `Provide' field when computing dependencies.
+Be careful when using this option: output packages may not be real orphans !
+A package will be marked as in use only if another one \fBexplicitly\fR depends
on it. If the other package depends on it only indirectly through its `provide'
field, it won't count as a dependency.
+
+This is useful to identify redundant packages providing the same functionality:
For example, many programs require 'editor'. Both vim and emacs21 provide
'editor', but only one of them is really needed to satisfy the dependency.
Without \fB\-\-ignore\-provides\fR, none of them will ever show up because both
will be considered in use. Using \fB\-\-ignore\-provides\fR, both will show up.
+.TP
 \fB-a, \-\-all\-packages\fP
 Check all the packages, instead of only those in the libs section. Best used
(if at all used) in combination with \fB\-\-priority\fR. This option implies
\fB\-\-show-section\fR.
 .\"  , when compiled with ALL_PACKAGES_IMPLY_SECTION defined (default)
--- deborphan-1.7.23.orig/src/exit.c
+++ deborphan-1.7.23/src/exit.c
@@ -102,6 +102,8 @@
     printf(_("-n        Enable checks for `recommends' and `suggests'.\n"));
 #endif

+    printf(_("--ignore-provides           Disable checks for `provide'
field.\n"));
+
     printf("--all-packages,   ");
     printf(_("-a        Compare all packages, not just libs.\n"));

--- deborphan-1.7.23.orig/src/deborphan.c
+++ deborphan-1.7.23/src/deborphan.c
@@ -114,6 +114,7 @@
        {"guess-doc", 0, 0, 16},
        {"find-config", 0, 0, 17},
        {"libdevel", 0, 0, 18},
+       {"ignore-provides", 0, 0, 19},
        {"exclude", 1, 0, 'e'},
        {0, 0, 0, 0}
     };
@@ -256,6 +257,9 @@
        case 18:
            options[SEARCH_LIBDEVEL] = 1;
            break;
+       case 19:
+           options[IGNORE_PROVIDES] = 1;
+           break;
        case 'e':
            while ( optarg ) {
                    char *c_ptr;
--- deborphan-1.7.23.orig/src/libdeps.c
+++ deborphan-1.7.23/src/libdeps.c
@@ -89,13 +89,15 @@
                continue;

        for (deps = 0; deps < package->deps_cnt && no_dep_found; deps++) {
-           for (prov = 0; prov < current_pkg->provides_cnt && no_dep_found;
-                prov++) {
-               if (pkgcmp(current_pkg->provides[prov], package->deps[deps])) {
-                   if (options[SHOW_DEPS])
-                       printf("      %s\n", package->self.name);
-                   else
-                       no_dep_found = 0;
+           if (!options[IGNORE_PROVIDES]) {
+               for (prov = 0; prov < current_pkg->provides_cnt && no_dep_found;
+                    prov++) {
+                   if (pkgcmp(current_pkg->provides[prov], 
package->deps[deps])) {
+                       if (options[SHOW_DEPS])
+                           printf("      %s\n", package->self.name);
+                       else
+                           no_dep_found = 0;
+                   }
                }
            }

--- deborphan-1.7.23.orig/include/deborphan.h
+++ deborphan-1.7.23/include/deborphan.h
@@ -105,6 +105,7 @@
      ZERO_KEEP,
      FIND_CONFIG,
      SEARCH_LIBDEVEL,
+     IGNORE_PROVIDES,
      NUM_OPTIONS /* THIS HAS TO BE THE LAST OF THIS ENUM! */
 };


Reply via email to