Skip to content

Commit

Permalink
Item14530: Merge branch 'bixycler-will' into Item14530
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Nov 21, 2017
2 parents b6f8186 + cb6098f commit 4277a98
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 15 deletions.
19 changes: 12 additions & 7 deletions core/lib/Foswiki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -132,36 +132,41 @@ $Foswiki::cfg{PermittedRedirectHostUrls} = '';
# ---++ File System Paths
# Configure the file system locations of key Foswiki directories here. These are usually guessed
# correctly during bootstrap. Other file locations are configured within their related sections.

# **PATH LABEL="Root Directory" FEEDBACK="icon='ui-icon-check';label='Validate Permissions'; method='validate_permissions';title='Validate file permissions. WARNING: this may take a long time on a large system'" CHECK="noemptyok perms:r,'*'" **
# This is the root file system path where all Foswiki directories should be placed.
# $Foswiki::cfg{RootDir} = '/home/httpd/foswiki';

# **PATH LABEL="Script Directory" FEEDBACK="icon='ui-icon-check';label='Validate Permissions'; method='validate_permissions';title='Validate file permissions.'" CHECK="noemptyok perms:Dx,'(.txt|.cfg)$'" **
# This is the file system path used to access the Foswiki bin directory.
# $Foswiki::cfg{ScriptDir} = '/home/httpd/foswiki/bin';
# $Foswiki::cfg{ScriptDir} = '$Foswiki::cfg{RootDir}/bin';

# **PATH LABEL="Pub Directory" FEEDBACK="icon='ui-icon-check';label='Validate Permissions'; method='validate_permissions';title='Validate file permissions. WARNING: this may take a long time on a large system'" CHECK="noemptyok perms:r,'*',wDn,'(,v|,pfv)$'" **
# Attachments store (file path, not URL), must match the attachments URL
# path =/foswiki/pub= - for example =/usr/local/foswiki/pub= This directory is
# normally accessible from the web.
# $Foswiki::cfg{PubDir} = '/home/httpd/foswiki/pub';
# $Foswiki::cfg{PubDir} = '$Foswiki::cfg{RootDir}/pub';

# **PATH LABEL="Data Directory" FEEDBACK="icon='ui-icon-check';label='Validate Permissions'; method='validate_permissions';title='Validate file permissions. WARNING: this may take a long time on a large system'" CHECK="noemptyok perms:rwDnpd,'(,v|,pfv)$',r" **
# Topic files store (file path, not URL). For example =/usr/local/foswiki/data=.
# This directory must not be web accessible.
# $Foswiki::cfg{DataDir} = '/home/httpd/foswiki/data';
# $Foswiki::cfg{DataDir} = '$Foswiki::cfg{RootDir}/data';

# **PATH LABEL="Tools Directory" FEEDBACK="icon='ui-icon-check';label='Validate Permissions'; method='validate_permissions'" CHECK="noemptyok perms:rD" **
# File path to tools directory. For example =/usr/local/foswiki/tools=.
# This directory must not be web accessible.
# $Foswiki::cfg{ToolsDir} = '/home/httpd/foswiki/tools';
# $Foswiki::cfg{ToolsDir} = '$Foswiki::cfg{RootDir}/tools';

# **PATH LABEL="Template Directory" FEEDBACK="icon='ui-icon-check';label='Validate Permissions'; method='validate_permissions'" CHECK="noemptyok perms:rD" **
# File path to templates directory. For example =/usr/local/foswiki/templates=.
# This directory must not be web accessible.
# $Foswiki::cfg{TemplateDir} = '/home/httpd/foswiki/templates';
# $Foswiki::cfg{TemplateDir} = '$Foswiki::cfg{RootDir}/templates';

# **PATH LABEL="Locales Directory" FEEDBACK="icon='ui-icon-check';label='Validate Permissions'; method='validate_permissions'" CHECK="noemptyok perms:rD" **
# File path to locale directory.
# For example =/usr/local/foswiki/locale=.
# This directory must not be web accessible.
# $Foswiki::cfg{LocalesDir} = '/home/httpd/foswiki/locale';
# $Foswiki::cfg{LocalesDir} = '$Foswiki::cfg{RootDir}/locale';

# **PATH LABEL="Working Directory" ONSAVE FEEDBACK="icon='ui-icon-check';label='Validate Permissions'; method='validate_permissions'" CHECK="noemptyok perms:rw,'[\//]README$',r" **
# Directory where Foswiki stores files that are required for the management
Expand All @@ -185,7 +190,7 @@ $Foswiki::cfg{PermittedRedirectHostUrls} = '';
# * ={WorkingDir}/registration_approvals= - this is used by the
# default Foswiki registration process to store registrations that
# are pending verification.
# $Foswiki::cfg{WorkingDir} = '/home/httpd/foswiki/working';
# $Foswiki::cfg{WorkingDir} = '$Foswiki::cfg{RootDir}/working';

