outdated-perl-ports 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/perl
  2. # $OpenBSD: outdated-perl-ports,v 1.2 2014/07/07 20:01:39 bluhm Exp $
  3. #
  4. # Copyright (c) 2003 Sam Smith <S@mSmith.net>
  5. #
  6. # Permission to use, copy, modify, and distribute this software for any
  7. # purpose with or without fee is hereby granted, provided that the above
  8. # copyright notice and this permission notice appear in all copies.
  9. #
  10. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. use strict;
  18. use warnings;
  19. use Getopt::Std;
  20. # -d: show path to port (relative to $PORTSDIR)
  21. # -m <maintainer>: search for a maintainer (name or address)
  22. our ($opt_d, $opt_m);
  23. getopts('dm:');
  24. # packages list. Change to a different mirror if you want.
  25. my $CPAN_packages_details="http://mirror.sov.uk.goscomb.net/CPAN/modules/02packages.details.txt.gz";
  26. my $PORTSDIR= $ENV{PORTSDIR} || "/usr/ports"; # location of ports directory
  27. my %Modules; # What CPAN thinks is up to date
  28. my $line; # lines we process
  29. my @line; # $line run through split
  30. my @dir; # pkg subdir
  31. {
  32. open(MODULES, "ftp -V -o - $CPAN_packages_details 2>/dev/null | gzip -cd |")
  33. || die "can't open $CPAN_packages_details: $!";
  34. while (<MODULES>) {
  35. next if (1 .. /^\s*$/); # ignore gunk before first blank line
  36. #example match: /Class-Autouse-0.8.tar.gz
  37. m#/([\w\-]+)\-([\d\.]+)(?:\_\w+\d+)?\.tar\.gz$#;
  38. if (defined $ENV{DEBUG}){print STDERR "$_" unless $2;}
  39. next unless ($2); # some things don't follow conventions
  40. unless ((defined $Modules{$1}) and $Modules{$1} ge $2) {
  41. $Modules{$1}=$2 ;
  42. #print STDERR "$1 maps to $2\n";
  43. }
  44. }
  45. open (PORTS, "< ${PORTSDIR}/INDEX") || die "can't open ${PORTSDIR}/INDEX: $!";
  46. while ($line=<PORTS>) {
  47. @line= split /\|/, $line;
  48. next unless ($line =~ /^(p5\-(.+?)\-([\d\.]+)(?:[pv]\d+)*)\|/);
  49. # $1 has full package name in
  50. # $2 is the name of the perl module (the stem minus the p5- prefix)
  51. # $3 is the version number
  52. if (defined $ENV{DEBUG}){print STDERR "$1\t$2\t$3\n";}
  53. if ((defined $Modules{$2}) and ($Modules{$2} gt $3)) {
  54. if ($opt_m) {
  55. next unless ($line[5] =~ m/$opt_m/);
  56. }
  57. if ($opt_d) {
  58. @dir = split /\//, $line[4];
  59. print STDOUT "Out of date: $dir[0]/$1 vs $Modules{$2}. $line[5]\n";
  60. } else {
  61. print STDOUT "Out of date: $1 vs $Modules{$2}. $line[5]\n";
  62. }
  63. }
  64. }
  65. }