-
Notifications
You must be signed in to change notification settings - Fork 5
/
dh_epics_gencontrol
executable file
·140 lines (91 loc) · 2.82 KB
/
dh_epics_gencontrol
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/perl
=head1 NAME
dh_epics_gencontrol - Create debian/control from debian/control.base
=head1 SYNOPSIS
B<dh_epics_gencontrol> [S<I<debhelper options>>]
=head1 DESCRIPTION
=cut
use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
use Debian::Debhelper::Dh_Epics qw(setepicsenv epics_targets);
use Parse::DebControl;
=head1 SYNOPSIS
B<dh_epics_gencontrol> [S<I<debhelper options>>]
=head1 DESCRIPTION
Expands debian/control.base adding entries
for cross compiled targets.
=cut
init();
my $parser = new Parse::DebControl;
my $cfile = "./debian/control.base";
if(not -f $cfile) {
verbose_print("No $cfile");
}
my $control = $parser->parse_file($cfile, { useTieIxHash => 'true' });
my @bdeps;
my @targets = (".*");
my $srcpkg = $control->[0]->{"Source"};
my $rtemsname = "rtems-$srcpkg"; # X-Rtems-Name:
my $rtemsdev = $control->[1]->{"Package"}; # X-Rtems-Dev:
my %srcfields = %{$control->[0]};
while (my ($k,$v) = each(%srcfields)) {
if(not defined @bdeps and $k =~ m/^(?:X[BCS]*-)?Rtems-Build-Depends$/ ) {
@bdeps = split(",",$v);
foreach my $bdep (@bdeps) {
chomp($bdep);
}
}
if($k =~ m/^(?:X[BCS]*-)?Epics-Targets/ ) {
@targets = split(/\s+/,$v);
}
if($k =~ m/^(?:X[BCS]*-)?Rtems-Name/ ) {
$rtemsname = "rtems-$v";
}
if($k =~ m/^(?:X[BCS]*-)?Rtems-Dev/ ) {
$rtemsdev = $v;
}
}
@targets = (".*") if(not defined @targets);
@targets = epics_targets(0, @targets);
if(defined @bdeps and not exists $control->[0]->{"Build-Depends"}) {
$control->[0]->Push("Build-Depends" => "");
}
my @rtemspkgs = ();
foreach my $target (@targets) {
next unless($target =~ m/^RTEMS-(.*)/);
my $bsp=$1;
if(defined @bdeps) {
my @extradeps = ();
foreach my $bdep (@bdeps) {
unshift(@extradeps, "$bdep-$bsp,");
}
my $olddeps = $control->[0]->{"Build-Depends"};
my $newdeps = join(" ",@extradeps);
# add leading comma if needed
$newdeps=",$newdeps" unless($olddeps =~ m/.*,\s*$/s);
$control->[0]->{"Build-Depends"} = "$olddeps\n $newdeps";
}
my $pkg = << "CONTROL";
Package: ${rtemsname}-$bsp
Architecture: all
Depends: \${rtems:Depends}, $rtemsdev (= \${binary:Version})
Description: $srcpkg for the $bsp BSP\n The $srcpkg compiled for the $bsp RTEMS BSP.
CONTROL
push(@rtemspkgs, $pkg);
}
my $writer = new Parse::DebControl;
$writer->DEBUG();
$writer->write_file("debian/control", $control,
{ clobberFile => 'true' });
open(CONT, ">>debian/control") || error("Can't append control");
foreach my $pkg (@rtemspkgs) {
print CONT $pkg;
}
close(CONT);
=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