mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Hopefully clarify/simplify configuration file stuff.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21796 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bfb6ebd9bc
commit
5fecb75c21
3 changed files with 103 additions and 179 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2005-10-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSPathUtilities.m: Remove backward compatibility hacks for
|
||||
old GNUsteprc support.
|
||||
Simplify code a little.
|
||||
Fix a retain/release bug.
|
||||
Fix per-user .GNUsteprc parsing to work as documented (ie override
|
||||
the system-window config, not just fill in undefined values).
|
||||
Deprecate use of '~' in per-user .GNUsteprc ... it adds complexity
|
||||
for little utility that I can see ... we can undeprecate it if I'm
|
||||
wrong.
|
||||
* Documentation/Base.gsdoc: Update to remove references to old config
|
||||
scheme. Remove documentation for deprecated '~' in per-user file
|
||||
Clarify how relative/absolute paths in config are treated.
|
||||
|
||||
2005-10-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSURLHandle.m: alter file handle to nitice if a file has
|
||||
|
|
|
@ -325,7 +325,7 @@ notice and this notice are preserved.
|
|||
<p>
|
||||
This environment variable, commonly set by the make system,
|
||||
is <strong>not</strong> used by GNUstep programs. Instead
|
||||
values from <code>.GNUsteprc</code> are used (see later).
|
||||
values from the GNUstep configuration file are used (see later).
|
||||
</p>
|
||||
</desc>
|
||||
<term>GNUSTEP_TARGET_CPU</term>
|
||||
|
@ -462,7 +462,7 @@ notice and this notice are preserved.
|
|||
can be used to set the base location of all the standard
|
||||
paths that GNUstep programs use or know about. The
|
||||
location of this file depends on how the Base library was
|
||||
configured and what operating system it was configured
|
||||
configured and/or what operating system it was configured
|
||||
on. On a GNU/Linux system, the default would be
|
||||
/etc/GNUstep/GNUstep.conf, for instance. This file is not
|
||||
required. If it does not appear, then default values will
|
||||
|
@ -482,56 +482,65 @@ notice and this notice are preserved.
|
|||
</p>
|
||||
<deflist>
|
||||
<term>USER_GNUSTEP_DIR</term>
|
||||
<desc>Path under user's home directory for user specific GNUstep resources (eg. 'GNUstep')</desc>
|
||||
<desc>Path for user specific GNUstep resources (eg. 'GNUstep').
|
||||
May be either an absolute path or a path relative to the
|
||||
user's home directory.</desc>
|
||||
<term>USER_GNUSTEP_RC</term>
|
||||
<desc>Name of user configuration file (eg. '.GNUsteprc')</desc>
|
||||
<desc>Name of user configuration file (eg. '.GNUsteprc')
|
||||
relative to the user's home directory.</desc>
|
||||
<term>USER_GNUSTEP_DEFAULTS</term>
|
||||
<desc>Name of directory in USER_GNUSTEP_DIR for user defaults files.</desc>
|
||||
<desc>Name of directory for user defaults files. Either an
|
||||
absolute path or relative to USER_GNUSTEP_DIR.</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
Support is provided to locate OS/PLATFORM directories. A conf file
|
||||
may provide the definitions below:
|
||||
</p>
|
||||
<deflist>
|
||||
<term>SYS_PREFS</term>
|
||||
<desc>Place for system/os preferences (eg. '/etc')</desc>
|
||||
<term>SYS_APPS</term>
|
||||
<desc>Place for system/os applications (eg. '/bin')</desc>
|
||||
<term>SYS_LIBS</term>
|
||||
<desc>Place for system/os shared libraries (eg. '/lib')</desc>
|
||||
<term>SYS_ADMIN</term>
|
||||
<desc>Place for system administration tools (eg. '/sbin')</desc>
|
||||
<term>PLATFORM_APPS</term>
|
||||
<desc>Place for non-gnustep applications (eg. '/usr/bin')</desc>
|
||||
<term>PLATFORM_LIBS</term>
|
||||
<desc>Place for application shared libraries (eg. '/usr/lib')</desc>
|
||||
<term>PLATFORM_RESOURCES</term>
|
||||
<desc>Place for shared application resources (eg. '/usr/share')</desc>
|
||||
<term>PLATFORM_ADMIN</term>
|
||||
<desc>Place for non-critical administrative tools (eg. '/usr/sbin')</desc>
|
||||
<term>PLATFORM_LOCAL_APPS</term>
|
||||
<desc>Place for machine local applications (eg. '/usr/local/bin')</desc>
|
||||
<term>PLATFORM_LOCAL_LIBS</term>
|
||||
<desc>Place for machine local shared libraries (eg. '/usr/local/lib/')</desc>
|
||||
<term>PLATFORM_LOCAL_RESOURCES</term>
|
||||
<desc>Place for machine local resources. (eg. '/usr/local/share')</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
These add to the path for NSSystemDomainMask, or
|
||||
NSLocalDomainMask as appropriate.
|
||||
</p>
|
||||
</subsect>
|
||||
<deflist>
|
||||
<term>SYS_PREFS</term>
|
||||
<desc>Place for system/os preferences (eg. '/etc')</desc>
|
||||
<term>SYS_APPS</term>
|
||||
<desc>Place for system/os applications (eg. '/bin')</desc>
|
||||
<term>SYS_LIBS</term>
|
||||
<desc>Place for system/os shared libraries (eg. '/lib')</desc>
|
||||
<term>SYS_ADMIN</term>
|
||||
<desc>Place for system administration tools (eg. '/sbin')</desc>
|
||||
<term>PLATFORM_APPS</term>
|
||||
<desc>Place for non-gnustep applications (eg. '/usr/bin')</desc>
|
||||
<term>PLATFORM_LIBS</term>
|
||||
<desc>Place for application shared libraries (eg. '/usr/lib')</desc>
|
||||
<term>PLATFORM_RESOURCES</term>
|
||||
<desc>Place for shared application resources (eg. '/usr/share')</desc>
|
||||
<term>PLATFORM_ADMIN</term>
|
||||
<desc>Place for non-critical administrative tools (eg. '/usr/sbin')</desc>
|
||||
<term>PLATFORM_LOCAL_APPS</term>
|
||||
<desc>Place for machine local applications (eg. '/usr/local/bin')</desc>
|
||||
<term>PLATFORM_LOCAL_LIBS</term>
|
||||
<desc>Place for machine local shared libraries (eg. '/usr/local/lib/')</desc>
|
||||
<term>PLATFORM_LOCAL_RESOURCES</term>
|
||||
<desc>Place for machine local resources. (eg. '/usr/local/share')</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
These add to the path for NSSystemDomainMask, or
|
||||
NSLocalDomainMask as appropriate.
|
||||
</p>
|
||||
</subsect>
|
||||
|
||||
<subsect>
|
||||
<heading>.GNUsteprc files</heading>
|
||||
<p>
|
||||
The locations of the directories in which user specific files and
|
||||
the user defaults database are stored are defined in the
|
||||
<code>.GNUsteprc</code> files.<br />
|
||||
the user defaults database are stored may be defined in the
|
||||
file given by USER_GNUSTEP_RC (by default,
|
||||
<code>.GNUsteprc</code>).<br />
|
||||
If no location is given for user specific files, they are stored
|
||||
in the GNUstep subdirectory of the users home directory.<br />
|
||||
in the locaton given by USER_GNUSTEP_DIR (by default, the
|
||||
<code>GNUstep</code> subdirectory of the users home
|
||||
directory).<br />
|
||||
If a separate location is not given for the defaults database, it
|
||||
is stored in the same directory as other user specific files.<br />
|
||||
is stored in the subdirectory of USER_GNUSTEP_DIR given by
|
||||
USER_GNUSTEP_DEFAULTS (by default, the <code>Defaults</code>
|
||||
subdirectory).<br />
|
||||
</p>
|
||||
<p>
|
||||
The presence of a <code>.GNUsteprc</code> file in a users home
|
||||
|
@ -542,39 +551,13 @@ notice and this notice are preserved.
|
|||
<term>GNUSTEP_DEFAULTS_ROOT=...</term>
|
||||
<desc>
|
||||
The text after the '=' is taken to be the path to the users
|
||||
defaults files. If it begins with a '~' character, the users home
|
||||
directory is prepended to it.
|
||||
defaults files (either absolute or relative to USER_GNUSTEP_DIR).
|
||||
</desc>
|
||||
<term>GNUSTEP_USER_ROOT=...</term>
|
||||
<desc>
|
||||
The text after the '=' is taken to be the path to the users
|
||||
files. If it begins with a '~' character, the users home
|
||||
directory is prepended to it.
|
||||
</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
The presence of a <code>.GNUsteprc</code> file in the
|
||||
GNUstep system directory may provide default paths for all
|
||||
users and may even override user specific files. This
|
||||
file has been deprecated in favor of the GNUstep
|
||||
Configuration File described above. The content of this
|
||||
file is as for the user specific file, but permits two
|
||||
additional commands:
|
||||
</p>
|
||||
<deflist>
|
||||
<term>FORCE_DEFAULTS_ROOT</term>
|
||||
<desc>
|
||||
If this line is present, and the file specifies a
|
||||
GNUSTEP_DEFAULTS_ROOT, then the value given in the system-wide
|
||||
file is used irrespective of the user specific file.
|
||||
Otherwise, the value in the user specific file takes precedence.
|
||||
</desc>
|
||||
<term>FORCE_USER_ROOT</term>
|
||||
<desc>
|
||||
If this line is present, and the file specifies a
|
||||
GNUSTEP_USER_ROOT, then the value given in the system-wide
|
||||
file is used irrespective of the user specific file.
|
||||
Otherwise, the value in the user specific file takes precedence.
|
||||
files. This may be an absolute path, or a path relative to
|
||||
the user's home directory.
|
||||
</desc>
|
||||
</deflist>
|
||||
</subsect>
|
||||
|
|
|
@ -152,12 +152,6 @@ static NSString *gnustep_flattened =
|
|||
/* Internal variables */
|
||||
/* ------------------ */
|
||||
|
||||
// For backwards compatibility
|
||||
static BOOL forceD;
|
||||
static BOOL forceU;
|
||||
static NSString *oldDRoot;
|
||||
static NSString *oldURoot;
|
||||
|
||||
static NSString *configFile;
|
||||
|
||||
/* names for the environment or conf-file variables */
|
||||
|
@ -279,21 +273,6 @@ getPathConfig(NSDictionary *dict, NSString *key)
|
|||
return path;
|
||||
}
|
||||
|
||||
|
||||
static NSString *
|
||||
removeTilde (NSString *home, NSString *val)
|
||||
{
|
||||
if ([val isEqual: @"~"])
|
||||
{
|
||||
val = @"";
|
||||
}
|
||||
else if ([val length] > 1 && [val characterAtIndex: 0] == '~')
|
||||
{
|
||||
val = [val substringFromIndex: 2];
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read .GNUsteprc file for user and set paths accordingly
|
||||
*/
|
||||
|
@ -301,18 +280,20 @@ static NSString *setUserGNUstepPath(NSString *userName,
|
|||
NSString **defaultsPath,
|
||||
NSString **userPath)
|
||||
{
|
||||
NSDictionary *dict;
|
||||
NSString *home, *path;
|
||||
NSString *steprcFile;
|
||||
NSString *userRoot;
|
||||
NSDictionary *dict;
|
||||
NSString *home;
|
||||
NSString *path;
|
||||
NSString *steprcFile;
|
||||
NSString *userRoot;
|
||||
|
||||
/* Look for rc file (".GNUsteprc") file in user's home directory */
|
||||
home = NSHomeDirectoryForUser(userName);
|
||||
if (home == nil)
|
||||
{
|
||||
/* It's OK if path is nil. We're might be running as user nobody in
|
||||
which case we don't want to access user stuff. Possibly it's a
|
||||
misconfigured Windows environment, though... */
|
||||
* which case we don't want to access user stuff. Possibly it's a
|
||||
* misconfigured Windows environment, though...
|
||||
*/
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -326,67 +307,43 @@ static NSString *setUserGNUstepPath(NSString *userName,
|
|||
path = [dict objectForKey: @"GNUSTEP_DEFAULTS_ROOT"];
|
||||
if (path != nil)
|
||||
{
|
||||
path = removeTilde(home, path);
|
||||
TEST_ASSIGN(*defaultsPath, path);
|
||||
/*
|
||||
* Special case for defaults root ... expand leading '~'
|
||||
*/
|
||||
if ([path hasPrefix: @"~"])
|
||||
{
|
||||
GSOnceFLog(@"Use of '~' in GNUSTEP_DEFAULTS_ROOT is deprecated");
|
||||
path = [path substringFromIndex: 1];
|
||||
while ([path hasPrefix: @"/"] || [path hasPrefix: @"\\"])
|
||||
{
|
||||
path = [path substringFromIndex: 1];
|
||||
}
|
||||
path = [home stringByAppendingPathComponent: path];
|
||||
}
|
||||
ASSIGN(*defaultsPath, path);
|
||||
}
|
||||
path = [dict objectForKey: @"GNUSTEP_USER_ROOT"];
|
||||
if (path != nil)
|
||||
{
|
||||
path = removeTilde(home, path);
|
||||
TEST_ASSIGN(*userPath, path);
|
||||
/*
|
||||
* For backward compatibility, remove leading '~' component
|
||||
* we will prepend the home directory later.
|
||||
*/
|
||||
if ([path hasPrefix: @"~"])
|
||||
{
|
||||
GSOnceFLog(@"Use of '~' in GNUSTEP_USER_ROOT is deprecated");
|
||||
path = [path substringFromIndex: 1];
|
||||
while ([path hasPrefix: @"/"] || [path hasPrefix: @"\\"])
|
||||
{
|
||||
path = [path substringFromIndex: 1];
|
||||
}
|
||||
}
|
||||
ASSIGN(*userPath, path);
|
||||
}
|
||||
RELEASE(dict);
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at the .GNUsteprc file in GNUSTEP_SYSTEM_ROOT. This is obsolete
|
||||
now that we are using the GNUstep conf file, but is kept in for
|
||||
transition purposes.
|
||||
*/
|
||||
steprcFile
|
||||
= [gnustepSystemRoot stringByAppendingPathComponent: @".GNUsteprc"];
|
||||
steprcFile = [steprcFile stringByStandardizingPath];
|
||||
if ([steprcFile isEqual: configFile] == NO)
|
||||
{
|
||||
dict = GSReadStepConfFile(steprcFile);
|
||||
if (dict != nil)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
PrintOnce("Warning: Configuration: The file %S has been "
|
||||
"deprecated. Please use the configuration file %s to "
|
||||
"set standard paths.\n",
|
||||
(const unichar*)[steprcFile fileSystemRepresentation],
|
||||
stringify(GNUSTEP_CONFIGURATION_FILE));
|
||||
#else
|
||||
PrintOnce("Warning: Configuration: The file %s has been "
|
||||
"deprecated. Please use the configuration file %s to "
|
||||
"set standard paths.\n",
|
||||
[steprcFile fileSystemRepresentation],
|
||||
stringify(GNUSTEP_CONFIGURATION_FILE));
|
||||
#endif
|
||||
forceD = [[dict objectForKey: @"FORCE_DEFAULTS_ROOT"] boolValue];
|
||||
forceU = [[dict objectForKey: @"FORCE_USER_ROOT"] boolValue];
|
||||
ASSIGN(oldDRoot, [dict objectForKey: @"GNUSTEP_DEFAULTS_ROOT"]);
|
||||
ASSIGN(oldURoot, [dict objectForKey: @"GNUSTEP_USER_ROOT"]);
|
||||
}
|
||||
}
|
||||
|
||||
if ((path = oldDRoot) != nil)
|
||||
{
|
||||
path = removeTilde(home, path);
|
||||
if (forceD)
|
||||
*defaultsPath = path;
|
||||
else
|
||||
TEST_ASSIGN(*defaultsPath, path);
|
||||
}
|
||||
if ((path = oldURoot) != nil)
|
||||
{
|
||||
path = removeTilde(home, path);
|
||||
if (forceU)
|
||||
*userPath = path;
|
||||
else
|
||||
TEST_ASSIGN(*userPath, path);
|
||||
}
|
||||
|
||||
/* set the user path and defaults directory to default values if needed */
|
||||
TEST_ASSIGN(*defaultsPath, DEFAULT_DEFAULTS_PATH);
|
||||
TEST_ASSIGN(*userPath, DEFAULT_USER_ROOT);
|
||||
|
@ -462,37 +419,6 @@ static void InitialisePathUtilities(void)
|
|||
gnustepDefaultsPath = [d objectForKey: @"USER_GNUSTEP_DEFAULTS"];
|
||||
gnustepUserPath = [d objectForKey: @"USER_GNUSTEP_DIR"];
|
||||
|
||||
{
|
||||
id o;
|
||||
// Next four are for backwards compatibility;
|
||||
o = [d objectForKey: @"FORCE_DEFAULTS_ROOT"];
|
||||
if (o != nil)
|
||||
{
|
||||
PrintOnce("Warning: Configuration: "
|
||||
"FORCE_DEFAULTS_ROOT is deprecated.\n");
|
||||
forceD = [o boolValue];
|
||||
}
|
||||
o = [d objectForKey: @"FORCE_USER_ROOT"];
|
||||
if (o != nil)
|
||||
{
|
||||
PrintOnce("Warning: Configuration: "
|
||||
"FORCE_USER_ROOT is deprecated.\n");
|
||||
forceU = [o boolValue];
|
||||
}
|
||||
ASSIGN(oldDRoot, [d objectForKey: @"GNUSTEP_DEFAULTS_ROOT"]);
|
||||
if (oldDRoot != nil)
|
||||
{
|
||||
PrintOnce("Warning: Configuration: "
|
||||
"GNUSTEP_DEFAULTS_ROOT is deprecated.\n");
|
||||
}
|
||||
ASSIGN(oldURoot, [d objectForKey: @"GNUSTEP_USER_ROOT"]);
|
||||
if (oldURoot != nil)
|
||||
{
|
||||
PrintOnce("Warning: Configuration: "
|
||||
"GNUSTEP_USER_ROOT is deprecated.\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OPTION_PLATFORM_SUPPORT
|
||||
osSysPrefs = getPathConfig(d, SYS_PREFS);
|
||||
osSysApps = getPathConfig(d, SYS_APPS);
|
||||
|
@ -648,7 +574,7 @@ GSReadStepConfFile(NSString *fileName)
|
|||
return nil;
|
||||
}
|
||||
|
||||
dict = [NSMutableDictionary dictionaryWithCapacity: 16];
|
||||
dict = [[NSMutableDictionary alloc] initWithCapacity: 16];
|
||||
if (dict == nil)
|
||||
{
|
||||
return nil; // should throw an exception??
|
||||
|
|
Loading…
Reference in a new issue