3 # build-maintainerdb - convert several Packages files to maintainer database
4 # Copyright (c) 1998,9,2001,3,4 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
26 # read the configuration
27 if (!open (C, "../config.sh")) {
28 printf "\nInternal Error: Cannot open configuration file.\n\n";
32 $topdir = $1 if (/^\s*topdir="?(.*)"?\s*$/);
36 $maintainerfile = "$topdir/archive/Maintainers";
37 $maintainerdb = "$topdir/files/maintainerdb";
38 $overridefile = "$topdir/conf/maintainerdb.override";
40 sub package_maintainer
45 my $home = "/debian/home/$login";
48 if (-f "$home/.forward-$pkg") {
49 return "$login-$pkg\@master.debian.org";
62 open (F, "$file") || die "Can't open $file, $!";
63 printf "Reading %s\n", $file if ($opt_verbose);
68 $package=$1; $maint=$2;
69 if (! exists $maint{$package}) {
70 printf " EVAL (%s, \"%s\")\n", $package, $maint if ($opt_verbose > 2);
72 if (exists $maint{$package}) {
73 $maint{$package} .= " ";
74 printf " EXPAND (%s)\n", $package if ($opt_verbose > 2);
76 if ($maint =~ /.*<(.*)>/) {
77 $maint{$package} .= $1;
78 printf " ADD (%s, %s)\n", $package, $1 if ($opt_verbose > 2);
79 } elsif ($maint =~ /\s*(\S+)\s+\(.*\)/) {
80 $maint{$package} .= $1;
81 printf " ADD (%s, %s)\n", $package, $1 if ($opt_verbose > 2);
83 $maint{$package} .= $maint;
84 printf " ADD (%s, %s)\n", $package, $maint if ($opt_verbose > 2);
87 printf " %s: %s\n", $package, $maint{$package} if ($opt_verbose > 1);
89 if ($package =~ /(.*[^\d\.]+)([\d\.]*\d)$/) {
91 $maint{$pkgshort} = $maint{$package} if (! exists $maint{$pkgshort});
92 printf " %s: %s\n", $pkgshort, $maint{$package} if ($opt_verbose > 1);
94 if ($maint{$package} =~ /([^\@]+)\@(master\.)?debian\.org/) {
95 $addrsave = $maint{$package} if ($opt_verbose > 1);
96 $maint{$package} = package_maintainer ($package, $1, $maint{$package});
97 printf " Changed to %s\n", $maint{$package} if ($opt_verbose > 1 && ($addrsave ne $maint{$package}));
98 if (length ($pkgshort) > 0) {
99 $maint{$pkgshort} = package_maintainer ($pkg, $1, $maint{$pkgshort});
103 printf "Skipping double $package\n" if ($opt_verbose);
104 printf "LINE: $_" if ($opt_verbose > 2);
114 printf "Writing to %s.new\n", $file if ($opt_verbose > 0);
115 open (CONF, ">$file.new") || die "Can't open $file.new, $!";
116 foreach $package (sort(keys(%maint))) {
117 printf "%s -> %s\n", $package, $maint{$package} if ($opt_verbose > 1);
118 printf CONF "%s:%s\n", $package, $maint{$package};
121 printf "Renaming to %s\n", $file if ($opt_verbose > 0);
122 system "mv -f $file.new $file";
127 print "build-maintainerdb - Build the maintainer db for packages.debian.org.\n";
128 print "-d debug, changes output file to ./maintainerdb\n";
129 print "-h This help\n";
130 print "-v Increase verbosity by 1\n";
131 print "-vv Increase verbosity by 2\n";
132 print "-vvv Increase verbosity by 3\n";
139 while ($#ARGV > -1) {
140 if ($ARGV[0] eq "-v") {
142 } elsif ($ARGV[0] eq "-vv") {
144 } elsif ($ARGV[0] eq "-vvv") {
146 } elsif ($ARGV[0] eq "-h") {
148 } elsif ($ARGV[0] eq "-d") {
149 $maintainerdb = "./maintainerdb";
154 &read_maintainer ($overridefile);
155 &read_maintainer ($maintainerfile);
157 &write_maintainer ($maintainerdb);