Commit 1a60e531 authored by Guillem Jover's avatar Guillem Jover

dpkg-query: Add new --control-list and --control-show commands

These replace the now deprecated --control-path command, as these do
not rely on any specific database layout.
parent 36567121
......@@ -32,6 +32,8 @@ dpkg (1.16.5) UNRELEASED; urgency=low
* Switch source compression to xz.
* Detect ar header fields truncation due to too long member names or too
large member sizes. Closes: #678933
* Add new dpkg-query --control-list and --control-show commands, which
replace the now deprecated --control-path.
[ Updated dpkg translations ]
* Swedish (Peter Krefting).
......
......@@ -54,6 +54,14 @@ Why:
support compressing new .deb files with that format, although unpacking
will be kept being supported to handle existing compressed files.
What: --control-path (dpkg-query option)
Status: deprecated
When: 1.18.x
Warning: man page
This was a semi-public interface now superceded by --control-list and
--control-show, which are a better interface as they do not rely on any
specific database layout.
History of feature removals
~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
......@@ -107,13 +107,19 @@ by an empty line, with the same order as specified on the argument list.
However, note that files created by package-specific installation-scripts
are not listed.
.TP
.BR \-\-control\-list " \fIpackage-name\fP
List control files installed to your system from \fIpackage-name\fP.
These can be used as input arguments to \fB\-\-control\-show\fP.
.TP
.BR \-\-control\-show " \fIpackage-name\fP \fIcontrol-file\fP"
Print the \fIcontrol-file\fP installed to your system from \fIpackage-name\fP
to the standard output.
.TP
.BR \-c ", " \-\-control\-path " \fIpackage-name\fP [\fIcontrol-file\fP]"
List paths for control files installed to your system from \fIpackage-name\fP.
If \fIcontrol-file\fP is specified then only list the path for that control
file if it is present. \fBWarning\fP: this command is semi-public, it should
be used only as a last resort solution, and if no other interface is
available. It might get deprecated later on if better interfaces or the
current architectural deficiencies have been solved.
file if it is present. \fBWarning\fP: this command is deprecated, please
switch to use \fB\-\-control\-list\fP and \fB\-\-control\-show\fP instead.
.TP
.BR \-S ", " \-\-search " \fIfilename-search-pattern\fP..."
Search for packages that own files corresponding to the given pattern.
......
......@@ -75,6 +75,8 @@ enum action {
act_listfiles,
act_searchfiles,
act_controlpath,
act_controllist,
act_controlshow,
act_cmpversions,
......
......@@ -50,6 +50,7 @@
#include <dpkg/pkg-show.h>
#include <dpkg/string.h>
#include <dpkg/path.h>
#include <dpkg/file.h>
#include <dpkg/options.h>
#include "filesdb.h"
......@@ -600,6 +601,15 @@ pkg_infodb_print_filename(const char *filename, const char *filetype)
printf("%s\n", filename);
}
static void
pkg_infodb_print_filetype(const char *filename, const char *filetype)
{
if (pkg_infodb_is_internal(filetype))
return;
printf("%s\n", filetype);
}
static void
control_path_file(struct pkginfo *pkg, const char *control_file)
{
......@@ -656,6 +666,76 @@ control_path(const char *const *argv)
return 0;
}
static int
control_list(const char *const *argv)
{
struct dpkg_error err;
struct pkginfo *pkg;
const char *pkgname;
pkgname = *argv++;
if (!pkgname || *argv)
badusage(_("--%s takes one package name argument"), cipaction->olong);
modstatdb_open(msdbrw_readonly);
pkg = pkg_spec_parse_pkg(pkgname, &err);
if (pkg == NULL)
badusage(_("--%s needs a valid package name but '%.250s' is not: %s"),
cipaction->olong, pkgname, err.str);
if (pkg->status == stat_notinstalled)
ohshit(_("package '%s' is not installed"), pkg_name(pkg, pnaw_nonambig));
pkg_infodb_foreach(pkg, &pkg->installed, pkg_infodb_print_filetype);
modstatdb_shutdown();
return 0;
}
static int
control_show(const char *const *argv)
{
struct dpkg_error err;
struct pkginfo *pkg;
const char *pkgname;
const char *filename;
const char *control_file;
pkgname = *argv++;
if (!pkgname || !*argv)
badusage(_("--%s needs at two arguments"),
cipaction->olong);
control_file = *argv++;
if (!control_file || *argv)
badusage(_("--%s takes at most two arguments"), cipaction->olong);
pkg_infodb_check_filetype(control_file);
modstatdb_open(msdbrw_readonly);
pkg = pkg_spec_parse_pkg(pkgname, &err);
if (pkg == NULL)
badusage(_("--%s needs a valid package name but '%.250s' is not: %s"),
cipaction->olong, pkgname, err.str);
if (pkg->status == stat_notinstalled)
ohshit(_("package '%s' is not installed"), pkg_name(pkg, pnaw_nonambig));
if (pkg_infodb_has_file(pkg, &pkg->installed, control_file))
filename = pkg_infodb_get_file(pkg, &pkg->installed, control_file);
else
ohshit(_("control file '%s' does not exist"), control_file);
modstatdb_shutdown();
file_show(filename);
return 0;
}
static void DPKG_ATTR_NORET
printversion(const struct cmdinfo *ci, const char *value)
{
......@@ -731,6 +811,8 @@ static const struct cmdinfo cmdinfos[]= {
ACTION( "search", 'S', act_searchfiles, searchfiles ),
ACTION( "show", 'W', act_listpackages, showpackages ),
ACTION( "control-path", 'c', act_controlpath, control_path ),
ACTION( "control-list", 0, act_controllist, control_list ),
ACTION( "control-show", 0, act_controlshow, control_show ),
{ "admindir", 0, 1, NULL, &admindir, NULL },
{ "load-avail", 0, 0, &opt_loadavail, NULL, NULL, 1 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment