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
|
#!/usr/bin/python
import getopt, sys, os, string
prefix="/usr/local"
fake_libprefix, libprefix, execprefix = None, None, None
opts, args = getopt.getopt(sys.argv[1:], '', ['prefix=', 'exec-prefix=',
'lib-prefix=', 'fake-lib-prefix='])
for (opt, value) in opts:
if opt=='--prefix':
prefix = value
if opt=='--exec-prefix':
execprefix = value
if opt=='--lib-prefix':
libprefix = value
if opt=='--fake-lib-prefix':
fake_libprefix = value
if execprefix is None:
execprefix = os.path.join(prefix, 'bin')
if libprefix is None:
libprefix = os.path.join(prefix, 'lib')
if fake_libprefix is None:
fake_libprefix = libprefix
if not os.path.isdir(execprefix):
os.mkdir(execprefix)
if not os.path.isdir(libprefix):
os.mkdir(libprefix)
execprefix = os.path.abspath(execprefix)
libprefix = os.path.abspath(libprefix)
code = os.system("(cd ./bin;tar cf - .)|(cd %s && tar xf -)" % execprefix)
if code:
raise SystemExit(code)
code = os.system("(cd ./lib;tar cf - .)|(cd %s && tar xf -)" % libprefix)
if code:
raise SystemExit(code)
for file in os.listdir('bin'):
file = os.path.join(execprefix, file)
if not os.path.isfile(file):
continue
f = open(file)
s = f.read()
s = string.replace(s, "@LIBPREFIX@", fake_libprefix)
f = open(file, 'w')
f.write(s)
f.close()
os.chmod(file, 0755)
|