@@ -29,7 +29,7 @@ use strict;
29
29
use Build;
30
30
use Build::Rpm;
31
31
32
- my ($dist , $archs , $configdir , $type , $argument );
32
+ my ($dist , $archs , $configdir , $decode , $ type , $argument );
33
33
34
34
$configdir = ($: :ENV {' BUILD_DIR' } || ' /usr/lib/build' ) . ' /configs' ;
35
35
@@ -42,6 +42,10 @@ while (@ARGV) {
42
42
shift @ARGV ;
43
43
$archs = shift @ARGV ;
44
44
next ;
45
+ } elsif ($ARGV [0] eq ' --decode' ) {
46
+ shift @ARGV ;
47
+ $decode = 1;
48
+ next ;
45
49
} elsif ($ARGV [0] eq ' --configdir' ) {
46
50
shift @ARGV ;
47
51
$configdir = shift @ARGV ;
@@ -58,39 +62,45 @@ die("Please specify what to query\n") unless defined $type;
58
62
my $cf = Build::read_config_dist($dist , $archs , $configdir );
59
63
die (" Unable to read config\n " ) unless $cf ;
60
64
65
+ sub printout {
66
+ my ($str ) = @_ ;
67
+ $str =~ s / %([a-fA-F0-9]{2})/ chr(hex($1 ))/ ge if $decode ;
68
+ print $str ;
69
+ }
70
+
61
71
if ($type eq ' buildflags' ) {
62
72
die (" Specify which buildflag to query\n " ) unless $argument ;
63
73
my $result = $cf -> {" buildflags:$argument " };
64
- print " $result \n " if defined $result ;
74
+ printout( " $result \n " ) if defined $result ;
65
75
} elsif ($type eq ' buildflags+' ) {
66
76
die (" Specify which buildflag to query\n " ) unless $argument ;
67
77
for (@{$cf -> {' buildflags' } || []}) {
68
- print " $1 \n " if / \Q $argument \E :(.*)/ ;
78
+ printout( " $1 \n " ) if / \Q $argument \E :(.*)/ ;
69
79
}
70
80
} elsif ($type eq ' hostarch' ) {
71
81
my $result = $cf -> {" hostarch" };
72
- print " $result \n " if defined $result ;
82
+ printout( " $result \n " ) if defined $result ;
73
83
} elsif ($type eq ' target' || $type eq ' type' || $type eq ' binarytype' || $type eq ' buildengine' || $type eq ' rawmacros' ) {
74
- print " $cf ->{$type }\n " if $cf -> {$type };
84
+ printout( " $cf ->{$type }\n " ) if $cf -> {$type };
75
85
} elsif ($type eq ' repotype' || $type eq ' repourl' || $type eq ' registryurl' ) {
76
- print join (' ' , @{$cf -> {$type }})." \n " if $cf -> {$type };
86
+ printout( join (' ' , @{$cf -> {$type }})." \n " ) if $cf -> {$type };
77
87
} elsif ($type eq ' optflags' ) {
78
88
exit (0) unless $cf -> {' optflags' };
79
89
my $all = $cf -> {' optflags' }-> {' *' };
80
90
$all = defined ($all ) && $all ne ' ' ? " $all " : ' ' ;
81
91
$all .= " -g" if $argument && $argument eq ' debug' ;
82
92
for (sort keys %{$cf -> {' optflags' }}) {
83
93
next if $_ eq ' *' ;
84
- print " optflags: $_ $cf ->{'optflags'}->{$_ }$all \n " ;
94
+ printout( " optflags: $_ $cf ->{'optflags'}->{$_ }$all \n " ) ;
85
95
}
86
96
} elsif ($type eq ' substitute' ) {
87
97
die (" Specify which substitute to query\n " ) unless $argument ;
88
98
my @res = @{$cf -> {' substitute' }-> {$argument } || []};
89
- print join (' ' , @res )." \n " if @res ;
99
+ printout( join (' ' , @res )." \n " ) if @res ;
90
100
} elsif ($type eq ' eval' ) {
91
101
die (" Specify what to eval\n " ) unless defined $argument ;
92
102
my $result = Build::Rpm::expandmacros($cf , $argument );
93
- print " $result \n " ;
103
+ printout( " $result \n " ) ;
94
104
} else {
95
105
die (" unsupported query type: $type \n " );
96
106
}
0 commit comments