-
Notifications
You must be signed in to change notification settings - Fork 29
/
pkgconf_extract
executable file
·47 lines (43 loc) · 882 Bytes
/
pkgconf_extract
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
#
use strict;
my($line, %vars, %defs);
open(F, $ARGV[0]);
while($line = <F>){
if($line =~ /(\S+)\s*=\s*(.+)/){
$vars{$1} = substitute($2);
}elsif($line =~ /(\S+)\s*:\s*(.+)/){
my($key, $val) = ($1, $2);
$defs{$key} = substitute($val);
#printf("Read in: %s -> %s\n", $1, $defs{$1});
}
}
close(F);
#printf("\n\n%s\n...\n", $defs{Version});
#foreach $x (keys(%defs)){
# printf("%s -> %s\n", $x, $defs{$x});
#}
#printf("...\n");
#printf("\"");
my($i) = 1;
while(1){
if(defined($ARGV[$i]) && defined($ARGV[$i+1]) && defined($defs{$ARGV[$i+1]})){
printf("%s=%s ", $ARGV[$i], $defs{$ARGV[$i+1]});
$i += 2;
}else{
last;
}
}
#printf("\"");
sub substitute{
my($str) = @_;
while($str =~ /(.*)\$\{(\S+)\}(.*)/){
if(exists($vars{$2})){
$str = $1.$vars{$2}.$3;
}else{
$str = $1.$3;
}
}
return $str;
}
#