Skip to content

Commit

Permalink
CI: Fix parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Aug 26, 2024
1 parent 3ebfff2 commit 031eeb7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Build Package
if: steps.fetch.outputs.BACKUP_FOLDER != ''
run: python3 metallib.py --build-package ${{ steps.fetch.outputs.BACKUP_FOLDER }}
run: python3 metallib.py --build-pkg ${{ steps.fetch.outputs.BACKUP_FOLDER }}

- name: Upload metal libraries to Artifactions
if: steps.fetch.outputs.BACKUP_FOLDER != ''
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ MetallibSupportPkg houses the `metal_libraries` python library, which was develo
1. Programmatically fetching the latest macOS Sequoia IPSW.
2. Extract the system volume DMG from the IPSW.
3. If the disk image is AEA encrypted, decrypt using [`aastuff`](https://github.com/dhinakg/aeota).
4. Mount the disk image, and extract all supported `.metallib` files
5. Patch the `.metallib` files to support Metal 3802 GPUs
6. Convert the directory into a macOS Distribution Package (PKG)
4. Mount the disk image, and extract all supported `.metallib` files.
5. Patch the `.metallib` files to support Metal 3802 GPUs.
6. Convert the directory into a macOS Distribution Package (PKG).

Notes regarding patching individual `.metallib` files:
1. Each `.metallib` is a collection of `.air` files.
2. Certain `.metallib` files are actually FAT Mach-O files. Thus they need to be thinned manually (Apple's `lipo` utility does not support the AIR64 architecture we need).
- [metallib/patch.py: `_thin_file()`](./metal_libraries/metallib/patch.py#L218-L270)
3. Each `.metallib` file is actually a collection of `.air` files. Need to extract them using [zhouwei's format](https://github.com/zhuowei/MetalShaderTool).
- metallib/patch.py: `_unpack_metallib_to_air()`](./metal_libraries/metallib/patch.py#L127-L187)
- [metallib/patch.py: `_unpack_metallib_to_air()`](./metal_libraries/metallib/patch.py#L127-L187)
4. `.air` files need to be next decompiled to `.ll` (LLVM IR) using Apple's `metal-objdump` utility.
- [metallib/patch.py: `_decompile_air_to_ll()`](./metal_libraries/metallib/patch.py#L77-L109)
5. With the LLVM IR, we can begin patching the AIR version to v26 (compared to Sequoia's v27) as well as other necessary changes.
Expand Down
10 changes: 6 additions & 4 deletions metal_libraries/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ def build_pkg(input: str) -> None:
"""
Builds a macOS package from a given directory
"""
name = Path(input).name
assert macos_pkg_builder.Packages(
pkg_output=f"MetallibSupportPkg-{Path(input).name}.pkg",
pkg_bundle_id=f"com.dortania.metallibsupportpkg.{Path(input).name}",
pkg_output=f"MetallibSupportPkg-{name}.pkg",
pkg_bundle_id=f"com.dortania.metallibsupportpkg.{name}",
pkg_version=__version__,
pkg_file_structure={
input: f"/Library/Application Support/Dortania/MetallibSupportPkg/{Path(input).name}"
input: f"/Library/Application Support/Dortania/MetallibSupportPkg/{name}"
},
pkg_welcome=f"# MetallibSupportPkg\n\nThis package installs patched Metal Libraries for usage with OpenCore Legacy Patcher specifically targeting Macs with Metal 3802-based Graphics cards on macOS 15, Sequoia and newer.\n\nAffected graphics card models:\n\n* Intel Ivy Bridge and Haswell iGPUs\n* Nvidia Kepler dGPUs\n\n----------\nInstall destination:\n\n* `/Library/Application Support/Dortania/MetallibSupportPkg/{Path(input).name}`\n\n----------\n\nFor more information, see the [MetallibSupportPkg repository]({__url__}).",
pkg_title=f"MetallibSupportPkg for {Path(input).name}",
pkg_title=f"MetallibSupportPkg for {name}",
pkg_as_distribution=True
).build() is True
print(f"MetallibSupportPkg-{name}.pkg")


def build_sys_patch(input: str, ci: bool = False) -> None:
Expand Down
3 changes: 2 additions & 1 deletion metal_libraries/metallib/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,12 @@ def _attempt_to_resolve_parent(self, file: Path) -> str:
"""
Attempt to resolve the parent directory
"""
extensions = [".framework", ".app", ".appex", ".bundle", ".cifilter"]
parent_file = file
attempts = 0
while True:
parent_file = parent_file.parent
if parent_file.name.endswith(".framework") or parent_file.name.endswith(".app"):
if any([parent_file.name.endswith(ext) for ext in extensions]):
break
if attempts > 5:
return str(file)
Expand Down

0 comments on commit 031eeb7

Please sign in to comment.