3 # build-maintainerdb - convert several Packages files to maintainer database
4 # Copyright (c) 1998,9,2001,3,4,6 Martin Schulze <joey@debian.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # . Read maintainer changes from overrides file(s), need to rub
24 # out all existing entries
29 # read the configuration
30 if (!open (C, "../config.sh")) {
31 print "\nInternal Error: Cannot open configuration file.\n\n";
34 my $topdir = "/org/packages.debian.org";
36 $topdir = $1 if (/^\s*topdir="?(.*)"?\s*$/);
40 my $maildomain = "packages.debian.org";
42 my $maintainerfile = "$topdir/archive/Maintainers";
43 my $maintainerdb = "$topdir/conf/maintainer";
44 my $overridefile = "$topdir/conf/maintainerdb.override";
45 my @postcall = ( "/usr/sbin/postmap", $maintainerdb );
50 sub package_maintainer
55 my $home = "/debian/home/$login";
58 if (-f "$home/.forward-$pkg") {
59 return "$login-$pkg\@master.debian.org";
72 open (F, "$file") || die "Can't open $file, $!";
73 printf "Reading %s\n", $file if ($opt_verbose);
78 $package=$1; $maint=$2;
79 if (! exists $maint{$package}) {
80 printf " EVAL (%s, \"%s\")\n", $package, $maint if ($opt_verbose > 2);
82 if (exists $maint{$package}) {
83 $maint{$package} .= " ";
84 printf " EXPAND (%s)\n", $package if ($opt_verbose > 2);
86 if ($maint =~ /.*<(.*)>/) {
87 $maint{$package} .= $1;
88 printf " ADD (%s, %s)\n", $package, $1 if ($opt_verbose > 2);
89 } elsif ($maint =~ /\s*(\S+)\s+\(.*\)/) {
90 $maint{$package} .= $1;
91 printf " ADD (%s, %s)\n", $package, $1 if ($opt_verbose > 2);
93 $maint{$package} .= $maint;
94 printf " ADD (%s, %s)\n", $package, $maint if ($opt_verbose > 2);
97 printf " %s: %s\n", $package, $maint{$package} if ($opt_verbose > 1);
99 if ($package =~ /(.*[^\d\.]+)([\d\.]*\d)$/) {
101 $maint{$pkgshort} = $maint{$package} if (! exists $maint{$pkgshort});
102 printf " %s: %s\n", $pkgshort, $maint{$package} if ($opt_verbose > 1);
104 if ($maint{$package} =~ /([^\@]+)\@(master\.)?debian\.org/) {
105 my $addrsave = $maint{$package} if ($opt_verbose > 1);
106 $maint{$package} = package_maintainer ($package, $1, $maint{$package});
107 printf " Changed to %s\n", $maint{$package} if ($opt_verbose > 1 && ($addrsave ne $maint{$package}));
108 if (length ($pkgshort) > 0) {
109 $maint{$pkgshort} = package_maintainer ($pkgshort, $1, $maint{$pkgshort});
113 printf "Skipping double $package\n" if ($opt_verbose);
114 printf "LINE: $_" if ($opt_verbose > 2);
124 printf "Writing to %s.new\n", $file if ($opt_verbose > 0);
125 open (CONF, ">$file.new") || die "Can't open $file.new, $!";
126 foreach my $package (sort(keys(%maint))) {
127 printf "%s -> %s\n", $package, $maint{$package} if ($opt_verbose > 1);
128 printf CONF "%s@%s\t%s\n", $package, $maildomain, $maint{$package};
131 printf "Renaming to %s\n", $file if ($opt_verbose > 0);
132 system "mv -f $file.new $file";
133 printf "Executing @postcall\n" if ($opt_verbose > 0);
139 print "build-maintainerdb - Build the maintainer db for packages.debian.org.\n";
140 print "-d debug, changes output file to ./maintainerdb\n";
141 print "-h This help\n";
142 print "-v Increase verbosity by 1\n";
143 print "-vv Increase verbosity by 2\n";
144 print "-vvv Increase verbosity by 3\n";
150 while ($#ARGV > -1) {
151 if ($ARGV[0] eq "-v") {
153 } elsif ($ARGV[0] eq "-vv") {
155 } elsif ($ARGV[0] eq "-vvv") {
157 } elsif ($ARGV[0] eq "-h") {
159 } elsif ($ARGV[0] eq "-d") {
160 $maintainerdb = "./maintainerdb";
165 &read_maintainer ($overridefile);
166 &read_maintainer ($maintainerfile);
168 &write_maintainer ($maintainerdb);