# **PATH LABEL="Safe PATH" CHECK='undefok'**
# You can override the default PATH setting to control
Expand Down
35 changes: 30 additions & 5 deletions core/lib/Foswiki/Configure/Bootstrap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ sub setBootstrap {

# Bootstrap works out the correct values of these keys
my @BOOTSTRAP =
qw( {DataDir} {DefaultUrlHost} {ForceDefaultUrlHost} {DetailedOS} {OS} {PubUrlPath} {ToolsDir} {WorkingDir}
{PubDir} {TemplateDir} {ScriptDir} {ScriptUrlPath} {ScriptUrlPaths}{view}
{ScriptSuffix} {LocalesDir} {Store}{Implementation} {NFCNormalizeFilenames}
qw( {DefaultUrlHost} {ForceDefaultUrlHost} {DetailedOS} {OS} {PubUrlPath}
{ScriptUrlPath} {ScriptUrlPaths}{view}
{ScriptSuffix} {Store}{Implementation} {NFCNormalizeFilenames}
{Store}{SearchAlgorithm} {Site}{Locale} );

$Foswiki::cfg{isBOOTSTRAPPING} = 1;
push( @{ $Foswiki::cfg{BOOTSTRAP} }, @BOOTSTRAP );
push( @{ $Foswiki::cfg{BOOTSTRAP} }, keys %{ $Foswiki::cfg{BSDIRS} } );
}

=begin TML
Expand Down Expand Up @@ -189,15 +190,21 @@ sub bootstrapConfig {
dir => 'bin',
required => 1,
validate_file => 'setlib.cfg'
},
RootDir => {
dir => '',
required => 1,
validate_file => 'bin'
}
);

# Note that we don't resolve x/../y to y, as this might
# confuse soft links
my $root = File::Spec->catdir( $bin, File::Spec->updir() );
$root =~ s{\\}{/}g;
my $fatal = '';
my $warn = '';
my $fatal = '';
my $warn = '';
my %bsdirs = ();
while ( my ( $key, $def ) = each %rel_to_root ) {
$Foswiki::cfg{$key} = File::Spec->rel2abs( $def->{dir}, $root );
$Foswiki::cfg{$key} = abs_path( $Foswiki::cfg{$key} );
Expand Down Expand Up @@ -227,6 +234,17 @@ sub bootstrapConfig {
$warn .=
"\n * Note: {$key} could not be guessed. Set it manually!";
}

# Redirect all subdirs to be relative to the RootDir
if ( $key ne 'RootDir' ) {
$bsdirs{"{$key}"} = '$Foswiki::cfg{RootDir}/' . $def->{dir};
}
else {
$bsdirs{"{$key}"} = $Foswiki::cfg{$key};
}

# But we need to keep those unexpanded values out of $Foswiki::cfg
# until after the last expansion via readConfig().
}

# Bootstrap the Site Locale and CharSet
Expand All @@ -249,6 +267,13 @@ EPITAPH
# Don't load LocalSite.cfg if it exists (should normally not exist when bootstrapping)
Foswiki::Configure::Load::readConfig( 0, 0, 1, 1 );

# (At the moment of writing this line,)
# the line above is the **last expansion of $Foswiki::cfg**
$Foswiki::cfg{BSDIRS} = \%bsdirs;
print STDERR "AUTOCONFIG BSDIRS: "
. Data::Dumper->Dump( [ $Foswiki::cfg{BSDIRS} ] )
if (TRAUTO);

# Detect the OS and DetailedOS
workOutOS();
print STDERR
Expand Down
1 change: 1 addition & 0 deletions core/lib/Foswiki/Configure/Load.pm
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ CODE
if ( $^O eq 'MSWin32' ) {

#force paths to use '/'
$Foswiki::cfg{RootDir} =~ s|\\|/|g;
$Foswiki::cfg{PubDir} =~ s|\\|/|g;
$Foswiki::cfg{DataDir} =~ s|\\|/|g;
$Foswiki::cfg{ToolsDir} =~ s|\\|/|g;
Expand Down
14 changes: 11 additions & 3 deletions core/lib/Foswiki/Configure/Wizards/Save.pm
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ sub save {
}

my %save;
my %set = %{ $this->param('set') };

# Clear out the configuration and re-initialize it either
# with or without the .spec expansion. This also clears the
Expand All @@ -222,8 +223,13 @@ sub save {
foreach my $key ( @{ $Foswiki::cfg{BOOTSTRAP} } ) {
eval("(\$save$key)=\$Foswiki::cfg$key=~m/^(.*)\$/");
ASSERT( !$@, $@ ) if DEBUG;
delete $Foswiki::cfg{BOOTSTRAP};
}
delete $Foswiki::cfg{BOOTSTRAP};
print STDERR "BSDIRS set = "
. Data::Dumper->Dump( [ $Foswiki::cfg{BSDIRS} ] )
if TRACE_SAVE;
%set = ( %set, %{ $Foswiki::cfg{BSDIRS} } );
delete $Foswiki::cfg{BSDIRS};

%Foswiki::cfg = ();

Expand All @@ -244,8 +250,10 @@ sub save {

# Get changes from 'set' *without* expanding values. this is
# a cut-down from Foswiki::Configure::Query::_getSetParams
if ( $this->param('set') ) {
while ( my ( $k, $v ) = each %{ $this->param('set') } ) {
if (%set) {
print STDERR "Save set = " . Data::Dumper->Dump( [ \%set ] )
if TRACE_SAVE;
while ( my ( $k, $v ) = each %set ) {
my $spec = $root->getValueObject($k);
eval("\$spec->{old_value} = \$Foswiki::cfg$k") if $spec;
if ( $spec && defined $v && !ref($v) ) {
Expand Down

0 comments on commit 4277a98

Please sign in to comment.