#!/usr/pkg/bin/perl # # $NetBSD$ # # Copyright (c) 2002, 2003, The NetBSD Foundation, Inc. # # This code was originally contributed to the NetBSD Foundation, Inc. # by Julio Merino . # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # 3. Neither the name of author nor the names of its contributors may # be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # $| = 1; $PKGSRCDIR="/p/pkgsrc"; @pkgs = (); %oodate = (); %maint = (); print "Scanning pkgsrc tree: "; scan_pkgsrc(); print "done\n"; scan_oodate(); sort_maintainers(); foreach $mail (keys %maint) { mkdir("/tmp/todo", 0755); open(MAIL, ">/tmp/todo/$mail"); print MAIL "NetBSD pkgsrc TODO\n"; print MAIL "------------------\n\n"; print MAIL "Dear pkgsrc user,\n\n"; print MAIL "you appear as the maintainer of several packages "; print MAIL "which are currently\n"; print MAIL "outdated, according to the doc/TODO file. You are "; print MAIL "encouraged to update\n"; print MAIL "these packages as soon as you can.\n\n"; print MAIL "Known outdated packages:\n\n"; @mailpkgs = split / /, $maint{"$mail"}; foreach (sort @mailpkgs) { print MAIL " -> $_ (" . $oodate{"$_"} . ")\n"; } print MAIL "\nIf you will not be able to maintain any of these "; print MAIL "packages any more,\n"; print MAIL "please let us know (packages\@netbsd.org) so we can "; print MAIL "pick up a new\n"; print MAIL "maintainer for the package(s).\n"; print MAIL "\nThank you.\n\n"; print MAIL "--\n"; print MAIL "The NetBSD Project: http://www.NetBSD.org/\n"; print MAIL "The NetBSD Packages Collection: http://www.pkgsrc.org/\n"; close(MAIL); } exit 0; # ------------------------------------------------------------------------- sub scan_pkgsrc { my ($cat, $pkg) = ("", ""); local *TOPDIR, *CATDIR; opendir(TOPDIR, "$PKGSRCDIR"); while ($cat = readdir(TOPDIR)) { next if ($cat =~ /^\./); next if ($cat eq "mk"); next if ($cat eq "distfiles"); next if ($cat eq "packages"); next if ($cat eq "CVS"); next if (! -d "$PKGSRCDIR/$cat"); opendir(CATDIR, "$PKGSRCDIR/$cat"); while ($pkg = readdir(CATDIR)) { next if ($pkg eq "CVS"); if (-d "$PKGSRCDIR/$cat/$pkg") { push @pkgs, "$cat/$pkg"; } } closedir(CATDIR); } closedir(TOPDIR); } sub scan_oodate { my ($pkgname, $pkg, $pkgquoted, $ver); local *TODO; open(TODO, "$PKGSRCDIR/doc/TODO"); while () { last if (/^Suggested package updates$/); } ; # Skip underline ITEM: while () { last ITEM if ($_ != "" && /^\t/ != ""); if (/^\to (\S+).*$/) { $pkgname=$1; if ($pkgname =~ /^(.*)-([0-9].*)$/) { $pkg = $1; $ver = $2; chop $pkg if $pkg =~ /-$/; foreach (@pkgs) { $pkgquoted = quotemeta $pkg; if (/\/$pkgquoted$/) { $oodate{"$_"} = $ver; next ITEM; } } print "Cannot locate pkgsrc directory of $pkg\n"; } else { print "Cannot determine package name of $pkgname\n"; } } elsif (/^\S/) { last ITEM; } } close(TODO); } sub sort_maintainers { my ($pkg, $m, $common); local *MKFILE; foreach $pkg (keys %oodate) { ($m, $common) = ("", ""); open(MKFILE, "$PKGSRCDIR/$pkg/Makefile"); while () { if (/^MAINTAINER[ \t]*\??=[ \t]*(.*)$/) { $m = $1; } elsif (/^\.include[ \t]+\"(.*Makefile.common)\"$/) { $common = $1; $common =~ s/\$\{.CURDIR\}/\./; } } close(MKFILE); if ($m eq "" && $common ne "") { open(MKFILE, "$PKGSRCDIR/$pkg/$common"); while () { if (/^MAINTAINER[ \t]*\??=[ \t]*(.*)$/) { $m = $1; } } close(MKFILE); } if ($m eq "") { print "Cannot determine maintainer of $pkg\n"; } else { $m = lc $m; $maint{"$m"} .= "$pkg "; } } }