From eaebfbb4887d9410bc89e75bd142d5213f44296b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 21 Apr 2020 16:13:03 +0530 Subject: remove bloat --- Makefile.inc | 6 ---- README | 20 ++---------- configure | 42 ++++++++++-------------- pyvercheck.py | 7 ++++ sh/bin.sh/python.sh | 37 --------------------- sh/lib.sh/existence.sh | 35 -------------------- sh/lib.sh/existence_python.sh | 76 ------------------------------------------- sh/lib.sh/msg.sh | 26 --------------- sh/lib.sh/progname.sh | 1 - sh/lib.sh/version_gnunet.sh | 5 --- 10 files changed, 26 insertions(+), 229 deletions(-) create mode 100644 pyvercheck.py delete mode 100755 sh/bin.sh/python.sh delete mode 100644 sh/lib.sh/existence.sh delete mode 100644 sh/lib.sh/existence_python.sh delete mode 100644 sh/lib.sh/msg.sh delete mode 100644 sh/lib.sh/progname.sh delete mode 100644 sh/lib.sh/version_gnunet.sh diff --git a/Makefile.inc b/Makefile.inc index a563ef4..35c2d42 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -3,12 +3,6 @@ # itself. BUILDCOMMON_SHLIB_FILES = \ - build-common/sh/bin.sh/python.sh \ - build-common/sh/lib.sh/existence.sh \ - build-common/sh/lib.sh/existence_python.sh \ - build-common/sh/lib.sh/msg.sh \ - build-common/sh/lib.sh/progname.sh \ - build-common/sh/lib.sh/version_gnunet.sh \ build-common/LICENSE BUILDCOMMON_CONF_FILES = \ diff --git a/README b/README index ee915fc..43c2e4f 100644 --- a/README +++ b/README @@ -4,28 +4,12 @@ A repository using these build-system files should be structured as follows: - bootstrap (copied/adjusted from bootstrap.template) +- configure.py (copied/adjusted from configure.py.template) - build-system (directory containing build system "stuff") ---| configure.py (copied/adjusted from bootstrap.template) --| taler-build-scripts (git submodule of taler-build-scripts) ---| Makefile -Makefile and configure.py can also be placed directly into the root of the -repository. However, this might lead to errors when "make" can be invoked -before bootstrap and configure has been done. - - -directory structure: +Directory Structure: -------------------- conf: - contains mixed configuration data, mostly for linters and editors - -sh: -- contains shell script code in reusable, importable pieces, - usually one function per file and files named after their - function. - the sh/lib.sh folder contains library code. - the sh/bin.sh folder contains executable scripts which can be - used for various functions. - Current caveat: the files all have to be included. shell independent - detection of real pathnames is tricky. diff --git a/configure b/configure index 7749566..ef7f697 100755 --- a/configure +++ b/configure @@ -1,20 +1,7 @@ #!/bin/sh -# This file is part of TALER -# (C) 2019 GNUnet e.V. -# -# This is very simple POSIX sh script which -# identifies the first matching -# python3 identifier in $PATH and produces -# configure.py from configure.py.in, and then -# calls the new executable configure.py. -# -# It should be portable on Unices. Report bugs on -# the bugtracker if you discover that it isn't -# working as intended. -# -# Authors: -# Author: ng0 +# This file is part of GNU Taler. +# (C) 2020 Taler Systems S.A. # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted. @@ -30,24 +17,29 @@ # # SPDX-License-Identifier: 0BSD -# we invoke configure not as a symlink but as a copy, -# so we have to use a fixed location for the repository! -dir=$(dirname "$(readlink -- "$0")")/build-system/taler-build-scripts -. $dir/sh/lib.sh/existence.sh -. $dir/sh/lib.sh/existence_python.sh +# This script checks if a suitable python3 executable is installed and then +# executes the actual configure logic written in Python. scriptpath=build-system/taler-build-scripts if ! test -d "$scriptpath"; then echo "fatal error: taler-build-scripts not found at $scriptpath" >&2 + echo "hint: did you run './bootstrap'?" >&2 exit 1 fi +# Check that the python3 executable is on the PATH. +# This follows PEP 394 (https://www.python.org/dev/peps/pep-0394/). +if ! python3 --version >/dev/null 2>&1; then + echo "error: python3 not found" >&2 + exit 1 +fi + +# Let python3 check that its own version is okay for us. +python3 "$scriptpath/pyvercheck.py" || exit $? + +# Allow Python to find libraries that are checked into the build system git. export PYTHONPATH="$scriptpath:${PYTHONPATH:-}" # 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. -exec "$PYTHON" ./configure.py $@ +exec python3 ./configure.py "$@" diff --git a/pyvercheck.py b/pyvercheck.py new file mode 100644 index 0000000..98e620b --- /dev/null +++ b/pyvercheck.py @@ -0,0 +1,7 @@ +# This file is placed in the public domain. + +import sys + +if sys.version_info.major < 3 or sys.version_info.minor < 7: + sys.stderr.write("error: python>=3.7 must be available as the python3 executable\n") + sys.exit(1) diff --git a/sh/bin.sh/python.sh b/sh/bin.sh/python.sh deleted file mode 100755 index 6a50498..0000000 --- a/sh/bin.sh/python.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# This file is part of TALER -# (C) 2019 GNUnet e.V. -# -# This is very simple POSIX sh script which -# identifies the first matching -# python3 identifier in $PATH and produces -# configure.py from configure.py.in, and then -# calls the new executable configure.py. -# -# It should be portable on Unices. Report bugs on -# the bugtracker if you discover that it isn't -# working as intended. -# -# 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 - -dir=$(dirname "$(readlink -- "$0")") -. $dir/../lib.sh/existence.sh -. $dir/../lib.sh/existence_python.sh - -exec "$PYTHON" $@ diff --git a/sh/lib.sh/existence.sh b/sh/lib.sh/existence.sh deleted file mode 100644 index cddc3d6..0000000 --- a/sh/lib.sh/existence.sh +++ /dev/null @@ -1,35 +0,0 @@ -# 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 - -errmsg='' - -# Check if shell supports builtin 'type'. -if test -z "$errmsg"; then - if ! (eval 'type type') >/dev/null 2>&1 - then - errmsg='Shell does not support type builtin' - exit 1 - fi -fi - -existence() -{ - type "$1" >/dev/null 2>&1 -} diff --git a/sh/lib.sh/existence_python.sh b/sh/lib.sh/existence_python.sh deleted file mode 100644 index 5fd9b03..0000000 --- a/sh/lib.sh/existence_python.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh - -# This file is part of TALER -# (C) 2019 GNUnet e.V. -# -# This is very simple POSIX sh script which -# identifies the first matching -# python3 identifier in $PATH and produces -# configure.py from configure.py.in, and then -# calls the new executable configure.py. -# -# It should be portable on Unices. Report bugs on -# the bugtracker if you discover that it isn't -# working as intended. -# -# 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 - -existence_python() -{ - # We have to check every possible variant of the - # executable name because there is a PEP which - # defines the executable to be like this. - if existence python3; then - if test ! -z "`python3 --version | awk '$2 ~ /^3\./ { print }'`"; then - python="python3" - else - echo "*** At least python 3.7 is required for the buildsystem" - exit 1 - fi - # elif existence python3.1; then - # python="python3.1" - # elif existence python3.2; then - # python="python3.2" - # elif existence python3.3; then - # python="python3.3" - # elif existence python3.4; then - # python="python3.4" - # elif existence python3.5; then - # python="python3.5" - # elif existence python3.6; then - # python="python3.6" - elif existence python3.7; then - python="python3.7" - elif existence python3.8; then - python="python3.8" - else - echo "*** No known python3 executable found in path ***" - echo "*** falling back to env(1) python ***" - # Unreliable, but if env finds no python, we still can - # not assume python in a fixed location. - # TODO: Check this in a clean chroot! - python="env python" - fi - - # we could check the return value here via || echo "blafoo" - # or fail anyway once configure.py is invoked because we - # don't have python if we reach the point to fail. - PYTHON=$($python -c 'import sys; print(sys.executable)') -} - -existence_python diff --git a/sh/lib.sh/msg.sh b/sh/lib.sh/msg.sh deleted file mode 100644 index 6bd49ee..0000000 --- a/sh/lib.sh/msg.sh +++ /dev/null @@ -1,26 +0,0 @@ -statusmsg() -{ - ${runcmd} echo "${tab}$@" | tee -a "${results}" -} - -infomsg() -{ - if [ x$verbosity = x1 ]; then - statusmsg "INFO:${tab}$@" - fi -} - -warningmsg() -{ - statusmsg "WARNING:${tab}$@" -} - -errormsg() -{ - statusmsg "ERROR:${tab}$@" -} - -linemsg() -{ - statusmsg "=========================================" -} diff --git a/sh/lib.sh/progname.sh b/sh/lib.sh/progname.sh deleted file mode 100644 index dd6fae8..0000000 --- a/sh/lib.sh/progname.sh +++ /dev/null @@ -1 +0,0 @@ -progname=${0##*/} diff --git a/sh/lib.sh/version_gnunet.sh b/sh/lib.sh/version_gnunet.sh deleted file mode 100644 index be68f73..0000000 --- a/sh/lib.sh/version_gnunet.sh +++ /dev/null @@ -1,5 +0,0 @@ -print_version() -{ - GNUNET_ARM_VERSION=`gnunet-arm -v | awk '{print $2 " " $3}'` - echo ${progname} $GNUNET_ARM_VERSION -} -- cgit v1.2.3