From 845f0d633fc37dfaec5938e8043bac8728f33dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 1 Apr 2013 19:21:03 +0200 Subject: [PATCH] fix issue #134 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- manuals/ponysay.texinfo | 28 ++++++++++---------- setup.py | 58 ++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/manuals/ponysay.texinfo b/manuals/ponysay.texinfo index 751b5e68..5ad89ae6 100644 --- a/manuals/ponysay.texinfo +++ b/manuals/ponysay.texinfo @@ -2024,43 +2024,43 @@ Change the section for the @command{cowsay} manpage. @opindex @option{--fortune-manpage-section} Change the section for the @command{fortune} manpage. -@item --with-ponies=/usr/share/ponysay/ponies +@item --with-ponies @opindex @option{--with-ponies} @opindex @option{--without-ponies} -Install standard xterm ponies, and select installation directory for them. (Default) +Install standard xterm ponies. (Default) -@item --with-ttyponies=/usr/share/ponysay/ttyponies +@item --with-ttyponies @opindex @option{--with-ttyponies} @opindex @option{--without-ttyponies} -Install standard tty ponies, and select installation directory for them. (Default) +Install standard tty ponies. (Default) -@item --with-extraponies=/usr/share/ponysay/extraponies +@item --with-extraponies @opindex @option{--with-extraponies} @opindex @option{--without-extraponies} -Install extra xterm ponies, and select installation directory for them. (Default) +Install extra xterm ponies. (Default) -@item --with-extrattyponies=/usr/share/ponysay/extrattyponies +@item --with-extrattyponies @opindex @option{--with-extrattyponies} @opindex @option{--without-extrattyponies} -Install extra tty ponies, and select installation directory for them. (Default) +Install extra tty ponies. (Default) -@item --with-quotes=/usr/share/ponysay/quotes +@item --with-quotes @opindex @option{--with-quotes} @opindex @option{--without-quotes} -Install pony quotes, and select installation directory for them. (Default) +Install pony quotes. (Default) -@item --with-balloons=/usr/share/ponysay/balloons +@item --with-balloons @opindex @option{--with-balloons} @opindex @option{--without-balloons} -Install balloon styles, and select installation directory for them. (Default) +Install balloon styles. (Default) @item --with-ucs -@itemx --with-ucs-names=/usr/share/ponysay/ucsmap +@itemx --with-ucs-names @opindex @option{--with-ucs} @opindex @option{--without-ucs} @opindex @option{--with-ucs-names} @opindex @option{--without-ucs-names} -Install UCS pony names, and select installation file name for the map. (Default) +Install UCS pony names. (Default) @item --without-custom-env-python @opindex @option{--without-custom-env-python} diff --git a/setup.py b/setup.py index 1c052f34..f77866c1 100755 --- a/setup.py +++ b/setup.py @@ -178,17 +178,17 @@ class Setup(): for dir in sharedirs: - opts.add_argumentless(help = 'Do not install ' + dir[0], + opts.add_argumentless(help = 'Do not install ' + dir[1], alternatives = ['--without-' + dir[0]]) - opts.add_argumented (help = 'Set directory for %s\nDefault = $SHAREDIR/ponysay/%s' % (dir[1], dir[0]), - alternatives = [ '--with-' + dir[0]], arg=dir[2]) + opts.add_argumentless(help = 'Install %s\nDefault' % dir[1], + alternatives = [ '--with-' + dir[0]]) opts.add_argumentless(help = 'Do not install UCS pony name map', alternatives = ['--without-ucs', '--without-ucs-names']) - opts.add_argumented (help = 'Set file for the UCS pony name map\nDefault = $SHAREDIR/ponysay/ucsmap', - alternatives = ['--with-ucs', '--with-ucs-names'], arg='UCSFILE') + opts.add_argumentless(help = 'Install UCS pony name map\nDefault', + alternatives = ['--with-ucs', '--with-ucs-names']) opts.add_argumentless(help = 'Let the installer set the env name for python in ponysay\nDefault', @@ -348,10 +348,10 @@ class Setup(): else: print(RED % ('Skipping compression of ' + man[1] + ' manpage')) for man in mansections: print(GREEN % ('References to manpage for ' + man[0] + ' points to section ', conf['man-section-' + man[0]])) for dir in sharedirs: - if conf[dir[0]] is not None: print(GREEN % ('Installing ' + dir[1] + ' to ', conf[dir[0]])) + if conf[dir[0]] is not None: print(GREEN % ('Installing ' + dir[1] + ' to ', conf['share-dir'] + '/' + dir[0])) else: print(RED % ('Skipping installation of ' + dir[1])) for file in sharefiles: - if conf[file[0]] is not None: print(GREEN % ('Installing ' + file[1] + ' as ', conf[file[0]])) + if conf[file[0]] is not None: print(GREEN % ('Installing ' + file[1] + ' as ', conf['share-dir'] + '/' + file[0])) else: print(RED % ('Skipping installation of ' + file[1])) 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')) @@ -413,10 +413,7 @@ class Setup(): data = data.replace('#!/usr/bin/env python3', '#!/usr/bin/env ' + env) else: data = data.replace('#!/usr/bin/env python', '#!/usr/bin/env ' + env) - for sharedir in [item[0] for item in sharedirs]: - data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir]) - for sharefile in sharefiles: - data = data.replace('/usr/share/ponysay/' + sharefile[1], conf[sharefile[0]]) + data = data.replace('/usr/share/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/')) data = data.replace('/etc/', conf['sysconf-dir'] + ('' if conf['sysconf-dir'].endswith('/') else '/')) data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION)) @@ -508,8 +505,7 @@ class Setup(): data = data.replace('/usr/bin/ponysay', conf[command]) data = data.replace('/ponysay', '\0') data = data.replace('ponysay', command) - for sharedir in [item[0] for item in sharedirs]: - data = data.replace('/usr/share/ponysay/' + sharedir, conf[sharedir]) + data = data.replace('/usr/share/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/')) data = data.replace('\0', '/ponysay') fileout.write(data.encode('utf-8')) @@ -624,12 +620,16 @@ class Setup(): dest = '%s/%s/%s.%s%s' % (conf[key], sub, command, section, '' if conf[key + '-compression'] is None else '.' + conf[key + '-compression']) dests.append(dest) self.cp(False, src, dests) + ponyshare = conf['share-dir'] + if not ponyshare.endswith('/'): + ponyshare += '/' + ponyshare += 'ponysay/' for dir in sharedirs: if conf[dir[0]] is not None: - self.cp(True, dir[0], [conf[dir[0]]], Setup.validateFreedom if self.free else None) + self.cp(True, dir[0], [ponyshare + dir[0]], Setup.validateFreedom if self.free else None) for file in sharefiles: if conf[file[0]] is not None: - self.cp(False, 'share/' + file[1], [conf[file[0]]], Setup.validateFreedom if self.free else None) + self.cp(False, 'share/' + file[1], [ponyshare + file[0]], Setup.validateFreedom if self.free else None) for file in miscfiles: self.cp(False, file[0], [conf[file[0]]], Setup.validateFreedom if self.free else None) print() @@ -671,12 +671,16 @@ class Setup(): for command in commands: if conf[command] is not None: files.append('%s/%s/%s.%s%s' % (conf[key], sub, command, section, '' if conf[key + '-compression'] is None else '.' + conf[key + '-compression'])) + ponyshare = conf['share-dir'] + if not ponyshare.endswith('/'): + ponyshare += '/' + ponyshare += 'ponysay/' for dir in sharedirs: if conf[dir[0]] is not None: - dirs.append(conf[dir[0]]) + dirs.append(ponyshare + dir[0]) for file in sharefiles: if conf[file[0]] is not None: - files.append(conf[file[0]]) + files.append(ponyshare + file[0]) for file in miscfiles: files.append(conf[file[0]]) @@ -929,14 +933,18 @@ class Setup(): for manpage in manpages: conf['man-' + manpage[0]] = '/usr/share/man' conf['man-' + manpage[0] + '-compression'] = 'gz' - for sharedir in sharedirs: - conf[sharedir[0]] = '/usr/share/ponysay/' + sharedir[0] - for sharefile in sharefiles: - conf[sharefile[0]] = '/usr/share/ponysay/' + sharefile[1] conf['custom-env-python'] = 'python3' + for sharedir in sharedirs: + conf[sharedir[0]] = True + for sharefile in sharefiles: + conf[sharefile[0]] = True for miscfile in miscfiles: conf[miscfile[0]] = miscfile[1] conf['sysconf-dir'] = '/etc' + conf['bin-dir'] = '/usr/bin' + conf['lib-dir'] = '/usr/lib/ponysay' + conf['libexec-dir'] = '/usr/libexec/ponysay' + conf['share-dir'] = '/usr/share' if opts['--private'] is not None: @@ -956,12 +964,8 @@ class Setup(): if opts['--bin-dir'] is None: opts['--bin-dir'] = ['/opt/ponysay/bin'] if opts['--lib-dir'] is None: opts['--lib-dir'] = ['/opt/ponysay/lib'] if opts['--libexec-dir'] is None: opts['--libexec-dir'] = ['/opt/ponysay/libexec'] - if opts['--share-dir'] is None: opts['--share-dir'] = ['/usr/share'] + if opts['--share-dir'] is None: opts['--share-dir'] = ['/opt/ponysay/share'] if opts['--with-shared-cache'] is None: opts['--with-shared-cache'] = ['/var/opt/ponysay/cache'] - for sharedir in sharedirs: - conf[sharedir[0]] = '/opt/ponysay/share/' + sharedir[0] - for sharefile in sharefiles: - conf[sharefile[0]] = '/opt/ponysay/share/' + sharefile[1] for dir in ['bin', 'lib', 'libexec', 'share']: if opts['--' + dir + '-dir'] is not None: @@ -980,7 +984,7 @@ class Setup(): conf[key] = dir + conf[key][10:] if opts['--sysconf-dir'] is not None: - conf['sysconf-dir'] = ['--sysconf-dir'] + conf['sysconf-dir'] = opts['--sysconf-dir'][0] for key in conf: defaults[key] = conf[key]