summaryrefslogtreecommitdiff
path: root/debian/genbuilddeps
blob: ca94a4f069261fb734e006336b5faeca1fb07e11 (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 deps 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:\s+)(.*)/$1$builddeps/;
	print OUT || die "print: $!";
}
close OUT || die "close: $!";
rename("$control.tmp", "$control");