From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Keir Fraser <Keir.Fraser@eu.citrix.com>
Subject: [PATCH] tools: python portability fixes
Date: Thu, 23 Jul 2009 15:58:12 +0200 [thread overview]
Message-ID: <200907231558.12957.Christoph.Egger@amd.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 751 bytes --]
Hi!
Attached patch applies portability fixes for NetBSD:
- remove useless get-path. It is a bash specific script which tries to
gain information the build system already has.
- make install-wrap work with bourne shell on NetBSD
- pass `which $(PYTHON)` to install-wrap. It is safe to assume
this always works because in case it doesn't the build system
errors out very early in tools/check/check_python
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
[-- Attachment #2: xen_python.diff --]
[-- Type: text/x-diff, Size: 3058 bytes --]
diff -r bc3aca17cb88 tools/misc/Makefile
--- a/tools/misc/Makefile Thu Jul 23 09:01:30 2009 +0100
+++ b/tools/misc/Makefile Thu Jul 23 15:45:48 2009 +0200
@@ -25,8 +25,7 @@ INSTALL_BIN := $(INSTALL_BIN-y)
INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm xen-tmem-list-parse gtraceview gtracestat
INSTALL_SBIN := $(INSTALL_SBIN-y)
-DEFAULT_PYTHON_PATH := $(shell $(XEN_ROOT)/tools/python/get-path)
-PYTHON_PATH ?= $(DEFAULT_PYTHON_PATH)
+PYTHON_PATH := $(shell which $(PYTHON))
INSTALL_PYTHON_PROG = $(XEN_ROOT)/tools/python/install-wrap \
"$(PYTHON_PATH)" $(INSTALL_PROG)
diff -r bc3aca17cb88 tools/python/get-path
--- a/tools/python/get-path Thu Jul 23 09:01:30 2009 +0100
+++ /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 bc3aca17cb88 tools/python/install-wrap
--- a/tools/python/install-wrap Thu Jul 23 09:01:30 2009 +0100
+++ b/tools/python/install-wrap Thu Jul 23 15:45:48 2009 +0200
@@ -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
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2009-07-23 13:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-23 13:58 Christoph Egger [this message]
2009-07-23 14:06 ` [PATCH] tools: python portability fixes Keir Fraser
2009-07-27 18:57 ` Ian Jackson
2009-07-28 7:34 ` Christoph Egger
2009-07-28 9:55 ` Ian Jackson
2009-07-28 12:27 ` Christoph Egger
2009-08-04 10:32 ` Ian Jackson
2009-08-04 12:33 ` Christoph Egger
2009-08-04 13:03 ` Ian Jackson
2009-08-04 13:40 ` Christoph Egger
2009-08-04 14:20 ` John Levon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200907231558.12957.Christoph.Egger@amd.com \
--to=christoph.egger@amd.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=Keir.Fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.