-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-ghc.py
More file actions
executable file
·40 lines (33 loc) · 1.22 KB
/
install-ghc.py
File metadata and controls
executable file
·40 lines (33 loc) · 1.22 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
#!/usr/bin/env python
import subprocess
import sys
import os
stack_root, rpm_build_root, dest_path = sys.argv[1:4]
fullname = None
d = os.path.join(stack_root, "programs", "x86_64-linux")
for filename in os.listdir(d):
if '.tar.' in filename:
fullname = os.path.join(d, filename)
break
extracted = "EXTRACTED"
if fullname and not os.path.exists(extracted):
os.mkdir(extracted)
subprocess.check_output(["tar", "-C", extracted, "-xf", fullname])
os.chdir(os.path.join(extracted, os.listdir(extracted)[0]))
cmd = ["./configure", "--prefix", dest_path]
print cmd
print subprocess.check_output(cmd)
cmd = ["make", "DESTDIR=" + rpm_build_root, "install"]
print cmd
print subprocess.check_output(cmd)
installed_bins = os.path.join(rpm_build_root,
os.path.join(dest_path[1:], "bin"))
stackage_dist_bin = os.path.join(rpm_build_root,
os.path.dirname(dest_path)[1:], "bin")
if not os.path.exists(stackage_dist_bin):
os.mkdir(stackage_dist_bin)
for installed_bin in os.listdir(installed_bins):
src = os.path.join("..", "ghc", "bin", installed_bin)
dest = os.path.join(stackage_dist_bin, installed_bin)
print (src, dest)
os.symlink(src, dest)