Wishlist: dpkg lists configfiles
Hi,
I don't think dpkg already has this feature, but wouldn't it be
interesting to give dpkg an option to show all the configuration files
that belong to a specific package. (Like rpm -qc)
I'know that the configfiles that belong to a package are kept in a
file (/var/lib/dpkg/info/<pkgn>.conffiles)
Also dpkg -s <pkg> will show the conffiles but this gives a lot more
(extra) information.
I already wrote a small poc/patch to show what I mean, but since i'am
not very familiar with the dpkg-code I think someone with better programming-skills
needs to rewrite it.
This patch was written on dpkg-1.10.28
$ ./dpkg-query -h
Usage: dpkg-query [<option>] <command>
Commands:
-s|--status <package-name> ... display package status details
-p|--print-avail <package-name> ... display available version details
-F|--listconf <package-name> list config files `owned' by a package
...
$ ./dpkg-query -F apache
/etc/init.d/apache
/etc/logrotate.d/apache
Kind regards,
Leo
--
------------------------------------------------------------------------
Leo Eraly Kangaroot Linux Solutions
System Adminstrator / Developer Grote Steenweg 91
leo@kangaroot.net 2600 Berchem
Tel: +32 3 286 17 10 Belgium
Fax: +32 3 281 23 49
PGP/GnuPG key: 1024D/F05EED4E
Key available at wwwkeys.pgp.net
------------------------- http://www.kangaroot.net ---------------------
diff -urN dpkg-1.10.28/main/main.c dpkg-1.10.28-test/main/main.c
--- dpkg-1.10.28/main/main.c 2004-11-11 04:16:33.000000000 +0100
+++ dpkg-1.10.28-test/main/main.c 2005-08-15 12:26:16.000000000 +0200
@@ -71,6 +71,7 @@
dpkg -s|--status <package-name> ... display package status details\n\
dpkg -p|--print-avail <package-name> ... display available version details\n\
dpkg -L|--listfiles <package-name> ... list files `owned' by package(s)\n\
+ dpkg -F|--listconf <package-name> list config files `owned' by package\n\
dpkg -l|--list [<pattern> ...] list packages concisely\n\
dpkg -S|--search <pattern> ... find package(s) owning file(s)\n\
dpkg -C|--audit check for broken package(s)\n\
@@ -378,6 +379,7 @@
ACTION( "yet-to-unpack", 0, act_unpackchk, unpackchk ),
ACTIONBACKEND( "list", 'l', DPKGQUERY),
ACTIONBACKEND( "search", 'S', DPKGQUERY),
+ ACTIONBACKEND( "listconf", 'F' , DPKGQUERY),
ACTION( "print-architecture", 0, act_printarch, printarch ),
ACTION( "print-gnu-build-architecture", 0, act_printgnuarch, printarch ),
ACTION( "assert-support-predepends", 0, act_assertpredep, assertpredep ),
diff -urN dpkg-1.10.28/main/main.h dpkg-1.10.28-test/main/main.h
--- dpkg-1.10.28/main/main.h 2004-11-11 04:16:33.000000000 +0100
+++ dpkg-1.10.28-test/main/main.h 2005-08-15 12:26:16.000000000 +0200
@@ -50,7 +50,7 @@
enum action { act_unset, act_install, act_unpack, act_avail, act_configure,
act_remove, act_purge, act_listpackages, act_avreplace, act_avmerge,
- act_unpackchk, act_status, act_searchfiles, act_audit, act_listfiles,
+ act_unpackchk, act_status, act_searchfiles, act_audit, act_listfiles, act_listconf,
act_assertpredep, act_printarch, act_predeppackage, act_cmpversions,
act_printinstarch, act_compareversions, act_printavail, act_avclear,
act_forgetold, act_getselections, act_setselections, act_printgnuarch,
diff -urN dpkg-1.10.28/main/query.c dpkg-1.10.28-test/main/query.c
--- dpkg-1.10.28/main/query.c 2004-11-11 04:16:33.000000000 +0100
+++ dpkg-1.10.28-test/main/query.c 2005-08-15 12:26:16.000000000 +0200
@@ -240,6 +240,31 @@
return found + (namenode->divert ? 1 : 0);
}
+void listconf(const char *const *argv)
+{
+ struct pkginfo *pkg;
+ struct pkginfoperfile *pif;
+ struct conffile *cf;
+
+ if(!*argv)
+ badusage(_("--listconf needs a package name"));
+
+ modstatdb_init(admindir,msdbrw_readonly);
+
+ pkg = findpackage(*argv);
+
+ if(pkg) {
+ pif = &pkg->installed;
+ cf = pif->conffiles;
+ while(cf)
+ {
+ printf("%s\n" , cf->name);
+ cf = cf->next;
+ }
+ }
+
+}
+
void searchfiles(const char *const *argv) {
struct filenamenode *namenode;
struct fileiterator *it;
@@ -450,6 +475,7 @@
Commands:\n\
-s|--status <package-name> ... display package status details\n\
-p|--print-avail <package-name> ... display available version details\n\
+ -F|--listconf <package-name> list config files `owned' by a package\n\
-L|--listfiles <package-name> ... list files `owned' by package(s)\n\
-l|--list [<pattern> ...] list packages concisely\n\
-W|--show <pattern> ... show information on package(s)\n\
@@ -518,6 +544,7 @@
{ longopt, shortopt, 0,0,0, setobsolete, 0, 0, 0 }
ACTION( "listfiles", 'L', act_listfiles, enqperpackage ),
+ ACTION( "listconf", 'F', act_listconf, listconf ),
ACTION( "status", 's', act_status, enqperpackage ),
ACTION( "print-avail", 'p', act_printavail, enqperpackage ),
ACTION( "list", 'l', act_listpackages, listpackages ),
Reply to: