-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·53 lines (49 loc) · 1.67 KB
/
setup.sh
File metadata and controls
executable file
·53 lines (49 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
[ -h "$0" ] && ORIGIN=`ls -l "$0" | sed "s/.*-> //g"` || ORIGIN="$0"
ORIGIN=`(cd "\`dirname \"$ORIGIN\"\`"; pwd -P 2>/dev/null || pwd)`
last_working=""
# Create .pth files
for binary in python2 python2.2 python2.3 python2.4 python2.5 python2.6 python _python_preferred_; do
if ${binary} -c "" 2>/dev/null; then
last_working=${binary}
${binary} - <<EOF
pthfile="hiveconf.pth"
mod_dir="${ORIGIN}"
import sys, os
sitedirs = filter(lambda s: s.endswith("site-packages") or s.endswith("dist-packages"), sys.path)
if len(sitedirs) < 1:
sys.exit("Unable to find a site packages directory in sys.path")
filename = sitedirs[0] + "/" + pthfile
want = mod_dir + "\n"
if not os.path.exists(filename) or open(filename, "r").read() != want:
open(filename, "w").write(want)
print "Created", filename
EOF
fi
done
# Modify hashbang of hivetool. If we are inside a sparse Solaris zone,
# site-packages is likely read only, but if the package is installed
# in the global zone (which is what we are supporting at this point),
# this script has already been executed there. Assuming the target
# Python interpreter ends up being the same, there's no need to modify
# hivetool, thus the read only file system is no problem.
if [ ${last_working} ]; then
${last_working} - <<EOF
toolfile="/usr/bin/hivetool"
import sys, os
binary = sys.executable
if binary[-len("_python_preferred_"):] == "_python_preferred_":
binary = os.readlink(binary)
want = "#!%s\n" % binary
f = open(toolfile, "r")
if f.readline() != want:
f.close()
f = open(toolfile, "r+")
lines = f.readlines()
lines[0] = want
f.seek(0)
f.writelines(lines)
f.truncate()
f.close()
EOF
fi