add setup option --sysconf-dir this will change /etc in ponysay to any other directory, this way, if you do not use unix, you can set the system wide ponysayrc file

This commit is contained in:
Mattias Andrée 2012-11-02 02:34:33 +01:00
parent bf43882ca4
commit 3cd825d0bf
2 changed files with 13 additions and 1 deletions

View file

@ -1881,6 +1881,10 @@ edge distributors should specify it if it differs from prefered.
@opindex @option{--share-dir} @opindex @option{--share-dir}
Set the system's directory for resource files. Set the system's directory for resource files.
@item --sysconf-dir=/etc
@opindex @option{--sysconf-dir}
Set the system's local specific configuration directory.
@item --cache-dir=/var/cache @item --cache-dir=/var/cache
@opindex @option{--cache-dir} @opindex @option{--cache-dir}
Set the system's directory for cache directories. Set the system's directory for cache directories.

View file

@ -214,11 +214,14 @@ class Setup():
alternatives = ['--lib-dir'], arg='LIBDIR') alternatives = ['--lib-dir'], arg='LIBDIR')
opts.add_argumented (help = 'Set the system\'s directory for non-command executables\nDefault = $PREFIX/libexec/ponysay\nNot used.', opts.add_argumented (help = 'Set the system\'s directory for non-command executables\nDefault = $PREFIX/libexec/ponysay\nNot used.',
alternatives = ['--libexec-dir'], arg='LIBDIR') alternatives = ['--libexec-dir'], arg='LIBEXECDIR')
opts.add_argumented (help = 'Set the system\'s directory for resource files\nDefault = $PREFIX/share', opts.add_argumented (help = 'Set the system\'s directory for resource files\nDefault = $PREFIX/share',
alternatives = ['--share-dir'], arg='SHAREDIR') alternatives = ['--share-dir'], arg='SHAREDIR')
opts.add_argumented (help = 'Set the system\'s local specific configuration directory\nDefault = /etc',
alternatives = ['--sysconf-dir'], arg='SYSCONFDIR')
opts.add_argumented (help = 'Set the system\'s directory for cache directories\nDefault = /var/cache', opts.add_argumented (help = 'Set the system\'s directory for cache directories\nDefault = /var/cache',
alternatives = ['--cache-dir'], arg='CACHEDIR') alternatives = ['--cache-dir'], arg='CACHEDIR')
@ -331,6 +334,7 @@ class Setup():
if conf['custom-env-python'] is not None: print(GREEN % ('Using custom env reference in python script shebang: ', conf['custom-env-python'])) if conf['custom-env-python'] is not None: print(GREEN % ('Using custom env reference in python script shebang: ', conf['custom-env-python']))
else: print(YELLOW % ('Looking for best env reference in python script shebang')) else: print(YELLOW % ('Looking for best env reference in python script shebang'))
for miscfile in miscfiles: print(GREEN % ('Installing ' + miscfile[0] + ' to ', conf[miscfile[0]])) for miscfile in miscfiles: print(GREEN % ('Installing ' + miscfile[0] + ' to ', conf[miscfile[0]]))
print('Using system configuration directory: ' + conf['sysconf-dir'])
print('Prefered linking style: ' + self.linking) print('Prefered linking style: ' + self.linking)
print() print()
@ -386,6 +390,7 @@ class Setup():
data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir]) data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir])
for sharefile in sharefiles: for sharefile in sharefiles:
data = data.replace('/usr/share/ponysay/' + sharefile[1], conf[sharefile[0]]) data = data.replace('/usr/share/ponysay/' + sharefile[1], conf[sharefile[0]])
data = data.replace('/etc/', conf['sysconf-dir'] + ('' if conf['sysconf-dir'].endswith('/') else '/'))
data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION)) data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION))
fileout.write(data.encode('utf-8')) fileout.write(data.encode('utf-8'))
@ -872,6 +877,7 @@ class Setup():
conf['custom-env-python'] = 'python3' conf['custom-env-python'] = 'python3'
for miscfile in miscfiles: for miscfile in miscfiles:
conf[miscfile[0]] = miscfile[1] conf[miscfile[0]] = miscfile[1]
conf['sysconf-dir'] = '/etc'
if opts['--private'] is not None: if opts['--private'] is not None:
@ -914,6 +920,8 @@ class Setup():
if conf[key].startswith('/var/cache'): if conf[key].startswith('/var/cache'):
conf[key] = dir + conf[key][10:] conf[key] = dir + conf[key][10:]
if opts['--sysconf-dir'] is not None:
conf['sysconf-dir'] = ['--sysconf-dir']
for key in conf: for key in conf:
defaults[key] = conf[key] defaults[key] = conf[key]