Commit 47d78d46 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Back out bug 147776, checksetup.pl now fills localconfig.old with a cryptic message

parent fb679ee6
...@@ -64,7 +64,6 @@ sub FILESYSTEM { ...@@ -64,7 +64,6 @@ sub FILESYSTEM {
my $libdir = bz_locations()->{'libpath'}; my $libdir = bz_locations()->{'libpath'};
my $extlib = bz_locations()->{'ext_libpath'}; my $extlib = bz_locations()->{'ext_libpath'};
my $skinsdir = bz_locations()->{'skinsdir'}; my $skinsdir = bz_locations()->{'skinsdir'};
my $localconfig = bz_locations()->{'localconfig'};
my $ws_group = Bugzilla->localconfig->{'webservergroup'}; my $ws_group = Bugzilla->localconfig->{'webservergroup'};
...@@ -117,8 +116,6 @@ sub FILESYSTEM { ...@@ -117,8 +116,6 @@ sub FILESYSTEM {
'sanitycheck.pl' => { perms => $ws_executable }, 'sanitycheck.pl' => { perms => $ws_executable },
'install-module.pl' => { perms => $owner_executable }, 'install-module.pl' => { perms => $owner_executable },
"$localconfig.old" => { perms => $owner_readable },
'docs/makedocs.pl' => { perms => $owner_executable }, 'docs/makedocs.pl' => { perms => $owner_executable },
'docs/rel_notes.txt' => { perms => $ws_readable }, 'docs/rel_notes.txt' => { perms => $ws_readable },
'docs/README.docs' => { perms => $owner_readable }, 'docs/README.docs' => { perms => $owner_readable },
......
...@@ -187,10 +187,12 @@ EOT ...@@ -187,10 +187,12 @@ EOT
}, },
); );
# When you read the symbol table of a package in Perl (like we do to use constant OLD_LOCALCONFIG_VARS => qw(
# get the localconfig variables), there are some symbols that are always mysqlpath
# there and should be ignored. contenttypes
use constant IGNORE_SYMBOLS => qw(_ INC __ANON__); pages
severities platforms opsys priorities
);
sub read_localconfig { sub read_localconfig {
my ($include_deprecated) = @_; my ($include_deprecated) = @_;
...@@ -219,24 +221,10 @@ Please fix the error in your 'localconfig' file. Alternately, rename your ...@@ -219,24 +221,10 @@ Please fix the error in your 'localconfig' file. Alternately, rename your
EOT EOT
} }
# First we have to get the whole symbol table my @vars = map($_->{name}, LOCALCONFIG_VARS);
my $safe_root = $s->root; push(@vars, OLD_LOCALCONFIG_VARS) if $include_deprecated;
my %safe_package; foreach my $var (@vars) {
{ no strict 'refs'; %safe_package = %{$safe_root . "::"}; } my $glob = $s->varglob($var);
# And now we read the contents of every var in the symbol table
# except those from IGNORE_SYMBOLS. If $include_deprecated is false,
# we also skip any vars that aren't specifically listed in
# LOCALCONFIG_VARS.
my @standard_vars = map($_->{name}, LOCALCONFIG_VARS);
foreach my $symbol (keys %safe_package) {
if (!$include_deprecated) {
next if !grep($_ eq $symbol, @standard_vars);
}
next if grep($_ eq $symbol, IGNORE_SYMBOLS);
# Perl 5.10 imports a lot of symbols that we want to ignore that
# all contain "::".
next if $symbol =~ /::/;
my $glob = $s->varglob($symbol);
# We can't get the type of a variable out of a Safe automatically. # We can't get the type of a variable out of a Safe automatically.
# We can only get the glob itself. So we figure out its type this # We can only get the glob itself. So we figure out its type this
# way, by trying first a scalar, then an array, then a hash. # way, by trying first a scalar, then an array, then a hash.
...@@ -246,13 +234,13 @@ EOT ...@@ -246,13 +234,13 @@ EOT
# fine since as I write this all modern localconfig vars are # fine since as I write this all modern localconfig vars are
# actually scalars. # actually scalars.
if (defined $$glob) { if (defined $$glob) {
$localconfig{$symbol} = $$glob; $localconfig{$var} = $$glob;
} }
elsif (defined @$glob) { elsif (defined @$glob) {
$localconfig{$symbol} = \@$glob; $localconfig{$var} = \@$glob;
} }
elsif (defined %$glob) { elsif (defined %$glob) {
$localconfig{$symbol} = \%$glob; $localconfig{$var} = \%$glob;
} }
} }
} }
...@@ -302,6 +290,11 @@ sub update_localconfig { ...@@ -302,6 +290,11 @@ sub update_localconfig {
} }
} }
my @old_vars;
foreach my $name (OLD_LOCALCONFIG_VARS) {
push(@old_vars, $name) if defined $localconfig->{$name};
}
if (!$localconfig->{'interdiffbin'} && $output) { if (!$localconfig->{'interdiffbin'} && $output) {
print <<EOT print <<EOT
...@@ -314,41 +307,30 @@ as well), you should install patchutils from: ...@@ -314,41 +307,30 @@ as well), you should install patchutils from:
EOT EOT
} }
my @old_vars;
foreach my $var (keys %$localconfig) {
push(@old_vars, $var) if !grep($_->{name} eq $var, LOCALCONFIG_VARS);
}
my $filename = bz_locations->{'localconfig'}; my $filename = bz_locations->{'localconfig'};
# Move any custom or old variables into a separate file.
if (scalar @old_vars) { if (scalar @old_vars) {
my $filename_old = "$filename.old";
open(my $old_file, ">>$filename_old") || die "$filename_old: $!";
local $Data::Dumper::Purity = 1;
foreach my $var (@old_vars) {
print $old_file Data::Dumper->Dump([$localconfig->{$var}],
["*$var"]) . "\n\n";
}
close $old_file;
my $oldstuff = join(', ', @old_vars); my $oldstuff = join(', ', @old_vars);
print <<EOT print <<EOT
The following variables are no longer used in $filename, and The following variables are no longer used in $filename, and
have been moved to $filename_old: $oldstuff should be removed: $oldstuff
EOT EOT
} }
# Re-write localconfig if (scalar @new_vars) {
open(my $fh, ">$filename") || die "$filename: $!"; my $filename = bz_locations->{'localconfig'};
foreach my $var (LOCALCONFIG_VARS) { my $fh = new IO::File($filename, '>>') || die "$filename: $!";
print $fh "\n", $var->{desc}, $fh->seek(0, SEEK_END);
Data::Dumper->Dump([$localconfig->{$var->{name}}], foreach my $var (LOCALCONFIG_VARS) {
["*$var->{name}"]); if (grep($_ eq $var->{name}, @new_vars)) {
} print $fh "\n", $var->{desc},
Data::Dumper->Dump([$localconfig->{$var->{name}}],
["*$var->{name}"]);
}
}
if (@new_vars) {
my $newstuff = join(', ', @new_vars); my $newstuff = join(', ', @new_vars);
print <<EOT; print <<EOT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment