Browse Source

dpkg-buildflags: new --dump action, make it the default

The --export command is useful to retrieve the compilation flags
in a shell script or in a makefile, and to export them in the environment,
but it's not well suited for parsing by another script (or even by a
human).

The new --dump option becomes the default action and prints
the flags and their values following a documented template: "flag=value".
Raphaël Hertzog 15 years ago
parent
commit
d415c388d3
3 changed files with 21 additions and 4 deletions
  1. 2 0
      debian/changelog
  2. 6 1
      man/dpkg-buildflags.1
  3. 13 3
      scripts/dpkg-buildflags.pl

+ 2 - 0
debian/changelog

@@ -69,6 +69,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     flags. Particularly useful for package maintainers who don't want
     flags. Particularly useful for package maintainers who don't want
     their supplementary flags to take precedence over user submitted
     their supplementary flags to take precedence over user submitted
     flags.
     flags.
+  * Add new --dump action to dpkg-buildflags and make it the default action.
+    Closes: #603435
 
 
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520

+ 6 - 1
man/dpkg-buildflags.1

@@ -4,7 +4,7 @@ dpkg\-buildflags \- returns build flags to use during package build
 .
 .
 .SH SYNOPSIS
 .SH SYNOPSIS
 .B dpkg\-buildflags
 .B dpkg\-buildflags
-.RI [ option "...] " command
+.RI [ option "...] [" command ]
 .
 .
 .SH DESCRIPTION
 .SH DESCRIPTION
 \fBdpkg\-buildflags\fP is a tool to retrieve compilation flags to use during
 \fBdpkg\-buildflags\fP is a tool to retrieve compilation flags to use during
@@ -43,6 +43,11 @@ The configuration files can contain comments on lines starting with a hash
 (#). Empty lines are also ignored.
 (#). Empty lines are also ignored.
 .SH COMMANDS
 .SH COMMANDS
 .TP
 .TP
+.BI \-\-dump
+Print to standard output all compilation flags and their values. It prints
+one flag per line separated from its value by an equal sign
+("\fIflag\fP=\fIvalue\fP"). This is the default action.
+.TP
 .BI \-\-list
 .BI \-\-list
 Print the list of flags supported by the current vendor
 Print the list of flags supported by the current vendor
 (one per line). See the \fBSUPPORTED FLAGS\fP section for more
 (one per line). See the \fBSUPPORTED FLAGS\fP section for more

+ 13 - 3
scripts/dpkg-buildflags.pl

@@ -2,7 +2,7 @@
 #
 #
 # dpkg-buildflags
 # dpkg-buildflags
 #
 #
-# Copyright © 2010 Raphaël Hertzog <hertzog@debian.org>
+# Copyright © 2010-2011 Raphaël Hertzog <hertzog@debian.org>
 #
 #
 # This program is free software; you can redistribute it and/or modify
 # 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
 # it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ sub version {
     printf _g("Debian %s version %s.\n"), $progname, $version;
     printf _g("Debian %s version %s.\n"), $progname, $version;
 
 
     printf _g("
     printf _g("
-Copyright (C) 2010 Raphael Hertzog <hertzog\@debian.org>.");
+Copyright (C) 2010-2011 Raphael Hertzog <hertzog\@debian.org>.");
 
 
     printf _g("
     printf _g("
 This is free software; see the GNU General Public License version 2 or
 This is free software; see the GNU General Public License version 2 or
@@ -50,6 +50,7 @@ Actions:
   --list             output a list of the flags supported by the current vendor.
   --list             output a list of the flags supported by the current vendor.
   --export=(sh|make) output commands to be executed in shell or make that export
   --export=(sh|make) output commands to be executed in shell or make that export
                      all the compilation flags as environment variables.
                      all the compilation flags as environment variables.
+  --dump             output all compilation flags with their values
   --help             show this help message.
   --help             show this help message.
   --version          show the version.
   --version          show the version.
 "), $progname;
 "), $progname;
@@ -70,6 +71,10 @@ while (@ARGV) {
             if defined($action);
             if defined($action);
         my $type = $1 || "sh";
         my $type = $1 || "sh";
         $action = "export-$type";
         $action = "export-$type";
+    } elsif (m/^--dump$/) {
+        usageerr(_g("two commands specified: --%s and --%s"), "dump", $action)
+            if defined($action);
+        $action = "dump";
     } elsif (m/^--list$/) {
     } elsif (m/^--list$/) {
         usageerr(_g("two commands specified: --%s and --%s"), "list", $action)
         usageerr(_g("two commands specified: --%s and --%s"), "list", $action)
             if defined($action);
             if defined($action);
@@ -85,7 +90,7 @@ while (@ARGV) {
     }
     }
 }
 }
 
 
-usageerr(_g("need an action option")) unless defined($action);
+$action = "dump" unless defined($action);
 
 
 my $build_flags = Dpkg::BuildFlags->new();
 my $build_flags = Dpkg::BuildFlags->new();
 
 
@@ -122,6 +127,11 @@ if ($action eq "get") {
 	}
 	}
     }
     }
     exit(0);
     exit(0);
+} elsif ($action eq "dump") {
+    foreach my $flag ($build_flags->list()) {
+	my $value = $build_flags->get($flag);
+	print "$flag=$value\n";
+    }
 }
 }
 
 
 exit(1);
 exit(1);