gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-taler-build-scripts] branch master updated: move mos


From: gnunet
Subject: [GNUnet-SVN] [taler-taler-build-scripts] branch master updated: move most of the shell functionality to the python script.
Date: Fri, 04 Oct 2019 17:58:16 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository taler-build-scripts.

The following commit(s) were added to refs/heads/master by this push:
     new 5059125  move most of the shell functionality to the python script.
5059125 is described below

commit 5059125bfe5a60aae4e6da79d61d086b4e2e2fce
Author: ng0 <address@hidden>
AuthorDate: Fri Oct 4 15:57:51 2019 +0000

    move most of the shell functionality to the python script.
---
 configure    | 44 +----------------------------------
 configure.py | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 67 insertions(+), 52 deletions(-)

diff --git a/configure b/configure
index 8f456dd..933d474 100755
--- a/configure
+++ b/configure
@@ -74,52 +74,10 @@ fi
 PYTHON=$($python -c 'import sys; print(sys.executable)')
 #echo $PYTHON
 
-if ! existence node; then
-    echo 'Error: node executable not found.'
-    echo 'If you are using Linux, Ubuntu or Debian, try installing the'
-    echo 'node-legacy package or symlink node to nodejs.'
-else
-    node_version=$(node --version)
-    #echo "Using node ${node_version}"
-    if ! node -p 'process.exit(!(/v([0-9]+)/.exec(process.version)[1] >= 4))'; 
then
-        echo 'Your node version is too old, use Node 4.x or newer'
-        exit 1
-    fi
-fi
-
-if existence yarn; then
-    if yarn help 2>&1 | grep "No such file or directory"; then
-        echo "ERROR: wrong yarn binary installed, please remove the"
-        echo "ERROR: conflicting binary before continuing."
-        if existence cmdtest; then
-            echo "WARNING: cmdtest is installed, this can lead"
-            echo "WARNING: to know issues with yarn."
-        fi
-        exit 1
-    fi
-    myyarn="yarn"
-elif existence yarnpkg; then
-    myyarn="yarnpkg"
-else
-    echo 'ERROR: yarn missing. See https://yarnpkg.com/en/docs/install'
-    exit 1
-fi
-
-# for the weird systems and sandboxes, only as a anotice.
-# make will fail anyway.
-if ! existence find; then
-    echo "INFO: find(1) is missing"
-fi
-if ! existence xargs; then
-    echo "INFO: xargs(1) is missing"
-fi
-if ! existence msgmerge; then
-    echo "INFO: msgmerge(1) is missing"
-fi
 
 # 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.
-$PYTHON ./configure.py --yarn=$myyarn $@
+$PYTHON ./configure.py $@
diff --git a/configure.py b/configure.py
index 212bd57..8fc6e04 100644
--- a/configure.py
+++ b/configure.py
@@ -22,6 +22,9 @@ import argparse
 import os
 import sys
 import logging
+from distutils.spawn import find_executable
+import subprocess
+from subprocess import Popen
 
 # This script so far generates config.mk.
 # The only value it produces is prefix,
@@ -32,6 +35,56 @@ import logging
 # TODO: Also respect DESTDIR ($PREFIX/$DESTDIR/rest).
 
 
+def _existence(name):
+    return find_executable(name) is not None
+
+
+def _tool_version(name):
+    return subprocess.getstatusoutput(name)[1]
+
+
+def _tool_node():
+    if _existence('node') is None:
+        sys.exit('Error: node executable not found.\nIf you are using Linux, 
Ubuntu or Debian, try installing the\nnode-legacy package or symlink node to 
nodejs.')
+    else:
+        if subprocess.getstatusoutput("node -p 
'process.exit(!(/v([0-9]+)/.exec(process.version)[1] >= 4))'")[1] is '':
+            # and exit(1) here?
+            sys.exit('Your node version is too old, use Node 4.x or newer')
+        else:
+            node_version = _tool_version("node --version")
+            return f"Using Node version {node_version}"
+
+
+def _tool_yarn():
+    if _existence('yarn'):
+        p1 = Popen(['yarn', 'help'], stderr=subprocess.STDOUT, 
stdout=subprocess.PIPE)
+        p2 = Popen(['grep', 'No such file or directory'], stdin=p1.stdout, 
stdout=subprocess.PIPE)
+        p1.stdout.close()  # Allow p1 to receive a SIGPIPE if p2 exits
+        output = p2.communicate()[0]
+        if output is b'':
+            if _existence('cmdtest'):
+                print('WARNING: cmdtest is installed, this can lead\nto know 
issues with yarn.')
+            sys.exit('ERROR: wrong yarn binary installed, please remove 
the\nconflicting binary before continuing.')
+        return 'yarn'
+    elif _existence('yarnpkg'):
+        return 'yarnpkg'
+    else:
+        sys.exit('ERROR: yarn missing. See 
https://yarnpkg.com/en/docs/install\n')
+
+
+def _tool_posix():
+    tool_find = _existence('find')
+    if tool_find is None:
+        msg_find = 'prerequiste find(1) not found.'
+    tool_xargs = _existence('xargs')
+    if tool_xargs is None:
+        msg_xargs = 'prerequiste xargs(1) not found.'
+    tool_msgmerge = _existence('msgmerge')
+    if tool_msgmerge is None:
+        msg_msgmerge = 'prerequiste msgmerge(1) not found.'
+    return [msg_find, msg_xargs, msg_msgmerge]
+
+
 def _read_prefix():
     logging.basicConfig(level=logging.DEBUG)
     logger = logging.getLogger(__name__)
@@ -40,16 +93,14 @@ def _read_prefix():
     if 'DEBUG' in os.environ:
         logger.debug('PREFIX from argv')
     parser = argparse.ArgumentParser()
-    parser.add_argument("-p",
-                        "--prefix",
+    parser.add_argument('-p',
+                        '--prefix',
                         type=str,
-                        default="/usr/local",
-                        # required=True,
+                        default='/usr/local',
                         help='Directory prefix for installation')
-    parser.add_argument("-y",
-                        "--yarn",
+    parser.add_argument('-y',
+                        '--yarn',
                         type=str,
-                        required=True,
                         help='name of yarn executable')
     if 'DEBUG' in os.environ:
         logger.debug('parser.parse_args step')
@@ -66,14 +117,16 @@ def _read_prefix():
             myprefix = p_myprefix
     else:
         myprefix = args.prefix
-    yarnexe = args.yarn
+    if args.yarn is not None:
+        yarnexe = args.yarn
+    else:
+        yarnexe = str(_tool_yarn())
     if 'DEBUG' in os.environ:
         logger.debug('%s', repr(myprefix))
     if args.prefix and os.path.isdir(myprefix) is True:
         return [myprefix, yarnexe];
 
 def main():
-    # mylist = str(_read_prefix())
     mylist = _read_prefix()
     myprefix = mylist[0]
     yarnexe = mylist[1]
@@ -82,6 +135,10 @@ def main():
                   f'prefix={myprefix}\n',
                   f'yarnexe={yarnexe}\n'])
     f.close()
+    _tool_node()
+    posixlist = _tool_posix()
+    for x in range(len(posixlist)):
+        print(posixlist[x] + "\n")
 
 
 main()

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]