From c1cc3cc63b604086b0b5d917e28dbaae684851b4 Mon Sep 17 00:00:00 2001 From: ng0 Date: Tue, 1 Oct 2019 13:09:13 +0000 Subject: apply feedback by florian --- configure | 10 +------- configure.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.py.in | 72 --------------------------------------------------------- 3 files changed, 71 insertions(+), 81 deletions(-) create mode 100644 configure.py delete mode 100644 configure.py.in diff --git a/configure b/configure index c03fc63ad..812d0460b 100755 --- a/configure +++ b/configure @@ -102,17 +102,9 @@ if ! existence msgmerge; then echo "INFO: msgmerge(1) is missing" fi -# Remove leftover configure.py file -rm -f configure.py - -# Now we will just assume sed exists, -# and replace only the executable name. -sed -e "s,[@]PYTHON[@],$PYTHON,g" < ./configure.py.in > configure.py -chmod +x configure.py - # Call configure.py, assuming all went well. # $1 is read by configure.py as the prefix. # If $1 is empty, the python script checks the # environment for PREFIX. We might need more # variables and switches, such as DESTDIR. -./configure.py $@ +$PYTHON ./configure.py $@ diff --git a/configure.py b/configure.py new file mode 100644 index 000000000..1e813e0d0 --- /dev/null +++ b/configure.py @@ -0,0 +1,70 @@ +# This file is part of TALER +# (C) 2019 GNUnet e.V. +# +# Authors: +# Author: ng0 +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE +# LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +# THIS SOFTWARE. +# +# SPDX-License-Identifier: 0BSD + +import argparse +import os +import sys +import logging + +# This script so far generates config.mk. +# The only value it produces is prefix, +# which is either taken as the first argument +# to this script, or as --prefix=, or read +# from the environment variable PREFIX. +# +# TODO: Also respect DESTDIR ($PREFIX/$DESTDIR/rest). + + +def _read_prefix(): + logging.basicConfig(level=logging.DEBUG) + logger = logging.getLogger(__name__) + + if 'PREFIX' in os.environ: + logger.debug('PREFIX from environment') + myprefix = os.environ.get('PREFIX') + if myprefix is not None and os.path.isdir(myprefix) is True: + logger.debug('PREFIX from environment: %s', myprefix) + return myprefix + + else: + logger.debug('PREFIX from argv') + parser = argparse.ArgumentParser() + parser.add_argument("-p", + "--prefix", + type=str, + required=True, + help='Directory prefix for installation') + logger.debug('parser.parse_args step') + args = parser.parse_args() + logger.debug('%s', args) + myprefix = args.prefix + # if args.prefix is not None and os.path.isdir(myprefix) is True: + if args.prefix and os.path.isdir(myprefix) is True: + return myprefix + +def main(): + myprefix = str(_read_prefix()) + f = open('config.mk', 'w+') + f.write('# this file is autogenerated by ./configure\n') + f.write('prefix=' + myprefix + '\n') + f.close() + + +main() diff --git a/configure.py.in b/configure.py.in deleted file mode 100644 index 9369410ed..000000000 --- a/configure.py.in +++ /dev/null @@ -1,72 +0,0 @@ -#!@PYTHON@ - -# This file is part of TALER -# (C) 2019 GNUnet e.V. -# -# Authors: -# Author: ng0 -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE -# LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -# THIS SOFTWARE. -# -# SPDX-License-Identifier: 0BSD - -import argparse -import os -import sys -import logging - -# This script so far generates config.mk. -# The only value it produces is prefix, -# which is either taken as the first argument -# to this script, or as --prefix=, or read -# from the environment variable PREFIX. -# -# TODO: Also respect DESTDIR ($PREFIX/$DESTDIR/rest). - - -def _read_prefix(): - logging.basicConfig(level=logging.DEBUG) - logger = logging.getLogger(__name__) - - if 'PREFIX' in os.environ: - logger.debug('PREFIX from environment') - myprefix = os.environ.get('PREFIX') - if myprefix is not None and os.path.isdir(myprefix) is True: - logger.debug('PREFIX from environment: %s', myprefix) - return myprefix - - else: - logger.debug('PREFIX from argv') - parser = argparse.ArgumentParser() - parser.add_argument("-p", - "--prefix", - type=str, - required=True, - help='Directory prefix for installation') - logger.debug('parser.parse_args step') - args = parser.parse_args() - logger.debug('%s', args) - myprefix = args.prefix - # if args.prefix is not None and os.path.isdir(myprefix) is True: - if args.prefix and os.path.isdir(myprefix) is True: - return myprefix - -def main(): - myprefix = str(_read_prefix()) - f = open('config.mk', 'w+') - f.write('# this file is autogenerated by ./configure\n') - f.write('prefix=' + myprefix + '\n') - f.close() - - -main() -- cgit v1.2.3