The following commit has been merged in the master branch:
commit 00ae46fa208194feb36bdced907ec8b7a8d62f3f
Author: Raphaël Hertzog <[email protected]>
Date: Wed Mar 2 12:13:38 2011 +0100
Dpkg::Path::get_control_path(): wrapper around dpkg-query --control-path
Sponsored-by: Linaro Limited
diff --git a/debian/changelog b/debian/changelog
index 54fa91b..950eb17 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -56,6 +56,8 @@ dpkg (1.16.0) UNRELEASED; urgency=low
directory.
* Apply patch from Colin Watson to let dpkg-buildflags return -O3
instead of -O2 when building ppc64 packages on Ubuntu. Closes: #612472
+ * Add new function get_control_path() to Dpkg::Path, it wraps dpkg-query
+ --control-path.
[ Jonathan Nieder ]
* Remove support for use of synchronous sync(2), due to its pernicious
diff --git a/scripts/Dpkg/Path.pm b/scripts/Dpkg/Path.pm
index 4705b07..b962eab 100644
--- a/scripts/Dpkg/Path.pm
+++ b/scripts/Dpkg/Path.pm
@@ -1,4 +1,5 @@
-# Copyright © 2007 Raphaël Hertzog <[email protected]>
+# Copyright © 2007-2011 Raphaël Hertzog <[email protected]>
+# Copyright © 2011 Linaro Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,14 +19,17 @@ package Dpkg::Path;
use strict;
use warnings;
-our $VERSION = "1.01";
+our $VERSION = "1.02";
use base qw(Exporter);
use File::Spec;
use Cwd qw(realpath);
+use Dpkg::IPC;
+
our @EXPORT_OK = qw(get_pkg_root_dir relative_to_pkg_root
guess_pkg_root_dir check_files_are_the_same
- resolve_symlink canonpath find_command);
+ resolve_symlink canonpath find_command
+ get_control_path);
=encoding utf8
@@ -211,6 +215,32 @@ sub find_command($) {
return undef;
}
+=item my $control_file = get_control_path($pkg, $filetype)
+
+Return the path of the control file of type $filetype for the given
+package.
+
+=item my @control_files = get_control_path($pkg)
+
+Return the path of all available control files for the given package.
+
+=cut
+
+sub get_control_path($;$) {
+ my ($pkg, $filetype) = @_;
+ my $control_file;
+ my @exec = ("dpkg-query", "--control-path", $pkg);
+ push @exec, $filetype if defined $filetype;
+ spawn(exec => \@exec, wait_child => 1, to_string => \$control_file);
+ chomp($control_file);
+ if (defined $filetype) {
+ return undef if $control_file eq "";
+ return $control_file;
+ }
+ return () if $control_file eq "";
+ return split(/\n/, $control_file);
+}
+
=back
=head1 AUTHOR
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]