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.

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