The following commit has been merged in the master branch:
commit 72c2242d4783ee314d7f333419839ab42c8ad6c0
Author: Guillem Jover <[email protected]>
Date: Wed Jul 18 17:05:29 2012 +0200
dpkg-parsechangelog: Add new --show-field option to print a field value
One of the most common uses of this program is to retrieve specific
field values from debian/rules file, but currently the output needs
to be filtered, which might introduce subtle bugs. This option will
make life easier for packagers, among others.
Closes: #284664
diff --git a/debian/changelog b/debian/changelog
index 970221a..f75404b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,8 @@ dpkg (1.17.0) UNRELEASED; urgency=low
* Fix clang warnings due to change of alignment requirements.
* Change copyright file to point to GPL-2 instead of GPL.
* Do not pass -e in shell script shebangs, set it in the body.
+ * Add new dpkg-parsechangelog --show-field option to print a field value.
+ Closes: #284664
-- Guillem Jover <[email protected]> Fri, 03 Aug 2012 13:21:00 +0200
diff --git a/man/dpkg-parsechangelog.1 b/man/dpkg-parsechangelog.1
index e71b01b..df5885d 100644
--- a/man/dpkg-parsechangelog.1
+++ b/man/dpkg-parsechangelog.1
@@ -19,7 +19,7 @@
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
.
-.TH dpkg\-parsechangelog 1 "2012-05-04" "Debian Project" "dpkg utilities"
+.TH dpkg\-parsechangelog 1 "2012-07-18" "Debian Project" "dpkg utilities"
.SH NAME
dpkg\-parsechangelog \- parse Debian changelog files
.
@@ -53,6 +53,10 @@ which are currently
.BR /usr/local/lib/dpkg/parsechangelog " and "
.BR /usr/lib/dpkg/parsechangelog .
.TP
+.BR \-S ", " \-\-show\-field " \fIfield\fP"
+Specifies the name of the field to show (since dpkg 1.17.0).
+The field name is not printed, only its value.
+.TP
.BR \-? ", " \-\-help
Show the usage message and exit.
.TP
diff --git a/scripts/dpkg-parsechangelog.pl b/scripts/dpkg-parsechangelog.pl
index 1dcaf9a..8b980db 100755
--- a/scripts/dpkg-parsechangelog.pl
+++ b/scripts/dpkg-parsechangelog.pl
@@ -30,6 +30,7 @@ use Dpkg::Changelog::Parse;
textdomain("dpkg-dev");
my %options;
+my $fieldname;
sub version {
printf _g("Debian %s version %s.\n"), $progname, $version;
@@ -48,6 +49,7 @@ sub usage {
-l<changelog-file> get per-version info from this file.
-F<changelog-format> force changelog format.
-L<libdir> look for changelog parsers in <libdir>.
+ -S, --show-field <field> show the values for <field>.
-?, --help show this help message.
--version show the version.")
. "\n\n" . _g(
@@ -81,6 +83,8 @@ while (@ARGV) {
$options{"changelogformat"} = $1;
} elsif (m/^-l(.+)$/) {
$options{"file"} = $1;
+ } elsif (m/^-(?:S|-show-field)(?:=(.+))?$/) {
+ $fieldname = $1 // shift(@ARGV);
} elsif (m/^--$/) {
last;
} elsif (m/^-([cfnostuv])(.*)$/) {
@@ -120,5 +124,9 @@ my $count = 0;
my @fields = changelog_parse(%options);
foreach my $f (@fields) {
print "\n" if $count++;
- print $f->output();
+ if ($fieldname) {
+ print $f->{$fieldname} . "\n";
+ } else {
+ print $f->output();
+ }
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]