|
16 | 16 | _installing = set() |
17 | 17 |
|
18 | 18 | def main(package, noconfirm=False): |
| 19 | + local = False |
| 20 | + # check if package is local |
| 21 | + if package.endswith(".car"): |
| 22 | + os.system(f"unzip {package}") |
| 23 | + os.chdir(package) |
| 24 | + with open("install_script.py", "r") as f: |
| 25 | + script = f.read() |
| 26 | + local = True |
19 | 27 | # first check if the name is correct, autocorrect if not |
20 | 28 | # using umbrella/autocorrect_package.py (unlicense) |
21 | | - autocorrected = Autocorrect.main(package) |
22 | | - if autocorrected != package: |
23 | | - package = autocorrected |
| 29 | + if not local: |
| 30 | + autocorrected = Autocorrect.main(package) |
| 31 | + if autocorrected != package: |
| 32 | + package = autocorrected |
24 | 33 |
|
25 | 34 | # Prevent circular dependencies and infinite loops |
26 | 35 | if package in _installing: |
27 | 36 | return |
28 | 37 | _installing.add(package) |
29 | 38 | try: |
30 | 39 | # save time fetching scripts, check if the package is in lists quickly |
31 | | - if get_package_list.main(package) != True: |
32 | | - return False |
| 40 | + if not local: |
| 41 | + if get_package_list.main(package) != True: |
| 42 | + return False |
33 | 43 |
|
34 | 44 | # main |
35 | 45 | try: |
@@ -62,35 +72,36 @@ def write_installed_versions(path, versions): |
62 | 72 | f.write("\n".join(lines) + "\n") |
63 | 73 |
|
64 | 74 | # go to /tmp |
65 | | - os.chdir("/tmp/") |
| 75 | + if not local: |
| 76 | + os.chdir("/tmp/") |
| 77 | + |
| 78 | + status("Fetching package") |
66 | 79 |
|
67 | | - status("Fetching package") |
| 80 | + # fetch all repos for the install script |
| 81 | + found = False |
68 | 82 |
|
69 | | - # fetch all repos for the install script |
70 | | - found = False |
| 83 | + for mirror in mirrors.install_script_places: |
| 84 | + url = f"{mirror.rstrip('/')}/{package}/install_script" |
71 | 85 |
|
72 | | - for mirror in mirrors.install_script_places: |
73 | | - url = f"{mirror.rstrip('/')}/{package}/install_script" |
| 86 | + result = os.system(f"curl -s -L -o install_script.py {url}") |
74 | 87 |
|
75 | | - result = os.system(f"curl -s -L -o install_script.py {url}") |
| 88 | + with open("install_script.py", "r") as f: |
| 89 | + script = f.read() |
76 | 90 |
|
77 | | - with open("install_script.py", "r") as f: |
78 | | - script = f.read() |
79 | | - |
80 | | - # github returns 404: Not Found in case the file does not exist, |
81 | | - # so handle that case too |
82 | | - if script != "404: Not Found": |
83 | | - found = True |
84 | | - break |
85 | | - else: |
86 | | - pass |
| 91 | + # github returns 404: Not Found in case the file does not exist, |
| 92 | + # so handle that case too |
| 93 | + if script != "404: Not Found": |
| 94 | + found = True |
| 95 | + break |
| 96 | + else: |
| 97 | + pass |
87 | 98 |
|
88 | | - if not found: |
89 | | - status("Failed to fetch install script from all mirrors", "error") |
90 | | - exit(1) |
| 99 | + if not found: |
| 100 | + status("Failed to fetch install script from all mirrors", "error") |
| 101 | + exit(1) |
91 | 102 |
|
92 | 103 | # import the script as a python library |
93 | | - spec = importlib.util.spec_from_file_location("install_script", "/tmp/install_script.py") |
| 104 | + spec = importlib.util.spec_from_file_location("install_script", "install_script.py") |
94 | 105 | install_script = importlib.util.module_from_spec(spec) |
95 | 106 | spec.loader.exec_module(install_script) |
96 | 107 |
|
@@ -127,8 +138,9 @@ def write_installed_versions(path, versions): |
127 | 138 | if not noconfirm: |
128 | 139 | status("The following packages are going to be installed:") |
129 | 140 | print(" ", end="") |
130 | | - for i in install_script.car_deps: |
131 | | - print(i, end=", ") |
| 141 | + if "car_deps" in script: |
| 142 | + for i in install_script.car_deps: |
| 143 | + print(i, end=", ") |
132 | 144 | print(package) # appending to the list did not work for some reason |
133 | 145 | console.print("::", style="blue bold", end=" ") |
134 | 146 | sure = input("Install dependencies and build? (Y/n) ") |
|
0 commit comments