improving "dpkg --list"
The patch below (against dpkg 1.9.16) provides two options that work
with --list option. Their effect is to omit packages from the list
that aren't currently installed. There are two options to pick two
different levels of "uninstalledness".
I'm not entirely happy with the choice of option names; perhaps there
are better alternatives.
While I was making this change, I noticed that "make distclean" fails
to remove */Makefile. This is a bit of a nuisance when creating the
diff.
ttfn/rjk
diff -x helpmsgs* -x TAGS -x Makefile -x *~ -ruN dpkg-1.9.16.old/main/dpkg.8 dpkg-1.9.16/main/dpkg.8
--- dpkg-1.9.16.old/main/dpkg.8 Sat May 5 11:26:49 2001
+++ dpkg-1.9.16/main/dpkg.8 Tue Aug 21 19:34:39 2001
@@ -200,6 +200,9 @@
shell wildchars are allowed in \fIpackage-name-pattern\fP. (You will
probably have to quote \fIpackage-name-pattern\fP to prevent the shell
from performing filename expansion. For example, \fBdpkg -l 'libc5*'\fP will list all the package names starting with "libc5".)
+.IP
+See also the \fB--skip-uninstalled\fP and \fB--skip-purged\fP options
+below.
.TP
\fBdpkg -s\fP | \fB--status\fP \fIpackage-name\fP ...
Report status of specified package. This just displays the entry in
@@ -463,6 +466,16 @@
\fB--status-fd \fP\fI<n>\fP
Send package status info to file descriptor \fI<n>\fP. This can be given
multiple times. Status updates are of the form `status: <pkg>: <pkg qstate>'.
+.TP
+\fB--skip-uninstalled\fP
+Show only installed packages with \fB--list\fP, excluding those which
+have only configuration files left. Packages that are not installed
+but are scheduled to be installed are shown.
+.TP
+\fB--skip-purged\fP
+Show only installed packages with \fB--list\fP, including those with
+only configuration files left. Packages that are not installed
+but are scheduled to be installed are shown.
.SH FILES
.TP
.I /etc/dpkg/dpkg.cfg
diff -x helpmsgs* -x TAGS -x Makefile -x *~ -ruN dpkg-1.9.16.old/main/enquiry.c dpkg-1.9.16/main/enquiry.c
--- dpkg-1.9.16.old/main/enquiry.c Tue Apr 24 01:42:33 2001
+++ dpkg-1.9.16/main/enquiry.c Tue Aug 21 19:21:39 2001
@@ -86,6 +86,9 @@
const char *pdesc;
static char format[80] = "";
+ if (pkg->status >= f_listlimit
+ && pkg->want >= f_listlimit)
+ return;
if (format[0]==0) {
w=getwidth()-80; /* get spare width */
if (w<0) w=0; /* lets not try to deal with terminals that are too small */
diff -x helpmsgs* -x TAGS -x Makefile -x *~ -ruN dpkg-1.9.16.old/main/main.c dpkg-1.9.16/main/main.c
--- dpkg-1.9.16.old/main/main.c Tue Apr 24 16:32:39 2001
+++ dpkg-1.9.16/main/main.c Tue Aug 21 19:13:01 2001
@@ -105,6 +105,8 @@
--force-... Override problems - see --force-help\n\
--no-force-...|--refuse-... Stop when problems encountered\n\
--abort-after <n> Abort after encountering <n> errors\n\
+ --skip-uninstalled List only installed packages\n\
+ --skip-purged List installed and removed-but-not-purged packages\n\
\n\
Comparison operators for --compare-versions are:\n\
lt le eq ne ge gt (treat no version as earlier than any version);\n\
@@ -130,6 +132,7 @@
const struct cmdinfo *cipaction= 0;
int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
int f_autodeconf=0, f_nodebsig=0;
+int f_listlimit=want_sentinel;
unsigned long f_debug=0;
/* Change fc_overwrite to 1 to enable force-overwrite by default */
int fc_downgrade=1, fc_configureany=0, fc_hold=0, fc_removereinstreq=0, fc_overwrite=0;
@@ -417,6 +420,8 @@
{ "version", 0, 0, 0, 0, versiononly },
{ "licence",/* UK spelling */ 0,0,0,0, showcopyright },
{ "license",/* US spelling */ 0,0,0,0, showcopyright },
+ { "skip-uninstalled", 0, 0, &f_listlimit, 0, 0, want_deinstall },
+ { "skip-purged", 0, 0, &f_listlimit, 0, 0, want_purge },
{ 0, 0 }
};
diff -x helpmsgs* -x TAGS -x Makefile -x *~ -ruN dpkg-1.9.16.old/main/main.h dpkg-1.9.16/main/main.h
--- dpkg-1.9.16.old/main/main.h Mon Apr 23 23:06:03 2001
+++ dpkg-1.9.16/main/main.h Tue Aug 21 19:12:34 2001
@@ -80,6 +80,7 @@
extern const struct cmdinfo *cipaction;
extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
extern int f_autodeconf, f_largemem, f_nodebsig;
+extern int f_listlimit;
extern unsigned long f_debug;
extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
Reply to: