mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.8 KiB

  1. #!/usr/bin/perl
  2. #
  3. # re-run this scrip if hosted_cpan.txt has changed
  4. # generates hosted_cpan.{desc,sel,cfg}
  5. #
  6. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  7. #
  8. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  9. # Please add additional copyright information _after_ the line containing
  10. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  11. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  12. #
  13. # ROCK Linux: rock-src/package/import/cpan/hosted_cpan.pl
  14. # ROCK Linux is Copyright (C) 1998 - 2004 Clifford Wolf
  15. #
  16. # This program is free software; you can redistribute it and/or modify
  17. # it under the terms of the GNU General Public License as published by
  18. # the Free Software Foundation; either version 2 of the License, or
  19. # (at your option) any later version. A copy of the GNU General Public
  20. # License can be found at Documentation/COPYING.
  21. #
  22. # Many people helped and are helping developing ROCK Linux. Please
  23. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  24. # file for details.
  25. #
  26. # --- ROCK-COPYRIGHT-NOTE-END ---
  27. my $cpanbase="http://www.cpan.org/modules/by-authors/id";
  28. my %hosted;
  29. open(F, "hosted_cpan.txt") || die $!;
  30. while (<F>) {
  31. chomp;
  32. next if /^#/ or /^\s*$/;
  33. my ($p, $m) = split /\s+/;
  34. $hosted{$m} = $p;
  35. }
  36. close F;
  37. open(F, "bzip2 -d < ../../../download/mirror/0/02packages.details.txt.bz2 |") || die $!;
  38. open(D, ">hosted_cpan.desc") || die $!;
  39. open(S, ">hosted_cpan.sel") || die $!;
  40. open(C, ">hosted_cpan.cfg") || die $!;
  41. print D "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
  42. print S "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
  43. print C "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
  44. print S "\ncase \"\$xpkg\" in\n";
  45. print D "\n"; print C "\n";
  46. while (<F>) {
  47. chomp;
  48. last if $_ =~ /^\s*$/;
  49. }
  50. while (<F>) {
  51. my ($mod, $ver, $loc) = split /\s+/;
  52. next unless $loc=~/(.*\/)([^\/]+)/;
  53. my ($d, $f) = ($1, $2);
  54. my $key = $mod;
  55. goto matched if defined $hosted{$key};
  56. foreach (keys %hosted) {
  57. $key = $_;
  58. goto matched if $mod =~ /^${key}::/;
  59. }
  60. next;
  61. matched:
  62. my $xmod = $key;
  63. $xmod =~ y/A-Z/a-z/;
  64. $xmod =~ s/::/-/g;
  65. my $ymod = $key;
  66. $ymod =~ y/a-z/A-Z/;
  67. $ymod =~ s/::/_/g;
  68. print "$key -> $mod -> cpan-$xmod\n";
  69. delete $hosted{$key};
  70. print D "#if xpkg == cpan-$xmod\n";
  71. print D "[V] $ver\n";
  72. print D "[D] 0 $f $cpanbase/$d\n";
  73. print D "#endif\n\n";
  74. $f =~ s/\.gz$/.bz2/;
  75. print S "\tcpan-$xmod)\n";
  76. print S "\t\tcpanmod=\"$mod\"\n";
  77. print S "\t\tcpanver=\"$ver\"\n";
  78. print S "\t\tcpanloc=\"$loc\"\n";
  79. print S "\t\tsrctar=\"$f\"\n";
  80. print S "\t\t;;\n";
  81. print C "bool 'Building package $mod (cpan-$xmod)' ROCKCFG_PKG_CPAN_$ymod 1\n";
  82. print C "if [ \$ROCKCFG_PKG_CPAN_$ymod = 1 ]; then pkgfork cpan cpan-$xmod priority $hosted{$mod}; fi\n\n";
  83. }
  84. print S "esac\n\n";
  85. close D; close S;
  86. close F; close C;