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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 # . Read maintainer changes from overrides file(s), need to rub
22 # out all existing entries
27 # read the configuration
28 if (!open (C, "../config.sh")) {
29 print "\nInternal Error: Cannot open configuration file.\n\n";
32 my $topdir = "/org/packages.debian.org";
34 $topdir = $1 if (/^\s*topdir="?(.*)"?\s*$/);
38 my $maildomain = "packages.debian.org";
40 my $maintainerfile = "$topdir/archive/Maintainers";
41 my $maintainerdb = "$topdir/conf/maintainer";
42 my $overridefile = "$topdir/conf/maintainerdb.override";
43 my @postcall = ( "/usr/sbin/postmap", $maintainerdb );
48 sub package_maintainer
53 my $home = "/debian/home/$login";
56 if (-f "$home/.forward-$pkg") {
57 return "$login-$pkg\@master.debian.org";
70 open (F, "$file") || die "Can't open $file, $!";
71 printf "Reading %s\n", $file if ($opt_verbose);
76 $package=$1; $maint=$2;
77 if (! exists $maint{$package}) {
78 printf " EVAL (%s, \"%s\")\n", $package, $maint if ($opt_verbose > 2);
80 if (exists $maint{$package}) {
81 $maint{$package} .= " ";
82 printf " EXPAND (%s)\n", $package if ($opt_verbose > 2);
84 if ($maint =~ /.*<(.*)>/) {
85 $maint{$package} .= $1;
86 printf " ADD (%s, %s)\n", $package, $1 if ($opt_verbose > 2);
87 } elsif ($maint =~ /\s*(\S+)\s+\(.*\)/) {
88 $maint{$package} .= $1;
89 printf " ADD (%s, %s)\n", $package, $1 if ($opt_verbose > 2);
91 $maint{$package} .= $maint;
92 printf " ADD (%s, %s)\n", $package, $maint if ($opt_verbose > 2);
95 printf " %s: %s\n", $package, $maint{$package} if ($opt_verbose > 1);
97 if ($package =~ /(.*[^\d\.]+)([\d\.]*\d)$/) {
99 $maint{$pkgshort} = $maint{$package} if (! exists $maint{$pkgshort});
100 printf " %s: %s\n", $pkgshort, $maint{$package} if ($opt_verbose > 1);
102 if ($maint{$package} =~ /([^\@]+)\@(master\.)?debian\.org/) {
103 my $addrsave = $maint{$package} if ($opt_verbose > 1);
104 $maint{$package} = package_maintainer ($package, $1, $maint{$package});
105 printf " Changed to %s\n", $maint{$package} if ($opt_verbose > 1 && ($addrsave ne $maint{$package}));
106 if (length ($pkgshort) > 0) {
107 $maint{$pkgshort} = package_maintainer ($pkgshort, $1, $maint{$pkgshort});
111 printf "Skipping double $package\n" if ($opt_verbose);
112 printf "LINE: $_" if ($opt_verbose > 2);
122 printf "Writing to %s.new\n", $file if ($opt_verbose > 0);
123 open (CONF, ">$file.new") || die "Can't open $file.new, $!";
124 foreach my $package (sort(keys(%maint))) {
125 printf "%s -> %s\n", $package, $maint{$package} if ($opt_verbose > 1);
126 printf CONF "%s@%s\t%s\n", $package, $maildomain, $maint{$package};
129 printf "Renaming to %s\n", $file if ($opt_verbose > 0);
130 system "mv -f $file.new $file";
131 printf "Executing @postcall\n" if ($opt_verbose > 0);
137 print "build-maintainerdb - Build the maintainer db for packages.debian.org.\n";
138 print "-d debug, changes output file to ./maintainerdb\n";
139 print "-h This help\n";
140 print "-v Increase verbosity by 1\n";
141 print "-vv Increase verbosity by 2\n";
142 print "-vvv Increase verbosity by 3\n";
148 while ($#ARGV > -1) {
149 if ($ARGV[0] eq "-v") {
151 } elsif ($ARGV[0] eq "-vv") {
153 } elsif ($ARGV[0] eq "-vvv") {
155 } elsif ($ARGV[0] eq "-h") {
157 } elsif ($ARGV[0] eq "-d") {
158 $maintainerdb = "./maintainerdb";
163 &read_maintainer ($overridefile);
164 &read_maintainer ($maintainerfile);
166 &write_maintainer ($maintainerdb);