XFix gbs full build error: binary not found
[tools/build.git] / queryconfig
1 #!/usr/bin/perl -w
2
3 ################################################################
4 #
5 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 or 3 as
9 # published by the Free Software Foundation.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program (see the file COPYING); if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 #
21 ################################################################
22
23 BEGIN {
24   unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
25 }
26
27 use strict;
28
29 use Build;
30
31 my ($dist, $archs, $configdir, $type, $argument);
32
33 $configdir = ($::ENV{'BUILD_DIR'} || '/usr/lib/build') . '/configs';
34
35 while (@ARGV)  {
36   if ($ARGV[0] eq '--dist') {
37     shift @ARGV;
38     $dist = shift @ARGV;
39     next;
40   } elsif ($ARGV[0] eq '--archpath') {
41     shift @ARGV;
42     $archs = shift @ARGV;
43     next;
44   } elsif ($ARGV[0] eq '--configdir') {
45     shift @ARGV;
46     $configdir = shift @ARGV;
47     next;
48   } elsif (defined($type)) {
49     $argument = shift @ARGV; 
50   } else {
51     $type = shift @ARGV;
52   }
53 }
54
55 die("Please specify what to query\n") unless defined $type;
56
57 my $cf = Build::read_config_dist($dist, $archs, $configdir);
58 die("Unable to read config\n") unless $cf;
59
60 if ($type eq 'buildflags') {
61   die("Specify which buildflag to query\n") unless $argument;
62   my $result = $cf->{"buildflags:$argument"};
63   print "$result\n" if defined $result;
64 } elsif ($type eq 'hostarch') {
65   my $result = $cf->{"hostarch"};
66   print "$result\n" if defined $result;
67 } elsif ($type eq 'target' || $type eq 'type' || $type eq 'binarytype' || $type eq 'buildengine' || $type eq 'rawmacros') {
68   print "$cf->{$type}\n" if $cf->{$type};
69 } elsif ($type eq 'repotype') {
70   print join(' ', @{$cf->{$type}})."\n" if $cf->{$type};
71 } elsif ($type eq 'optflags') {
72   exit(0) unless $cf->{'optflags'};
73   my $all = $cf->{'optflags'}->{'*'};
74   $all = defined($all) && $all ne '' ? " $all" : '';
75   $all .= " -g" if $argument && $argument eq 'debug';
76   for (sort keys %{$cf->{'optflags'}}) {
77     next if $_ eq '*';
78     print "optflags: $_ $cf->{'optflags'}->{$_}$all\n";
79   }
80 } elsif ($type eq 'substitute') {
81   die("Specify which substitute to query\n") unless $argument;
82   my @res =  @{$cf->{'substitute'}->{$argument} || []};
83   print join(' ', @res)."\n" if @res;
84 } else {
85   die("unsupported query type: $type\n");
86 }
87
88 exit(0);
89