File: make-copyright

package info (click to toggle)
doc-linux-nonfree 2006.09-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 3,412 kB
  • ctags: 15
  • sloc: perl: 390; makefile: 151; sh: 122
file content (46 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download | duplicates (6)
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
#! /usr/bin/perl -w
use strict;

# Build a copyright file based on the files in debian/copyrights.

use Text::Wrap qw(wrap);

if (@ARGV < 2) {
    print STDERR "Usage: $0 <free/non-free> <header>\n";
    exit 1;
}

my $status = shift;
my $header = shift;

my (%documents, %copyrights);

opendir COPYRIGHTS, "debian/copyrights/$status"
    or die "Can't open debian/copyrights/$status directory: $!";
for my $copy (readdir COPYRIGHTS) {
    next unless -f "debian/copyrights/$status/$copy";
    open COPYRIGHT, "< debian/copyrights/$status/$copy"
	or die "Can't open debian/copyrights/$status/$copy: $!";
    while (<COPYRIGHT>) {
	chomp;
	last if /^$/;
	next unless s/^HOWTO: //o;
	push @{$documents{$copy}}, $_;
    }
    $copyrights{$copy} = join '', <COPYRIGHT>;
    close COPYRIGHT;
}
closedir COPYRIGHTS;

system "cat \Q$header\E";

$Text::Wrap::columns = 76;

for my $copy (sort keys %documents) {
    print "\n", '=' x 76, "\n\n";
    my @documents = sort @{$documents{$copy}};
    print "The following licence covers these documents:\n";
    print wrap('  ', '  ', (join ', ', @documents) . "\n");
    print "\n";
    print $copyrights{$copy};
}