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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
#! /usr/bin/perl -w
use strict;
# Split the HOWTO tarballs into free and non-free components, based on the
# files in debian/copyrights.
use File::Copy;
use File::Path;
if (@ARGV < 1) {
print STDERR "Usage: $0 <tar.bz2>\n";
exit 1;
}
rmtree 'free', 0, 1;
mkdir 'free';
rmtree 'non-free', 0, 1;
mkdir 'non-free';
my $type = 'HOWTO';
my %status;
for my $status (qw(free non-free undistributable removed placeholder)) {
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/^\Q$type\E: //o;
$status{$status}{$_}++;
$status{all}{$_}++;
if ($status{all}{$_} > 1) {
warn "Duplicate copyright information for $_!\n";
}
}
close COPYRIGHT;
}
closedir COPYRIGHTS;
}
mkdir 'tmp';
my $tar = shift;
system "tar -C tmp -xjf \Q$tar\E";
my $dir = 'tmp';
$dir = 'tmp/HOWTO' if -d 'tmp/HOWTO';
opendir FILES, $dir or die "Can't open $dir directory: $!";
my @files = grep !/^\.\.?$/, readdir FILES;
closedir FILES;
for my $file (@files) {
(my $canon = $file) =~ s/(?:-\d+)?\.html$//;
# These always go in the free package.
if ($file =~ /^(?:COPYRIGHT|INDEX|INDEX\.html|README|images|index\.html)$/
or $file =~ /\.gif$/) {
move "$dir/$file", "free/$file";
next;
}
# Special cases (sigh).
if ($canon =~ /^(?:C\+\+Programming|PostgreSQL)-HOWTO$/) {
move "$dir/$file", "free/$file";
next;
} elsif ($canon eq 'HOWTO-INDEX') {
# goes in both directories for the benefit of debian/html2docs
system 'cp', '-a', "$dir/$file", "free/$file";
move "$dir/$file", "non-free/$file";
next;
} elsif ($canon eq '.htaccess') {
next;
} elsif ($canon eq 'archived') {
next;
} elsif ($canon eq 'Access-HOWTO') {
$canon = 'Accessibility-HOWTO';
} elsif ($canon eq 'Distributions-HOWTO') {
$canon = 'CD-Distributions-EN-HOWTO';
} elsif ($canon eq 'GTEK-BBS') {
$canon = 'GTEK-BBS-550';
} elsif ($canon eq 'IR-HOWTO') {
$canon = 'Infrared-HOWTO';
} elsif ($canon eq 'Loadlin+Win95') {
$canon = 'Loadlin+Win95-98-ME';
# Net-HOWTO was reverted to NET3-4-HOWTO so comment out
# } elsif ($canon eq 'NET3-4-HOWTO') {
# $canon = 'Net-HOWTO';
} elsif ($canon eq 'Xnews-under-Linux-HOWTO') {
$canon = 'Windows-Newsreaders-under-Linux-HOWTO';
}
if ($status{free}{$canon}
|| $status{placeholder}{$canon}) {
move "$dir/$file", "free/$file";
} elsif ($status{'non-free'}{$canon}) {
move "$dir/$file", "non-free/$file";
} elsif (!$status{all}{$canon}) {
warn "No copyright information for $file ($canon)!\n";
}
}
for my $status (qw(free non-free)) {
(my $tarout = $tar) =~ s{/([^/]*)$}{/$status-$1};
$tarout = "../$tarout" unless $tarout =~ m[^/];
system "cd \Q$status\E && tar -cjf \Q$tarout\E *";
}
rmtree 'free', 0, 1;
rmtree 'non-free', 0, 1;
rmtree 'tmp', 0, 1;
|