debuggers.hg

view tools/python/install-wrap @ 21067:b4a1832a916f

Update Xen version to 4.0.0-rc6
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 09 18:18:05 2010 +0000 (2010-03-09)
parents d820a6b813db
children
line source
1 #!/bin/sh
2 # usage:
3 # .../install-wrap $(PYTHON_PATH) install <options-to-install> <src>... <dest>
4 # where
5 # PYTHON_PATH is what to put after #! and may be `/usr/bin/env python'
6 #
7 # Used via $(INSTALL_PYTHON_PROG) in Rules.mk; PYTHON_PATH comes from $(PYTHON)
9 set -e
10 if test $# -lt 2; then
11 echo >&2 "${0##*/}: too few arguments"
12 exit 1
13 fi
15 pythonpath="$1"
16 shift
18 install="$1"
19 shift
20 srcs=""
22 while [ $# != 0 ]; do
23 case "$1" in
24 -|--) install=`echo "${install} $1"`
25 shift
26 break
27 ;;
28 -*) install=`echo "${install} $1"`
29 shift
30 ;;
31 *) break
32 ;;
33 esac
34 done
36 while test $# -gt 1; do
37 srcs=`echo "${srcs} $1"`
38 shift
39 done
41 dest="$1"
42 shift
44 destf="$dest"
45 for srcf in ${srcs}; do
46 if test -d "$dest"; then
47 destf="$dest/${srcf%%*/}"
48 fi
49 org="$(sed -n '2q; /^#! *\/usr\/bin\/env python *$/p' $srcf)"
50 if test "x$org" = x; then
51 eval "${install} $srcf $destf"
52 continue
53 fi
54 tmpf="$destf.tmp"
55 eval "${install} $srcf $tmpf"
56 printf >"$tmpf" "#!%s\n" "$pythonpath"
57 sed -e 1d "$srcf" >>"$tmpf"
58 mv -f "$tmpf" "$destf"
59 done
60 exit 0