aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-12-09 10:58:52 +0000
committerKeir Fraser <keir.fraser@citrix.com>2009-12-09 10:58:52 +0000
commit80b20a2fa03aca3f5da93827879e9d3aeed7dade (patch)
tree6ef5bffa658f66abece3c8019db5c14f09d1dd12
parent5f05fba8c1826f6f8132c46d9215b25598f5eb39 (diff)
downloadxen-80b20a2fa03aca3f5da93827879e9d3aeed7dade.tar.gz
xen-80b20a2fa03aca3f5da93827879e9d3aeed7dade.tar.bz2
xen-80b20a2fa03aca3f5da93827879e9d3aeed7dade.zip
tools: simplify PYTHON_PATH computation (and fixes for NetBSD)
Doesn't work when build-time python path differs from install-time. Do we care about this given tools should be packaged/built for the specific run-time distro? Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
-rw-r--r--tools/Rules.mk4
-rwxr-xr-xtools/python/get-path22
-rwxr-xr-xtools/python/install-wrap52
3 files changed, 36 insertions, 42 deletions
diff --git a/tools/Rules.mk b/tools/Rules.mk
index ae7bf0e316..53d8aa86ce 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -49,8 +49,8 @@ check-$(CONFIG_X86) = $(call cc-ver-check,CC,0x030400,\
"Xen requires at least gcc-3.4")
$(eval $(check-y))
-DEFAULT_PYTHON_PATH := $(shell $(XEN_ROOT)/tools/python/get-path)
-PYTHON_PATH ?= $(DEFAULT_PYTHON_PATH)
+_PYTHON_PATH := $(shell which $(PYTHON))
+PYTHON_PATH ?= $(_PYTHON_PATH)
INSTALL_PYTHON_PROG = \
$(XEN_ROOT)/tools/python/install-wrap "$(PYTHON_PATH)" $(INSTALL_PROG)
diff --git a/tools/python/get-path b/tools/python/get-path
deleted file mode 100755
index ae672793e2..0000000000
--- a/tools/python/get-path
+++ /dev/null
@@ -1,22 +0,0 @@
-#! /usr/bin/env bash
-set -e
-
-check () {
- set +e
- p=`type -p python$v`
- r=$?
- set -e
- if [ $r = 0 ]; then
- echo >&2 "${0##*/}: will use #!$p for python programs"
- printf "%s\n" "$p"
- exit 0
- fi
-}
-
-v="$(python -V 2>&1)"
-v="${v#* }"
-check
-v="${v%.*}"
-check
-echo >&2 'python version not determined, will use env to find python at runtime'
-printf "/usr/bin/env python\n"
diff --git a/tools/python/install-wrap b/tools/python/install-wrap
index 29db25d1a7..00e2014016 100755
--- a/tools/python/install-wrap
+++ b/tools/python/install-wrap
@@ -1,44 +1,60 @@
-#! /usr/bin/env bash
+#!/bin/sh
# usage:
# .../install-wrap $(PYTHON_PATH) install <options-to-install> <src>... <dest>
# where
# PYTHON_PATH is what to put after #! and may be `/usr/bin/env python'
#
-# Used via $(INSTALL_PYTHON_PROG) in Rules.mk; PYTHON_PATH comes from
-# .../get-path alongside this script
+# Used via $(INSTALL_PYTHON_PROG) in Rules.mk; PYTHON_PATH comes from $(PYTHON)
set -e
-if [ $# -lt 2 ]; then echo >&2 "${0##*/}: too few arguments"; exit 1; fi
-pythonpath="$1"; shift
+if test $# -lt 2; then
+ echo >&2 "${0##*/}: too few arguments"
+ exit 1
+fi
-install=("$1"); shift
-srcs=()
+pythonpath="$1"
+shift
+
+install="$1"
+shift
+srcs=""
while [ $# != 0 ]; do
case "$1" in
- -|--) install=("${install[@]}" "$1"); shift; break ;;
- -*) install=("${install[@]}" "$1"); shift ;;
- *) break ;;
+ -|--) install=`echo "${install} $1"`
+ shift
+ break
+ ;;
+ -*) install=`echo "${install} $1"`
+ shift
+ ;;
+ *) break
+ ;;
esac
done
-while [ $# -gt 1 ]; do
- srcs=("${srcs[@]}" "$1"); shift
+
+while test $# -gt 1; do
+ srcs=`echo "${srcs} $1"`
+ shift
done
-dest="$1"; shift
+
+dest="$1"
+shift
destf="$dest"
-for srcf in "${srcs[@]}"; do
+for srcf in ${srcs}; do
if test -d "$dest"; then
- destf="$dest/${srcf%%*/}";
+ destf="$dest/${srcf%%*/}"
fi
org="$(sed -n '2q; /^#! *\/usr\/bin\/env python *$/p' $srcf)"
- if [ "x$org" = x ]; then
- "${install[@]}" "$srcf" "$destf"
+ if test "x$org" = x; then
+ eval "${install} $srcf $destf"
continue
fi
tmpf="$destf.tmp"
- "${install[@]}" "$srcf" "$tmpf"
+ eval "${install} $srcf $tmpf"
printf >"$tmpf" "#!%s\n" "$pythonpath"
sed -e 1d "$srcf" >>"$tmpf"
mv -f "$tmpf" "$destf"
done
+exit 0