-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfix-bins.py
More file actions
executable file
·29 lines (26 loc) · 1.01 KB
/
fix-bins.py
File metadata and controls
executable file
·29 lines (26 loc) · 1.01 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
#!/usr/bin/env python
import subprocess
import sys
import os
pathname, stack_root, stackage_root_installed = sys.argv[1:4]
try:
installed_path = os.path.join(stackage_root_installed, "snapshots", pathname)
if os.path.exists(installed_path):
if os.path.isdir(pathname):
try:
os.rmdir(pathname)
except OSError, e:
pass
else:
print "Removing %s that is already installed as %s" % (pathname, installed_path)
os.unlink(pathname)
else:
if pathname.endswith('.so') or os.path.basename(os.path.dirname(pathname)) == "bin":
print "Fixing rpath in %s" % (pathname, )
rpath = subprocess.check_output(["chrpath", pathname]).strip()
new_rpath = rpath.split(pathname + ": RPATH=")[1].replace(stack_root, stackage_root_installed)
subprocess.check_output(["chrpath", pathname, "--replace", new_rpath])
except OSError, e:
print e
except subprocess.CalledProcessError, e:
print e