This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=7c54fa2b232e2d9f9008aeaaa0dd94a810921282 commit 7c54fa2b232e2d9f9008aeaaa0dd94a810921282 Author: Guillem Jover <[email protected]> AuthorDate: Fri Sep 4 01:02:24 2020 +0200 dpkg-architecture: Add a --print-format option This makes possible to select the output format for the --print-set and --print-unset commands. The current values supported are “shell” which is the current default, and “make”. Prompted-by: #968963 --- man/dpkg-architecture.pod | 7 ++++++- scripts/dpkg-architecture.pl | 30 ++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/man/dpkg-architecture.pod b/man/dpkg-architecture.pod index 9a4db88fd..02ebfe018 100644 --- a/man/dpkg-architecture.pod +++ b/man/dpkg-architecture.pod @@ -82,7 +82,7 @@ Print the value of a single variable. =item B<-s>, B<--print-set> Print an export command. This can be used to set the environment variables -using the POSIX shell B<eval>. +using the POSIX shell or make B<eval>, depending on the output format. =item B<-u>, B<--print-unset> @@ -145,6 +145,11 @@ specified CPU bits (since dpkg 1.17.14). Either B<32> or B<64>. Restrict the architectures listed by B<--list-known> to ones with the specified endianness (since dpkg 1.17.14). Either B<little> or B<big>. +=item B<--print-format> I<format> + +Sets the output format for B<--print-set> and B<--print-unset> +(since dpkg 1.20.6), to either B<shell> (default) or B<make>. + =item B<-f>, B<--force> Values set by existing environment variables with the same name as used by diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl index 847ea0519..6776117de 100755 --- a/scripts/dpkg-architecture.pl +++ b/scripts/dpkg-architecture.pl @@ -66,6 +66,9 @@ sub usage { restrict architecture list matching <arch-bits>. -E, --match-endian <arch-endian> restrict architecture list matching <arch-endian>. + --print-format <format> + use <format> for --print-set and --print-unset, + allowed values: shell (default), make. -f, --force force flag (override variables set in environment).') . "\n", $Dpkg::PROGNAME; } @@ -153,6 +156,9 @@ my %arch_vars = ( DEB_TARGET_GNU_TYPE => DEB_TARGET | DEB_GNU_INFO, ); +my %known_print_format = map { $_ => 1 } qw(shell make); +my $print_format = 'shell'; + my $req_vars = DEB_ALL; my $req_host_arch = ''; my $req_host_gnu_type = ''; @@ -207,6 +213,10 @@ while (@ARGV) { } elsif ($arg eq '-s' or $arg eq '--print-set') { $req_vars = DEB_ALL; $action = 'print-set'; + } elsif ($arg eq '--print-format') { + $print_format = shift; + error(g_('%s is not a supported print format'), $print_format) + unless exists $known_print_format{$print_format}; } elsif ($arg eq '-f' or $arg eq '--force') { $force=1; } elsif ($arg eq '-q' or $arg eq '--query') { @@ -332,12 +342,24 @@ if ($action eq 'list') { print "$k=$v{$k}\n"; } } elsif ($action eq 'print-set') { - foreach my $k (sort keys %arch_vars) { - print "$k=$v{$k}; "; + if ($print_format eq 'shell') { + foreach my $k (sort keys %arch_vars) { + print "$k=$v{$k}; "; + } + print 'export ' . join(' ', sort keys %arch_vars) . "\n"; + } elsif ($print_format eq 'make') { + foreach my $k (sort keys %arch_vars) { + print "export $k = $v{$k}\n"; + } } - print 'export ' . join(' ', sort keys %arch_vars) . "\n"; } elsif ($action eq 'print-unset') { - print 'unset ' . join(' ', sort keys %arch_vars) . "\n"; + if ($print_format eq 'shell') { + print 'unset ' . join(' ', sort keys %arch_vars) . "\n"; + } elsif ($print_format eq 'make') { + foreach my $k (sort keys %arch_vars) { + print "undefine $k\n"; + } + } } elsif ($action eq 'equal') { exit !debarch_eq($v{DEB_HOST_ARCH}, $req_eq_arch); } elsif ($action eq 'is') { -- Dpkg.Org's dpkg

