#!/usr/bin/perl
|
|
#
|
|
# re-run this scrip if hosted_cpan.txt has changed
|
|
# generates hosted_cpan.{desc,sel,cfg}
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
|
|
#
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
# Please add additional copyright information _after_ the line containing
|
|
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
|
|
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
|
|
#
|
|
# ROCK Linux: rock-src/package/import/cpan/hosted_cpan.pl
|
|
# ROCK Linux is Copyright (C) 1998 - 2004 Clifford Wolf
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version. A copy of the GNU General Public
|
|
# License can be found at Documentation/COPYING.
|
|
#
|
|
# Many people helped and are helping developing ROCK Linux. Please
|
|
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
|
|
# file for details.
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-END ---
|
|
|
|
my $cpanbase="http://www.cpan.org/modules/by-authors/id";
|
|
|
|
my %hosted;
|
|
|
|
open(F, "hosted_cpan.txt") || die $!;
|
|
|
|
while (<F>) {
|
|
chomp;
|
|
next if /^#/ or /^\s*$/;
|
|
my ($p, $m) = split /\s+/;
|
|
$hosted{$m} = $p;
|
|
}
|
|
|
|
close F;
|
|
|
|
open(F, "bzip2 -d < ../../../download/mirror/0/02packages.details.txt.bz2 |") || die $!;
|
|
open(D, ">hosted_cpan.desc") || die $!;
|
|
open(S, ">hosted_cpan.sel") || die $!;
|
|
open(C, ">hosted_cpan.cfg") || die $!;
|
|
|
|
print D "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
|
|
print S "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
|
|
print C "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
|
|
|
|
print S "\ncase \"\$xpkg\" in\n";
|
|
print D "\n"; print C "\n";
|
|
|
|
while (<F>) {
|
|
chomp;
|
|
last if $_ =~ /^\s*$/;
|
|
}
|
|
|
|
while (<F>) {
|
|
my ($mod, $ver, $loc) = split /\s+/;
|
|
|
|
next unless $loc=~/(.*\/)([^\/]+)/;
|
|
my ($d, $f) = ($1, $2);
|
|
|
|
my $key = $mod;
|
|
goto matched if defined $hosted{$key};
|
|
|
|
foreach (keys %hosted) {
|
|
$key = $_;
|
|
goto matched if $mod =~ /^${key}::/;
|
|
}
|
|
next;
|
|
|
|
matched:
|
|
my $xmod = $key;
|
|
$xmod =~ y/A-Z/a-z/;
|
|
$xmod =~ s/::/-/g;
|
|
|
|
my $ymod = $key;
|
|
$ymod =~ y/a-z/A-Z/;
|
|
$ymod =~ s/::/_/g;
|
|
|
|
print "$key -> $mod -> cpan-$xmod\n";
|
|
delete $hosted{$key};
|
|
|
|
print D "#if xpkg == cpan-$xmod\n";
|
|
print D "[V] $ver\n";
|
|
print D "[D] 0 $f $cpanbase/$d\n";
|
|
print D "#endif\n\n";
|
|
|
|
$f =~ s/\.gz$/.bz2/;
|
|
print S "\tcpan-$xmod)\n";
|
|
print S "\t\tcpanmod=\"$mod\"\n";
|
|
print S "\t\tcpanver=\"$ver\"\n";
|
|
print S "\t\tcpanloc=\"$loc\"\n";
|
|
print S "\t\tsrctar=\"$f\"\n";
|
|
print S "\t\t;;\n";
|
|
|
|
print C "bool 'Building package $mod (cpan-$xmod)' ROCKCFG_PKG_CPAN_$ymod 1\n";
|
|
print C "if [ \$ROCKCFG_PKG_CPAN_$ymod = 1 ]; then pkgfork cpan cpan-$xmod priority $hosted{$mod}; fi\n\n";
|
|
}
|
|
|
|
print S "esac\n\n";
|
|
|
|
close D; close S;
|
|
close F; close C;
|
|
|