From 5f80de3fbc0c4b43fb93d0ef4460aea16b2c78e0 Mon Sep 17 00:00:00 2001 From: ng0 Date: Tue, 26 Feb 2019 08:35:45 +0000 Subject: [PATCH] Proposed fix for https://bugs.gnunet.org/view.php?id=5611 --- src/util/Makefile.am | 27 +++++-------- src/util/gnunet-qr.in | 46 ++++++++++++++++++++++ src/util/{gnunet-qr.py.in => gnunet-qr.py} | 1 - 3 files changed, 56 insertions(+), 18 deletions(-) create mode 100755 src/util/gnunet-qr.in rename src/util/{gnunet-qr.py.in => gnunet-qr.py} (99%) diff --git a/src/util/Makefile.am b/src/util/Makefile.am index d1aa8aa9b..7041004ac 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -204,8 +204,15 @@ libexec_PROGRAMS = \ gnunet-timeout \ $(W32CONSOLEHELPER) +do_subst = $(SED) -e 's,[@]PREFIX[@],$(PREFIX),g' + +gnunet-qr: gnunet-qr.in Makefile + $(do_subst) < $(srcdir)/gnunet-qr.in > gnunet-qr + chmod +x gnunet-qr + bin_SCRIPTS =\ - gnunet-qr + gnunet-qr \ + gnunet-qr.py bin_PROGRAMS = \ gnunet-resolver \ @@ -236,21 +243,6 @@ gnunet_timeout_SOURCES = \ gnunet-timeout-w32.c endif -# This is horrible, but compared to the alternatives and the solution -# which preceded this it is a good compromise and good enough for one -# file. Everyone else is invited to patch it locally. -# In case someone reads this file and is wondering about the -# assignment operator below, it's explained here: -# https://lists.gnu.org/archive/html/make-w32/2013-10/msg00021.html - -xENV != which env - -do_subst = $(SED) -e 's,[@]ENV[@],${xENV},g' - -gnunet-qr: gnunet-qr.py.in Makefile - $(do_subst) < $(top_srcdir)/src/util/gnunet-qr.py.in > gnunet-qr - chmod +x gnunet-qr - gnunet_service_resolver_SOURCES = \ gnunet-service-resolver.c gnunet_service_resolver_LDADD = \ @@ -675,4 +667,5 @@ EXTRA_DIST = \ test_resolver_api_data.conf \ test_service_data.conf \ test_speedup_data.conf \ - gnunet-qr.py.in + gnunet-qr.py \ + gnunet-qr.in diff --git a/src/util/gnunet-qr.in b/src/util/gnunet-qr.in new file mode 100755 index 000000000..5e7a285ac --- /dev/null +++ b/src/util/gnunet-qr.in @@ -0,0 +1,46 @@ +#!/bin/sh +# +# From curl's buildconf, making this script subject to the +# curl license: https://curl.haxx.se/docs/copyright.html +# Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. +# Copyright (C) 2019 GNUnet e.V. + +# findtool works like which without relying on which (which is a problem +# for some limited shells. +findtool(){ + file="$1" + + if { echo "$file" | grep "/" >/dev/null 2>&1; } then + # when file is given with a path check it first + if test -f "$file"; then + echo "$file" + return + fi + fi + + old_IFS=$IFS; IFS=':' + for path in $PATH + do + IFS=$old_IFS + # echo "checks for $file in $path" >&2 + if test "$path" -a "$path" != '.' -a -f "$path/$file"; then + echo "$path/$file" + return + fi + done + IFS=$old_IFS +} + +# end curl licensed code +pythonize=`findtool python2.7 2>/dev/null` +if test ! -x "$pythonize"; then + pythonize=`findtool ${PYTHON2:-python2.7}` +fi + +if test -z "$pythonize"; then + echo "ERROR: python2.7 not found." + echo " You need python2.7 installed." + exit 1 +fi + +${pythonize} @PREFIX@/bin/gnunet-qr.py || echo "ERROR: python2.7 or future not found" && exit 1 diff --git a/src/util/gnunet-qr.py.in b/src/util/gnunet-qr.py similarity index 99% rename from src/util/gnunet-qr.py.in rename to src/util/gnunet-qr.py index ceed8bd77..bf35b3a7e 100755 --- a/src/util/gnunet-qr.py.in +++ b/src/util/gnunet-qr.py @@ -1,4 +1,3 @@ -#!@ENV@ python2.7 from __future__ import print_function from builtins import str import sys -- 2.25.1