#! /usr/bin/perl # build-maintainerdb - convert several Packages files to maintainer database # Copyright (c) 1998,9,2001,3,4 Martin Schulze # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # $Id$ # Todo: # . Read maintainer changes from overrides file(s), need to rub # out all existing entries # read the configuration if (!open (C, "../config.sh")) { printf "\nInternal Error: Cannot open configuration file.\n\n"; exit 0; } while () { $topdir = $1 if (/^\s*topdir="?(.*)"?\s*$/); } close (C); $maintainerfile = "$topdir/archive/Maintainers"; $maintainerdb = "$topdir/files/maintainerdb"; $overridefile = "$topdir/conf/maintainerdb.override"; sub package_maintainer { my $pkg = shift; my $login = shift; my $addr = shift; my $home = "/debian/home/$login"; if (-d $home) { if (-f "$home/.forward-$pkg") { return "$login-$pkg\@master.debian.org"; } } return $addr; } sub read_maintainer { my $file = shift; my $package; my $maintainer; my $maint; open (F, "$file") || die "Can't open $file, $!"; printf "Reading %s\n", $file if ($opt_verbose); while () { next if (/^#/); next if (/^$/); /(\S+)\s+(.*)/; $package=$1; $maint=$2; if (! exists $maint{$package}) { printf " EVAL (%s, \"%s\")\n", $package, $maint if ($opt_verbose > 2); if (exists $maint{$package}) { $maint{$package} .= " "; printf " EXPAND (%s)\n", $package if ($opt_verbose > 2); } if ($maint =~ /.*<(.*)>/) { $maint{$package} .= $1; printf " ADD (%s, %s)\n", $package, $1 if ($opt_verbose > 2); } elsif ($maint =~ /\s*(\S+)\s+\(.*\)/) { $maint{$package} .= $1; printf " ADD (%s, %s)\n", $package, $1 if ($opt_verbose > 2); } else { $maint{$package} .= $maint; printf " ADD (%s, %s)\n", $package, $maint if ($opt_verbose > 2); } printf " %s: %s\n", $package, $maint{$package} if ($opt_verbose > 1); $pkgshort = ""; if ($package =~ /(.*[^\d\.]+)([\d\.]*\d)$/) { $pkgshort = $1; $maint{$pkgshort} = $maint{$package} if (! exists $maint{$pkgshort}); printf " %s: %s\n", $pkgshort, $maint{$package} if ($opt_verbose > 1); } if ($maint{$package} =~ /([^\@]+)\@(master\.)?debian\.org/) { $addrsave = $maint{$package} if ($opt_verbose > 1); $maint{$package} = package_maintainer ($package, $1, $maint{$package}); printf " Changed to %s\n", $maint{$package} if ($opt_verbose > 1 && ($addrsave ne $maint{$package})); if (length ($pkgshort) > 0) { $maint{$pkgshort} = package_maintainer ($pkg, $1, $maint{$pkgshort}); } } } else { printf "Skipping double $package\n" if ($opt_verbose); printf "LINE: $_" if ($opt_verbose > 2); } } close (F); } sub write_maintainer { my $file = shift; printf "Writing to %s.new\n", $file if ($opt_verbose > 0); open (CONF, ">$file.new") || die "Can't open $file.new, $!"; foreach $package (sort(keys(%maint))) { printf "%s -> %s\n", $package, $maint{$package} if ($opt_verbose > 1); printf CONF "%s:%s\n", $package, $maint{$package}; } close (CONF); printf "Renaming to %s\n", $file if ($opt_verbose > 0); system "mv -f $file.new $file"; } sub help { print "build-maintainerdb - Build the maintainer db for packages.debian.org.\n"; print "-d debug, changes output file to ./maintainerdb\n"; print "-h This help\n"; print "-v Increase verbosity by 1\n"; print "-vv Increase verbosity by 2\n"; print "-vvv Increase verbosity by 3\n"; } # # Main program # $opt_verbose = 0; while ($#ARGV > -1) { if ($ARGV[0] eq "-v") { $opt_verbose++; } elsif ($ARGV[0] eq "-vv") { $opt_verbose+= 2; } elsif ($ARGV[0] eq "-vvv") { $opt_verbose+= 3; } elsif ($ARGV[0] eq "-h") { help(); } elsif ($ARGV[0] eq "-d") { $maintainerdb = "./maintainerdb"; } shift; } &read_maintainer ($overridefile); &read_maintainer ($maintainerfile); &write_maintainer ($maintainerdb);