summaryrefslogtreecommitdiff
path: root/debian/genbuilddeps
blob: 1a35afec0f9a02df5f8d14abd0e3a3551106474f (plain)
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
#!/usr/bin/perl
# Generate build deps line from comments in the control file and replace
# the current Build-Depends-Indep line in the control file with it.

my $control;
if (-e "debian/control") {
	$control="debian/control";
}
elsif (-e "control") {
	$control="control";
}
else {
	die "cannot find control file";
}

my @builddeps;
my @lines;
open (IN, $control) || die "read $control: $!";
while (<IN>) {
	push @lines, $_;
	chomp;
	if (/^#\s+-\s+(.*)$/) {
		push @builddeps, $1;
	}
}
close IN;

my $builddeps=join(", ", @builddeps);
open (OUT, ">$control.tmp") || die "write $control.tmp: $!";
foreach (@lines) {
	s/^(Build-Depends-Indep:\s+)(.*)/$1$builddeps/;
	print OUT || die "print: $!";
}
close OUT || die "close: $!";
rename("$control.tmp", "$control");