|
19 | 19 | shutil.rmtree(d)
|
20 | 20 |
|
21 | 21 |
|
| 22 | +def fetch(url, path): |
| 23 | + run(["curl", "-L", "-o", path, url]) |
| 24 | + |
| 25 | + |
22 | 26 | def mangle_path(path):
|
23 | 27 | if platform.system() == "Windows":
|
24 |
| - return ( |
25 |
| - path.replace(os.path.sep, "/").replace("C:", "/c").replace("D:", "/d") |
26 |
| - ) |
| 28 | + return path.replace(os.path.sep, "/").replace("C:", "/c").replace("D:", "/d") |
27 | 29 | else:
|
28 | 30 | return path
|
29 | 31 |
|
30 | 32 |
|
31 | 33 | def build(package, configure_args=[]):
|
32 |
| - path = os.path.join(build_dir, package) |
33 |
| - os.chdir(path) |
| 34 | + package_path = os.path.join(build_dir, package) |
| 35 | + |
| 36 | + # update config.guess and config.sub |
| 37 | + config_files = ("config.guess", "config.sub") |
| 38 | + for root, dirs, files in os.walk(package_path): |
| 39 | + for name in filter(lambda x: x in config_files, files): |
| 40 | + script_path = os.path.join(root, name) |
| 41 | + cache_path = os.path.join(source_dir, name) |
| 42 | + if not os.path.exists(cache_path): |
| 43 | + fetch( |
| 44 | + "https://git.savannah.gnu.org/cgit/config.git/plain/" + name, |
| 45 | + cache_path, |
| 46 | + ) |
| 47 | + shutil.copy(cache_path, script_path) |
| 48 | + os.chmod(script_path, 0o755) |
| 49 | + |
| 50 | + os.chdir(package_path) |
34 | 51 | run(["sh", "./configure"] + configure_args + ["--prefix=" + mangle_path(dest_dir)])
|
35 | 52 | run(["make"])
|
36 | 53 | run(["make", "install"])
|
@@ -72,7 +89,7 @@ def extract(package, url, *, strip_components=1):
|
72 | 89 |
|
73 | 90 | # download tarball
|
74 | 91 | if not os.path.exists(tarball):
|
75 |
| - run(["curl", "-L", "-o", tarball, url]) |
| 92 | + fetch(url, tarball) |
76 | 93 |
|
77 | 94 | # extract tarball
|
78 | 95 | os.mkdir(path)
|
|
0 commit comments