|
19 | 19 | from .ypkgcontext import YpkgContext |
20 | 20 | from .scripts import ScriptGenerator |
21 | 21 | from .packages import PackageGenerator, PRIORITY_USER |
22 | | -from .examine import PackageExaminer |
| 22 | +from .examine import PackageExaminer, is_elf_file |
23 | 23 | from . import metadata |
24 | 24 | from .dependencies import DependencyResolver |
25 | 25 | from . import packager_name, packager_email |
|
38 | 38 |
|
39 | 39 | from timeit import default_timer as timer |
40 | 40 | from datetime import timedelta |
| 41 | +from pathlib import Path |
41 | 42 |
|
42 | 43 |
|
43 | 44 | def show_version(): |
@@ -190,6 +191,41 @@ def execute_step(context, step, step_n, work_dir): |
190 | 191 | return False |
191 | 192 | return True |
192 | 193 |
|
| 194 | +was_avx2_context = False |
| 195 | + |
| 196 | +def post_execute_step(context, step, step_n, work_dir): |
| 197 | + |
| 198 | + hwcaps_v3_bin_dir = os.path.join(context.get_install_dir(), "usr", "hwcaps", "x86-64-v3", "bin") |
| 199 | + hwcaps_v1_bin_dir = os.path.join(context.get_install_dir(), "usr", "hwcaps", "x86-64-v1", "bin") |
| 200 | + bin_dir = os.path.join(context.get_install_dir(), "usr", "bin") |
| 201 | + |
| 202 | + if context.avx2 and step_n == "install": |
| 203 | + global was_avx2_context |
| 204 | + was_avx2_context = True |
| 205 | + |
| 206 | + os.makedirs(hwcaps_v3_bin_dir, exist_ok=True) |
| 207 | + for dirpath, dirnames, filenames in os.walk(bin_dir): |
| 208 | + for file in filenames: |
| 209 | + file_path = os.path.join(dirpath, file) |
| 210 | + if is_elf_file(file_path): |
| 211 | + shutil.move(file_path, hwcaps_v3_bin_dir) |
| 212 | + |
| 213 | + if context.emul32 is False and context.avx2 is False and step_n == "install" and was_avx2_context is True: |
| 214 | + os.makedirs(hwcaps_v1_bin_dir, exist_ok=True) |
| 215 | + |
| 216 | + dummy_hwcaps_loader = Path(bin_dir, "hwcaps-loader") |
| 217 | + dummy_hwcaps_loader.touch() |
| 218 | + |
| 219 | + for dirpath, dirnames, filenames in os.walk(bin_dir): |
| 220 | + for file in filenames: |
| 221 | + file_path = os.path.join(dirpath, file) |
| 222 | + if is_elf_file(file_path): |
| 223 | + shutil.move(file_path, hwcaps_v1_bin_dir) |
| 224 | + relative_target = os.path.relpath(dummy_hwcaps_loader, start=os.path.dirname(file_path)) |
| 225 | + os.symlink(relative_target, file_path) |
| 226 | + |
| 227 | + os.unlink(dummy_hwcaps_loader) |
| 228 | + |
193 | 229 |
|
194 | 230 | def build_package(filename, outputDir, buildDir=None): |
195 | 231 | """ Will in future be moved to a separate part of the module """ |
@@ -380,6 +416,7 @@ def build_package(filename, outputDir, buildDir=None): |
380 | 416 | end_time = timer() |
381 | 417 | console_ui.emit_success("Build", "{} successful ({})". |
382 | 418 | format(step, timedelta(seconds=end_time-start_time))) |
| 419 | + post_execute_step(context, r_step, step, work_dir) |
383 | 420 | continue |
384 | 421 | console_ui.emit_error("Build", "{} failed for {}".format(step, spec.pkg_name)) |
385 | 422 | sys.exit(1) |
|
0 commit comments