~ubuntu-branches/ubuntu/hoary/binutils/hoary

« back to all changes in this revision

Viewing changes to debian/scripts/dh_split

  • Committer: Bazaar Package Importer
  • Author(s): Christopher C. Chimelis
  • Date: 2002-04-18 13:03:49 UTC
  • Revision ID: james.westby@ubuntu.com-20020418130349-pr9a1j3znz4gh3j6
Tags: 2.12.90.0.1-4
* Added patch from Gerhardt Tonn
  to fix s390 merge problem (closes: Bug#143187)
* Corrected DOW of my last changelog entry :-P

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
$control = 'debian/control';
 
4
if ( -d 'debian/packages.d' ) {
 
5
    $dir = 'debian/packages.d';
 
6
} else {
 
7
    $dir = 'debian';
 
8
}
 
9
$needclean = 0;
 
10
$needlist = 0;
 
11
$needdeps = 0;
 
12
 
 
13
if (defined($ENV{'DH_COMPAT'})) {
 
14
    $dh = $ENV{'DH_COMPAT'};
 
15
} else {
 
16
    $dh = 0;
 
17
}
 
18
 
 
19
if (@ARGV) {
 
20
    $temp = shift;
 
21
    if ($temp eq "clean") { $needclean = 1; }
 
22
    elsif ($temp eq "makedeps") { $needlist = 1; }
 
23
    elsif ($temp eq "gendeps") { $needdeps = 1; }
 
24
}
 
25
 
 
26
@packages = ();
 
27
$first_package = "";
 
28
 
 
29
open (CONTROL, "< $control");
 
30
 
 
31
while (<CONTROL>) {
 
32
    if (m/^Package:/) {
 
33
        $package = (split)[1];
 
34
        if ($first_package eq "" and $dh < 2) {
 
35
                $first_package = $package;
 
36
        }
 
37
        if ( -f "${dir}/${package}.in" ) {
 
38
            push @packages, $package;
 
39
        }
 
40
    }
 
41
}
 
42
 
 
43
close CONTROL;
 
44
 
 
45
while (@packages) {
 
46
    $package = shift(@packages);
 
47
    $inhead = 1;
 
48
    $opened = 0;
 
49
    if ($needdeps) {
 
50
        print "${dir}/${package}.in ";
 
51
        next;
 
52
    }
 
53
    open (IN, "< ${dir}/${package}.in");
 
54
    while (<IN>) {
 
55
        if (m/^\%(.*)\%$/) {
 
56
            if ($needclean) {
 
57
                if ($package ne $first_package) {
 
58
                    system("rm -f debian/${package}.${1}");
 
59
                } else {
 
60
                    system("rm -f debian/${1}");
 
61
                }
 
62
            } elsif ($needlist) {
 
63
                if ($package ne $first_package) {
 
64
                    print "debian/${package}.${1} ";
 
65
                } else {
 
66
                    print "debian/${1} ";
 
67
                }
 
68
            } else {
 
69
                $inhead = 0;
 
70
                if ($opened) { close OUT; } else { $opened = 1; }
 
71
                if ($package ne $first_package) {
 
72
                    open OUT, "> debian/${package}.${1}";
 
73
                } else {
 
74
                    open OUT, "> debian/${1}";
 
75
                }
 
76
            }
 
77
        } elsif (!$inhead) {
 
78
            print OUT $_;
 
79
        }
 
80
    }
 
81
    close OUT;
 
82
    close IN;
 
83
}