Configuration system improvements.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25915 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2008-01-10 11:14:30 +00:00
parent e4ca2f34af
commit 6079944b00
6 changed files with 152 additions and 20 deletions

View file

@ -1,3 +1,12 @@
2008-01-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPathUtilities.m: Allow '../' to indicate a relocatable
resource. Add suypport for GlobalDefaults.plist.
* Source/NSUserDefaults.m: Improve documentation
* Documentation/ReleaseNotes.gsdoc: Note recent changes.
* Documentation/Base.gsdoc: Improve documentation
* Headers/Foundation/NSUserDefaults.h: Improve comments.
2008-01-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSSocketStream.m: tweak TLS code

View file

@ -581,7 +581,9 @@ notice and this notice are preserved.
<p>
All the above values from the configuration file are made
available in the NSUserDefaults system at runtime, in the
GSConfigDomain of the defaults.<br />
GSConfigDomain (along with any defaults provided in the
GlobalDefaults.plist file in the same directory as the
config file).<br />
In addition, the configuration file may contain the key
<em>GNUSTEP_EXTRA</em> with a value set to be a comma separated
list of extra key names which are to be allowed in the config
@ -631,10 +633,11 @@ notice and this notice are preserved.
<p>
Firstly, variables in the configuration file which define
paths, are expected to by full path specifications, except
for the special case in which they begin with dot-slash (./).
In this case the text after the dot-slash is appended to
the path to the directory containing the configuration file
(or specified to contain the configuration file if no
for the special case in which they begin with dot-slash (./)
or dot-dot-slash (../).
In this case the path from the variable is appended to the
path of the directory containing the configuration file
(or the path specified to contain the configuration file if no
configuration file exists) to form the value used.
</p>
<p>
@ -642,10 +645,8 @@ notice and this notice are preserved.
as the location of the config file (or specified by
the GNUSTEP_CONFIG_FILE environment variable unless that option
was disabled when the base library was configured)
begins with a dot and slash (./) then the path used for that
file is made relative to the base library.<br />
ie the text after the dot-slash is appended to the path of the
directory containing the gnustep-base library.
begins with a dot-slash (./) or dot-dot-slash (../) then the path
used for that file is made relative to the base library.
</p>
<p>
So you can bundle the whole lot together in one directory,
@ -660,7 +661,7 @@ notice and this notice are preserved.
a path with a trailing slash so that the base library will
<em>not</em> read it, and will use the builtin default values.<br />
To do this, you would configure using the options
<code>--with-config-file=./</code> and
<code>--with-config-file=not-used/</code> and
<code>--with-default-file=myConfig</code> where <em>myConfig</em>
is a file containing the paths you want to use relative to the
location the base library gets installed in.<br />

View file

@ -28,6 +28,36 @@ notice and this notice are preserved.
changes and other information that might help developers and users
migrate to using a newer version of the library.
</p>
<section>
<heading>Version 1.15.3</heading>
<p>
This is an unstable release.
</p>
Highlights:
<deflist>
<term>Configuration/NSUserDefaults</term>
<desc>
Syntax withing the configuration file extended so that a leading
'../' in a path name denotes a relative path nin a relocatable
installation.<br />
New 'GlobalDefaults.plist' file in the same directory as the main
GNUstep config file allows packagers/sysadmins to set up global
defaults easily.
</desc>
<term>NSStream</term>
<desc>
Addition of TLS/SSL support using GNU TLS on both unix-like
and mswindows systems. First draft.<br />
Additions of SOCKS proxying support for socket streams. First draft.
</desc>
<term>NSURLConnection</term>
<desc>
Added support for https using new stream code.<br />
Added support for basic and digest authentrication.
</desc>
</deflist>
</section>
<section>
<heading>Version 1.15.2</heading>
<p>

View file

@ -63,7 +63,8 @@ GS_EXPORT NSString* const NSRegistrationDomain;
#ifndef NO_GNUSTEP
/**
* User defaults domain for GNUstep config file.
* User defaults domain for GNUstep config file and for any defaults
* stored in the GlobalDefaults.plist file alongside the config file.
*/
GS_EXPORT NSString* const GSConfigDomain;
#endif

View file

@ -279,6 +279,11 @@ getPath(NSString *path)
[path substringFromIndex: 2]];
path = [path stringByStandardizingPath];
}
else if ([path hasPrefix: @"../"] == YES)
{
path = [gnustepConfigPath stringByAppendingPathComponent: path];
path = [path stringByStandardizingPath];
}
return path;
}
@ -322,7 +327,7 @@ getPathConfig(NSDictionary *dict, NSString *key)
static void ExtractValuesFromConfig(NSDictionary *config)
{
NSMutableDictionary *c = [config mutableCopy];
NSString *extra;
id extra;
/*
* Move values out of the dictionary and into variables for rapid reference.
@ -394,7 +399,11 @@ static void ExtractValuesFromConfig(NSDictionary *config)
NSEnumerator *enumerator;
NSString *key;
enumerator = [[extra componentsSeparatedByString: @","] objectEnumerator];
if ([extra isKindOfClass: [NSString class]] == YES)
{
extra = [extra componentsSeparatedByString: @","];
}
enumerator = [extra objectEnumerator];
[c removeObjectForKey: @"GNUSTEP_EXTRA"];
while ((key = [enumerator nextObject]) != nil)
{
@ -402,6 +411,7 @@ static void ExtractValuesFromConfig(NSDictionary *config)
[c removeObjectForKey: key];
}
}
[c removeObjectForKey: @"GNUSTEP_SYSTEM_DEFAULTS_FILE"];
/*
* Remove any other dictionary entries we have used.
@ -623,18 +633,21 @@ GNUstepConfig(NSDictionary *newConfig)
/*
* Special case ... if the config file location begins './'
* then we determine it's actual path by working relative
* to the gnustep-base library.
* or '../' then we determine it's actual path by working
* relative to the gnustep-base library.
*/
if ([file hasPrefix: @"./"] == YES)
if ([file hasPrefix: @"./"] == YES
|| [file hasPrefix: @"../"] == YES)
{
Class c = [NSProcessInfo class];
NSString *path = GSPrivateSymbolPath (c, 0);
// Remove library name from path
path = [path stringByDeletingLastPathComponent];
// Remove ./ prefix from filename
file = [file substringFromIndex: 2];
if ([file hasPrefix: @"./"] == YES)
{
file = [file substringFromIndex: 2];
}
// Join the two together
file = [path stringByAppendingPathComponent: file];
}
@ -678,9 +691,82 @@ GNUstepConfig(NSDictionary *newConfig)
}
else
{
NSString *defs;
gnustepConfigPath
= RETAIN([file stringByDeletingLastPathComponent]);
ParseConfigurationFile(file, conf, nil);
defs = [gnustepConfigPath stringByAppendingPathComponent:
@"GlobalDefaults.plist"];
if ([MGR() isReadableFileAtPath: defs] == YES)
{
NSDictionary *d;
NSDictionary *attributes;
attributes = [MGR() fileAttributesAtPath: defs
traverseLink: YES];
if (([attributes filePosixPermissions]
& (0022 & ATTRMASK)) != 0)
{
#if defined(__MINGW32__)
fprintf(stderr,
"The file '%S' is writable by someone other than"
" its owner (permissions 0%lo).\nIgnoring it.\n",
[defs fileSystemRepresentation],
[attributes filePosixPermissions]);
#else
fprintf(stderr,
"The file '%s' is writable by someone other than"
" its owner (permissions 0%lo).\nIgnoring it.\n",
[defs fileSystemRepresentation],
[attributes filePosixPermissions]);
#endif
d = nil;
}
else
{
d = [NSDictionary dictionaryWithContentsOfFile: defs];
}
if (d != nil)
{
NSEnumerator *enumerator;
NSString *key;
id extra;
extra = [conf objectForKey: @"GNUSTEP_EXTRA"];
extra = [extra componentsSeparatedByString: @","];
extra = [extra mutableCopy];
if (extra == nil)
{
extra = [NSMutableArray new];
}
enumerator = [d keyEnumerator];
while ((key = [enumerator nextObject]) != nil)
{
if ([conf objectForKey: key] == nil)
{
[extra addObject: key];
}
else
{
fprintf(stderr, "Key '%s' in '%s' duplicates"
" key in %s\n", [key UTF8String],
[defs UTF8String], [file UTF8String]);
}
}
[conf addEntriesFromDictionary: d];
if ([extra count] > 0)
{
NSArray *c = [extra copy];
[conf setObject: c forKey: @"GNUSTEP_EXTRA"];
RELEASE(c);
}
RELEASE(extra);
}
}
}
}
else
@ -1176,7 +1262,6 @@ ParseConfigurationFile(NSString *fileName, NSMutableDictionary *dict,
}
NSZoneFree(NSDefaultMallocZone(), src);
NSZoneFree(NSDefaultMallocZone(), dst);
return YES;
}

View file

@ -197,7 +197,13 @@ static void updateCache(NSUserDefaults *self)
* Information retrieved from the GNUstep configuration system.
* Usually the system wide and user specific GNUstep.conf files,
* or from information compiled in when the base library was
* built.
* built.<br />
* In addition to this standard configuration information, this
* domain contains all values from the GlobalDefaults.plist file
* stored in the same directory as the system widw GNUstep.conf
* file. The GlobalDefaults.plist allows packagers and system
* administrators to provide global defaults settings for all
* users of a particular GNUstep installation.
* </desc>
* <term><code>NSRegistrationDomain</code> ... volatile</term>
* <desc>