-
Notifications
You must be signed in to change notification settings - Fork 5
/
dh_epics_list_targets
executable file
·113 lines (73 loc) · 2.34 KB
/
dh_epics_list_targets
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/perl
=head1 NAME
dh_epics_list_targets - Print a list of installed EPICS targets
=head1 SYNOPSIS
B<dh_epics_list_targets> [S<I<debhelper options>>] [--skiphost] [--neg] -- [posregex] [-negregex]
=head1 DESCRIPTION
Print a list of EPICS targets matching the given constraints.
Constraints are given as either positive (including) or negative
(excluding) regular expressions.
By default all targets are printed unless a negative expression is matched.
If the --neg option is given then no targets are printed unless a positive
expression is matched. In either case a target matching a negative
expression will not be printed.
A negative expression is one which begins with the '-' (dash) charactor.
The dash is not part of the regular expression. To start a positive
expression with a dash it must be escaped with '\'.
The --skiphost argument is equivalent to "-^${EPICS_HOST_ARCH}$".
=head1 EXAMPLES
Print only RTEMS targets
dh_epics_list_targets --neg -- RTEMS
Print all but RTEMS targets
dh_epics_list_targets -- -RTEMS
Print all cross compiler targets
dh_epics_list_targets --skiphost
Print any debug targets
dh_epics_list_targets --neg -- "\-debug$"
=cut
use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
use Debian::Debhelper::Dh_Epics qw(setepicsenv);
my $skiphost = 0;
my $neg = 0;
my %args;
my %options = (
"skiphost" => \$skiphost,
"neg" => \$neg,
);
$args{options}{$_} = $options{$_} foreach keys(%options);
init(%args);
inhibit_log();
setepicsenv();
my @args = ();
@args = @{$dh{U_PARAMS}} if(defined @{$dh{U_PARAMS}});
if($skiphost) {
unshift(@args,"-^$ENV{EPICS_HOST_ARCH}\$");
}
my @dirs = glob("$ENV{EPICS_BASE}/lib/*");
foreach my $libdir (@dirs) {
next unless(-d $libdir and not -l $libdir);
my $targ = basename($libdir);
my $cont=($neg ? 0 : 1);
foreach my $test (@args) {
if( $test =~ m/^-(.*)/ ) {
if( $targ =~ m/$1/) {
$cont = 0;
last;
}
} else {
my $tst = $test;
$tst = $1 if( $test =~ m/^\\-(.*)/ );
$cont = 1 if( $targ =~ m/$tst/);
}
}
next if(not $cont);
print "$targ\n";
}
=head1 SEE ALSO
L<debhelper(7)>, L<epics-debhelper(7)>
This program is a not part of the official debhelper package.
=head1 AUTHOR
Michael Davidsaver <[email protected]>
=cut