File: dh_split

package info (click to toggle)
shadow 19990827-20
  • links: PTS
  • area: main
  • in suites: potato
  • size: 828 kB
  • ctags: 52
  • sloc: ansic: 1,071; makefile: 126; perl: 74; sh: 46
file content (61 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w

# Special just for shadow (does not create for a base package, so
# not compatible with debhelper)
#LOCAL#

$control = 'debian/control';
$dir = 'debian';
$needclean = 0;
$needlist = 0;
$needdeps = 0;

if (@ARGV) {
    $temp = shift;
    if ($temp eq "clean") { $needclean = 1; }
    elsif ($temp eq "makedeps") { $needlist = 1; }
    elsif ($temp eq "gendeps") { $needdeps = 1; }
}

@packages = ();

open (CONTROL, "< $control");

while (<CONTROL>) {
    if (m/^Package:/) {
	$package = (split)[1];
	if ( -f "${dir}/${package}.in" ) {
	    push @packages, $package;
	}
    }
}

close CONTROL;

while (@packages) {
    $package = shift(@packages);
    $inhead = 1;
    $opened = 0;
    if ($needdeps) {
	print "${dir}/${package}.in ";
	next;
    }
    open (IN, "< ${dir}/${package}.in");
    while (<IN>) {
	if (m/^\%(.*)\%$/) {
	    if ($needclean) {
		system("rm -f ${dir}/${package}.${1}");
	    } elsif ($needlist) {
		print "${dir}/${package}.${1} ";
	    } else {
		$inhead = 0;
		if ($opened) { close OUT; } else { $opened = 1; }
		open OUT, "> ${dir}/${package}.${1}";
	    }
	} elsif (!$inhead) {
	    print OUT $_;
	}
    }
    close OUT;
    close IN;
}