diff --git a/ocpm/data/OCKextRepos.yml b/ocpm/data/OCKextRepos.yml index a9382ac..a0548b3 100644 --- a/ocpm/data/OCKextRepos.yml +++ b/ocpm/data/OCKextRepos.yml @@ -1,4 +1,7 @@ Repos: + AirPortBrcm4360_Injector: https://github.com/acidanthera/AirportBrcmFixup + AirportBrcmFixup: https://github.com/acidanthera/AirportBrcmFixup + AirPortBrcmNIC_Injector: https://github.com/acidanthera/AirportBrcmFixup AirportItlwm-BigSur: Artifact: .*BigSur.* Repo: &itlwm https://github.com/OpenIntelWireless/itlwm @@ -26,7 +29,11 @@ Repos: BrcmPatchRAM3: *brcm BrcmPatchRAM: *brcm BrightnessKeys: https://github.com/acidanthera/BrightnessKeys + CPUFriend: https://github.com/acidanthera/CPUFriend CpuTscSync: https://github.com/acidanthera/CpuTscSync + CryptexFixup.kext: https://github.com/acidanthera/CryptexFixup + DebugEnhancer: https://github.com/acidanthera/DebugEnhancer + FeatureUnlock.kext: https://github.com/acidanthera/FeatureUnlock HibernationFixup: https://github.com/acidanthera/HibernationFixup IntelBluetoothFirmware: &itlbf https://github.com/OpenIntelWireless/IntelBluetoothFirmware IntelBluetoothInjector: *itlbf @@ -34,26 +41,33 @@ Repos: IntelMausi: &imausi https://github.com/acidanthera/IntelMausi IntelSnowMausi: *imausi Lilu: https://github.com/acidanthera/Lilu + MacHyperVSupport: https://github.com/acidanthera/MacHyperVSupport + MacHyperVSupportMonterey: https://github.com/acidanthera/MacHyperVSupport NVMeFix: https://github.com/acidanthera/NVMeFix RealtekCardReader: https://github.com/0xFireWolf/RealtekCardReader RealtekCardReaderFriend: https://github.com/0xFireWolf/RealtekCardReaderFriend RealtekRTL8111: https://github.com/Mieze/RTL8111_driver_for_OS_X - VirtualSMC: &smc https://github.com/acidanthera/VirtualSMC - SMCBatteryManager: *smc + RestrictEvents: https://github.com/acidanthera/RestrictEvents + RTCMemoryFixup: https://github.com/acidanthera/RTCMemoryFixup + SMCBatteryManager: &smc https://github.com/acidanthera/VirtualSMC SMCDellSensors: *smc SMCLightSensor: *smc SMCProcessor: *smc SMCSuperIO: *smc + UEFIGraphicsFB: https://github.com/acidanthera/UEFIGraphicsFB USBInjectAll: https://github.com/Sniki/OS-X-USB-Inject-All USBToolBox: &utb https://github.com/USBToolBox/kext UTBDefault: *utb + VirtualSMC: *smc VoodooI2C: &i2c https://github.com/VoodooI2C/VoodooI2C VoodooI2CAtmelMXT: *i2c VoodooI2CELANL: *i2c VoodooI2CFTE: *i2c VoodooI2CHID: *i2c VoodooI2CSynaptics: *i2c - VoodooInput: https://github.com/acidanthera/VoodooInput - VoodooPS2Controller: https://github.com/acidanthera/VoodooPS2 + VoodooInput: &ps2 https://github.com/acidanthera/VoodooPS2 + VoodooPS2Controller: *ps2 + VoodooPS2Keyboard: *ps2 + VoodooPS2Mouse: *ps2 + VoodooPS2Trackpad: *ps2 WhateverGreen: https://github.com/acidanthera/WhateverGreen - diff --git a/ocpm/main.py b/ocpm/main.py index 952f13e..4f1f81c 100755 --- a/ocpm/main.py +++ b/ocpm/main.py @@ -29,7 +29,36 @@ except Exception: bar_len = 20 -def get_latest_release(name: str, repos: dict, pre: bool): +def get_latest_release_repo(repo: str, pre: bool) -> Release: + """ + Fetch the latest release info from a repository + + :param repo: GitHub repo in the format of owner/repo + :param pre: Whether to allow pre-releases + :return: Latest release + """ + + # Check latest version + headers = {} + if 'GH_TOKEN' in os.environ: + headers['Authorization'] = f'token {os.environ["GH_TOKEN"]}' + releases = requests.get(f'https://api.github.com/repos/{repo}/releases', headers=headers).json() + if not pre: + releases = [r for r in releases if not r['prerelease']] + latest = releases[0] + + return Release.from_github(latest) + + +def get_latest_release(name: str, repos: dict, pre: bool) -> Release: + """ + Fetch the latest release info from a name in the repository list yml + + :param name: Unique name + :param repos: Repository list yml (Check out data/OCKextRepos.yml) + :param pre: Whether to allow pre-releases + :return: Latest release + """ # Lowercase keys repos = {k.lower(): v for k, v in repos['Repos'].items()} name = name.lower() @@ -47,16 +76,7 @@ def get_latest_release(name: str, repos: dict, pre: bool): assert 'github.com/' in repo, f'For {name}: {repo} is not a github repo, skipping...' repo = repo.split('github.com/')[1] - # Check latest version - headers = {} - if 'GH_TOKEN' in os.environ: - headers['Authorization'] = f'token {os.environ["GH_TOKEN"]}' - releases = requests.get(f'https://api.github.com/repos/{repo}/releases', headers=headers).json() - if not pre: - releases = [r for r in releases if not r['prerelease']] - latest = releases[0] - - return Release.from_github(latest) + return get_latest_release_repo(repo, pre) def download_file(url: str, file: str | Path): diff --git a/tools/get_artifacts.py b/tools/get_artifacts.py new file mode 100644 index 0000000..f549da8 --- /dev/null +++ b/tools/get_artifacts.py @@ -0,0 +1,24 @@ +from pathlib import Path +from tempfile import TemporaryDirectory +from zipfile import ZipFile + +from ocpm.main import download_file, get_latest_release_repo + +if __name__ == '__main__': + while True: + repo = input("Please type in github repo name (e.g. owner/repo): ") + + release = get_latest_release_repo(repo, False) + + with TemporaryDirectory() as tmp: + tmp = Path(tmp) + + download_file(release.artifact.url, tmp / "artifact.zip") + + with ZipFile(tmp / 'artifact.zip', 'r') as f: + names = [a.strip('/') for a in f.namelist() if a.lower().endswith('.kext/')] + print('\n'.join(names)) + + repos_path = Path('ocpm/data/OCKextRepos.yml') + yml = ''.join(f'\n {Path(a).stem}: https://github.com/{repo}' for a in names) + repos_path.write_text(repos_path.read_text() + yml)