[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] tools: simplify PYTHON_PATH computation (and fixes for NetBSD)
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1260356332 0 # Node ID d820a6b813dbd42f7a74a877880f3469a3e05e75 # Parent 9e9746e635f9ec1ef1a3e0cbb425e89112f8e63b 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@xxxxxxx> --- tools/python/get-path | 22 ------------------- tools/Rules.mk | 4 +-- tools/python/install-wrap | 52 ++++++++++++++++++++++++++++++---------------- 3 files changed, 36 insertions(+), 42 deletions(-) diff -r 9e9746e635f9 -r d820a6b813db tools/Rules.mk --- a/tools/Rules.mk Wed Dec 09 10:46:11 2009 +0000 +++ b/tools/Rules.mk Wed Dec 09 10:58:52 2009 +0000 @@ -49,8 +49,8 @@ check-$(CONFIG_X86) = $(call cc-ver-chec "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 -r 9e9746e635f9 -r d820a6b813db tools/python/get-path --- a/tools/python/get-path Wed Dec 09 10:46:11 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 -r 9e9746e635f9 -r d820a6b813db tools/python/install-wrap --- a/tools/python/install-wrap Wed Dec 09 10:46:11 2009 +0000 +++ b/tools/python/install-wrap Wed Dec 09 10:58:52 2009 +0000 @@ -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 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |