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.

123 lines
3.0 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 - 2006 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. my %flags;
  30. open(F, "hosted_cpan.txt") || die $!;
  31. while (<F>) {
  32. chomp;
  33. next if /^#/ or /^\s*$/;
  34. die unless /^(\S+)\s+(\S+)(\s+.*\S|)/;
  35. my ($p, $m, $f) = ($1, $2, $3);
  36. $f =~ s/(\S+)/flag $1/g;
  37. $hosted{$m} = $p;
  38. $flags{$m} = $f;
  39. }
  40. close F;
  41. my %cksum;
  42. if ( open(D, "<hosted_cpan.desc") ) {
  43. while (<D>) {
  44. next unless /^.D. (\d+) (\S+)/;
  45. $cksum{$2} = $1;
  46. }
  47. close D;
  48. }
  49. open(F, "bzip2 -d < ../../../download/mirror/c/cpan_packages_20060324.txt.bz2 |") || die $!;
  50. open(D, ">hosted_cpan.desc") || die $!;
  51. open(S, ">hosted_cpan.sel") || die $!;
  52. open(C, ">hosted_cpan.cfg") || die $!;
  53. print D "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
  54. print S "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
  55. print C "# Auto-generated by hosted_cpan.pl from hosted_cpan.txt\n";
  56. print S "\ncase \"\$xpkg\" in\n";
  57. print D "\n"; print C "\n";
  58. while (<F>) {
  59. chomp;
  60. last if $_ =~ /^\s*$/;
  61. }
  62. while (<F>) {
  63. my ($mod, $ver, $loc) = split /\s+/;
  64. next unless $loc=~/(.*\/)([^\/]+)/;
  65. my ($d, $f) = ($1, $2);
  66. my $key = $mod;
  67. goto matched if defined $hosted{$key};
  68. foreach (keys %hosted) {
  69. $key = $_;
  70. goto matched if $mod =~ /^${key}::/;
  71. }
  72. next;
  73. matched:
  74. my $xmod = $key;
  75. $xmod =~ y/A-Z/a-z/;
  76. $xmod =~ s/::/-/g;
  77. my $ymod = $key;
  78. $ymod =~ y/a-z/A-Z/;
  79. $ymod =~ s/::/_/g;
  80. print "$key -> $mod -> cpan-$xmod\n";
  81. my $cksum = defined $cksum{$f} ? $cksum{$f} : 0;
  82. print D "#if xpkg == cpan-$xmod\n";
  83. print D "[V] $ver\n";
  84. print D "[D] $cksum $f $cpanbase/$d\n";
  85. print D "#endif\n\n";
  86. $f =~ s/\.gz$/.bz2/;
  87. print S "\tcpan-$xmod)\n";
  88. print S "\t\tcpanmod=\"$mod\"\n";
  89. print S "\t\tcpanver=\"$ver\"\n";
  90. print S "\t\tcpanloc=\"$loc\"\n";
  91. print S "\t\tsrctar=\"$f\"\n";
  92. print S "\t\t;;\n";
  93. print C "pkgfork cpan cpan-$xmod status X priority $hosted{$key}$flags{$key}\n";
  94. delete $hosted{$key};
  95. }
  96. print S "esac\n\n";
  97. close D; close S;
  98. close F; close C;