mirror of
https://github.com/zhigang1992/Hackintosh-EFI-MSI-Z490i-Unify.git
synced 2026-01-12 17:22:56 +08:00
feat auto update
This commit is contained in:
87
.github/workflows/update.yml
vendored
Normal file
87
.github/workflows/update.yml
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
#
|
||||
# Copyright (C) 2022 Ing
|
||||
#
|
||||
# This is free software, licensed under the MIT License.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
|
||||
name: update
|
||||
on:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '* */6 * * *'
|
||||
workflow_dispatch:
|
||||
env:
|
||||
FORCE_INSTALL: 1
|
||||
HAS_OPENSSL_BUILD: 1
|
||||
HAS_OPENSSL_W32BUILD: 0
|
||||
ACID32: 1
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.1.2
|
||||
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@main
|
||||
|
||||
- name: Install Python Dependencies
|
||||
run: |
|
||||
python3 -m pip install -U pip
|
||||
pip3 install datetime urllib3 wget
|
||||
|
||||
- name: Run Updater
|
||||
run: python3 -u update.py ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Check for changes
|
||||
run: |
|
||||
if [ -n "$(git status -s | grep -v -w VERTIME)" ];then
|
||||
echo "ischanges=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "ischanges=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Commit and Push
|
||||
if: env.ischanges == 'true'
|
||||
run: |
|
||||
git add .
|
||||
git commit -m "update $(date +%Y-%m-%d" "%H:%M:%S)"
|
||||
git push -f
|
||||
|
||||
- name: Generate release tag
|
||||
if: env.ischanges == 'true'
|
||||
id: tag
|
||||
run: |
|
||||
echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")"
|
||||
echo "::set-output name=status::success"
|
||||
|
||||
- name: Zip EFI
|
||||
if: env.ischanges == 'true'
|
||||
uses: vimtor/action-zip@v1
|
||||
with:
|
||||
files: EFI README.md
|
||||
recursive: false
|
||||
dest: Hackintosh-EFI-MSI-Z490i-Unify-${{ steps.tag.outputs.release_tag }}.zip
|
||||
|
||||
- name: Upload firmware to release
|
||||
if: env.ischanges == 'true'
|
||||
uses: softprops/action-gh-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.tag.outputs.release_tag }}
|
||||
files: Hackintosh*.zip
|
||||
|
||||
- name: Delete workflow runs
|
||||
uses: GitRML/delete-workflow-runs@main
|
||||
with:
|
||||
retain_days: 1
|
||||
keep_minimum_runs: 3
|
||||
57
.gitignore
vendored
57
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/macos
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=macos
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/windows,macos,xcode
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,xcode
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
@@ -30,4 +30,55 @@ Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/macos
|
||||
### macOS Patch ###
|
||||
# iCloud generated files
|
||||
*.icloud
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
### Xcode ###
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## Xcode 8 and earlier
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
### Xcode Patch ###
|
||||
*.xcodeproj/*
|
||||
!*.xcodeproj/project.pbxproj
|
||||
!*.xcodeproj/xcshareddata/
|
||||
!*.xcworkspace/contents.xcworkspacedata
|
||||
/*.gcno
|
||||
**/xcshareddata/WorkspaceSettings.xcsettings
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/windows,macos,xcode
|
||||
|
||||
### OC ###
|
||||
.vscode
|
||||
.contentFlavour
|
||||
.gitkeep
|
||||
@@ -1,7 +1,7 @@
|
||||
# Hackintosh-EFI-MSI-Z490i-Unify
|
||||
|
||||
## 介绍
|
||||
MSI-Z490i-Unify-Hackintosh
|
||||
[Hackintosh-EFI-MSI-Z490i-Unify](https://github.com/wjz304/Hackintosh-EFI-MSI-Z490i-Unify)
|
||||
|
||||
## 说明
|
||||
MSI-Z490i-Unify 的黑苹果 EFI
|
||||
|
||||
286
update.py
Normal file
286
update.py
Normal file
@@ -0,0 +1,286 @@
|
||||
|
||||
|
||||
import os, sys, json, shutil, datetime, zipfile
|
||||
import urllib3
|
||||
import wget
|
||||
|
||||
PM = urllib3.PoolManager()
|
||||
|
||||
|
||||
date_curr = datetime.datetime.now(tz=datetime.timezone.utc).isoformat()
|
||||
date_last = ''
|
||||
|
||||
date_last_file = 'VERTIME'
|
||||
try:
|
||||
with open(date_last_file,'r') as f:
|
||||
date_last = f.read()
|
||||
except:
|
||||
pass
|
||||
|
||||
date_last = '' # Forced
|
||||
|
||||
|
||||
class UpdateKexts():
|
||||
def __init__(self, alpha = True) -> None:
|
||||
self.alpha = True
|
||||
self.kexts = [
|
||||
['Lilu', 'EFI/OC/Kexts/Lilu.kext', 'Lilu.kext'],
|
||||
['WhateverGreen', 'EFI/OC/Kexts/WhateverGreen.kext', 'WhateverGreen.kext'],
|
||||
['VirtualSMC', 'EFI/OC/Kexts/VirtualSMC.kext', 'Kexts/VirtualSMC.kext'],
|
||||
['VirtualSMC', 'EFI/OC/Kexts/SMCSuperIO.kext', 'Kexts/SMCSuperIO.kext'],
|
||||
['VirtualSMC', 'EFI/OC/Kexts/SMCProcessor.kext', 'Kexts/SMCProcessor.kext'],
|
||||
['AppleALC', 'EFI/OC/Kexts/AppleALC.kext', 'AppleALC.kext'],
|
||||
# ['LucyRTL8125Ethernet', 'EFI/OC/Kexts/LucyRTL8125Ethernet.kext', 'LucyRTL8125Ethernet.kext'],
|
||||
# ['itlwm', 'EFI/OC/Kexts/itlwm.kext', 'itlwm.kext'],
|
||||
# ['AirportItlwm', 'EFI/OC/Kexts/AirportItlwm.kext', 'AirportItlwm.kext'],
|
||||
['BrcmPatchRAM', 'EFI/OC/Kexts/BlueToolFixup.kext', 'BlueToolFixup.kext'],
|
||||
# ['IntelBluetoothInjector', 'EFI/OC/Kexts/IntelBluetoothInjector.kext', 'IntelBluetoothInjector.kext'],
|
||||
# ['IntelBluetoothFirmware', 'EFI/OC/Kexts/IntelBluetoothFirmware.kext', 'IntelBluetoothFirmware.kext'],
|
||||
]
|
||||
self.dortaniaKextsJson = None
|
||||
|
||||
def __dlExt(self, url, dir):
|
||||
fileName = './' + url.split('/')[-1]
|
||||
print('download {}'.format(fileName))
|
||||
if os.path.exists(fileName):
|
||||
os.remove(fileName)
|
||||
#data = PM.request('GET', url)
|
||||
#with open(fileName,'wb') as f:
|
||||
# f.write(data.data)
|
||||
wget.download(url, out=fileName)
|
||||
if os.path.exists(dir):
|
||||
shutil.rmtree(dir)
|
||||
with zipfile.ZipFile(fileName) as zf:
|
||||
zf.extractall(dir)
|
||||
os.remove(fileName)
|
||||
print('')
|
||||
|
||||
def __xcopy(self, srcPath, dstPath, ignore=None):
|
||||
print('xcopy {} to {}'.format(srcPath, dstPath))
|
||||
if os.path.exists(dstPath):
|
||||
if os.path.isdir(dstPath):
|
||||
shutil.rmtree(dstPath)
|
||||
else:
|
||||
os.remove(dstPath)
|
||||
if os.path.exists(srcPath):
|
||||
if os.path.isdir(srcPath):
|
||||
shutil.copytree(srcPath, dstPath, ignore=ignore)
|
||||
else:
|
||||
shutil.copy(srcPath, dstPath)
|
||||
|
||||
def __initDortaniaJson(self):
|
||||
print('get {}'.format('dortania config.json'))
|
||||
dortaniaUrl = 'https://raw.githubusercontent.com/dortania/build-repo/builds/config.json'
|
||||
#res = PM.request('GET', dortaniaUrl)
|
||||
#self.dortaniaKextsJson = json.loads(res.data.decode('utf-8'))
|
||||
wget.download(dortaniaUrl, out='dortaniaConfig.json')
|
||||
with open('dortaniaConfig.json', mode="rb") as f:
|
||||
self.dortaniaKextsJson = json.loads(f.read())
|
||||
os.remove('dortaniaConfig.json')
|
||||
print('')
|
||||
|
||||
def upgradeDortaniaKexts(self, kextName, dstPath, srcPath):
|
||||
if self.dortaniaKextsJson is None:
|
||||
self.__initDortaniaJson()
|
||||
print('upgrade {}'.format(kextName))
|
||||
if self.dortaniaKextsJson[kextName]['versions'][0]['date_built'] > self.dortaniaKextsJson[kextName]['versions'][len(self.dortaniaKextsJson[kextName]['versions']) - 1]['date_built']:
|
||||
idx = 0
|
||||
else:
|
||||
idx = len(self.dortaniaKextsJson[kextName]['versions']) - 1
|
||||
if self.dortaniaKextsJson[kextName]['versions'][idx]['date_built'] > date_last:
|
||||
url = self.dortaniaKextsJson[kextName]['versions'][idx]['links']['release']
|
||||
self.__dlExt(url, './tmp')
|
||||
self.__xcopy('./tmp/' + srcPath, dstPath)
|
||||
shutil.rmtree('./tmp')
|
||||
|
||||
|
||||
def upgradeI2C(self):
|
||||
print('upgrade {}'.format('VoodooI2C and VoodooI2CHID'))
|
||||
res = PM.request('GET', 'https://api.github.com/repos/VoodooI2C/VoodooI2C/releases')
|
||||
self.i2c = json.loads(res.data.decode('utf-8'))
|
||||
for i2cVer in self.i2c:
|
||||
if self.alpha is False and 'alpha' in i2cVer['name'].lower():
|
||||
continue
|
||||
if i2cVer['published_at'] > date_last:
|
||||
for item in i2cVer['assets']:
|
||||
if not 'debug' in item['name'].lower() and '.zip' in item['name'].lower():
|
||||
url = item['browser_download_url']
|
||||
self.__dlExt(url, './tmp')
|
||||
self.__xcopy('./tmp/VoodooI2C.kext', 'EFI/OC/Kexts/VoodooI2C.kext')
|
||||
self.__xcopy('./tmp/VoodooI2CHID.kext', 'EFI/OC/Kexts/VoodooI2CHID.kext')
|
||||
shutil.rmtree('./tmp')
|
||||
break
|
||||
break
|
||||
|
||||
|
||||
def upgradeEC(self):
|
||||
print('upgrade {}'.format('ECEnabler'))
|
||||
res = PM.request('GET', 'https://api.github.com/repos/1Revenger1/ECEnabler/releases')
|
||||
self.i2c = json.loads(res.data.decode('utf-8'))
|
||||
for i2cVer in self.i2c:
|
||||
if self.alpha is False and 'alpha' in i2cVer['name'].lower():
|
||||
continue
|
||||
if i2cVer['published_at'] > date_last:
|
||||
for item in i2cVer['assets']:
|
||||
if not 'debug' in item['name'].lower() and '.zip' in item['name'].lower():
|
||||
url = item['browser_download_url']
|
||||
self.__dlExt(url, './tmp')
|
||||
self.__xcopy('./tmp/ECEnabler.kext', 'EFI/OC/Kexts/ECEnabler.kext')
|
||||
shutil.rmtree('./tmp')
|
||||
break
|
||||
break
|
||||
|
||||
def upgradeRTL8125E(self):
|
||||
print('upgrade {}'.format('ECEnabler'))
|
||||
res = PM.request('GET', 'https://api.github.com/repos/Mieze/LucyRTL8125Ethernet/releases')
|
||||
self.i2c = json.loads(res.data.decode('utf-8'))
|
||||
for i2cVer in self.i2c:
|
||||
if self.alpha is False and 'alpha' in i2cVer['name'].lower():
|
||||
continue
|
||||
if i2cVer['published_at'] > date_last:
|
||||
for item in i2cVer['assets']:
|
||||
if not 'debug' in item['name'].lower() and '.zip' in item['name'].lower():
|
||||
url = item['browser_download_url']
|
||||
self.__dlExt(url, './tmp')
|
||||
self.__xcopy('./tmp/ECEnabler.kext', 'EFI/OC/Kexts/ECEnabler.kext')
|
||||
shutil.rmtree('./tmp')
|
||||
break
|
||||
break
|
||||
|
||||
def upgradeIntel(self):
|
||||
print('upgrade {}'.format('AirportItlwm'))
|
||||
res = PM.request('GET', 'https://api.github.com/repos/OpenIntelWireless/itlwm/releases')
|
||||
self.itlwm = json.loads(res.data.decode('utf-8'))
|
||||
for itlwmVer in self.itlwm:
|
||||
if self.alpha is False and 'alpha' in itlwmVer['name'].lower():
|
||||
continue
|
||||
if itlwmVer['published_at'] > date_last:
|
||||
for item in itlwmVer['assets']:
|
||||
if 'ventura' in item['name'].lower():
|
||||
url = item['browser_download_url']
|
||||
self.__dlExt(url, './tmp')
|
||||
self.__xcopy('./tmp/Ventura/AirportItlwm.kext', 'EFI/OC/Kexts/AirportItlwm.kext')
|
||||
shutil.rmtree('./tmp')
|
||||
break
|
||||
for item in itlwmVer['assets']:
|
||||
if not 'airport' in item['name'].lower() and '.zip' in item['name'].lower():
|
||||
url = item['browser_download_url']
|
||||
self.__dlExt(url, './tmp')
|
||||
self.__xcopy('./tmp/itlwm.kext', 'EFI/OC/Kexts/itlwm.kext')
|
||||
shutil.rmtree('./tmp')
|
||||
break
|
||||
break
|
||||
|
||||
|
||||
print('upgrade {}'.format('IntelBluetoothFirmware and IntelBluetoothInjector'))
|
||||
res = PM.request('GET', 'https://api.github.com/repos/OpenIntelWireless/IntelBluetoothFirmware/releases')
|
||||
self.ibt = json.loads(res.data.decode('utf-8'))
|
||||
for ibtVer in self.ibt:
|
||||
if self.alpha is False and 'alpha' in ibtVer['name'].lower():
|
||||
continue
|
||||
if ibtVer['published_at'] > date_last:
|
||||
for item in ibtVer['assets']:
|
||||
if '.zip' in item['name'].lower():
|
||||
url = item['browser_download_url']
|
||||
self.__dlExt(url, './tmp')
|
||||
self.__xcopy('./tmp/IntelBluetoothFirmware.kext', 'EFI/OC/Kexts/IntelBluetoothFirmware.kext')
|
||||
self.__xcopy('./tmp/IntelBluetoothInjector.kext', 'EFI/OC/Kexts/IntelBluetoothInjector.kext')
|
||||
shutil.rmtree('./tmp')
|
||||
break
|
||||
break
|
||||
|
||||
|
||||
def upgradeOC(self):
|
||||
print('upgrade {}'.format('OpenCore_Mod'))
|
||||
url = ''
|
||||
if self.alpha is False:
|
||||
url = 'https://api.github.com/repos/OlarilaHackintosh/OpenCore_NO_ACPI/releases'
|
||||
else:
|
||||
url = 'https://api.github.com/repos/wjz304/OpenCore_NO_ACPI_Build/releases'
|
||||
res = PM.request('GET', url)
|
||||
self.ocmod = json.loads(res.data.decode('utf-8'))
|
||||
for ocVer in self.ocmod:
|
||||
if ocVer['published_at'] > date_last:
|
||||
|
||||
for item in ocVer['assets']:
|
||||
if 'release' in item['name'].lower():
|
||||
url = item['browser_download_url']
|
||||
self.__dlExt(url, './tmp')
|
||||
|
||||
if os.path.exists('EFI/BOOT/BOOTx64.efi'):
|
||||
self.__xcopy('./tmp/X64/EFI/BOOT/BOOTx64.efi', 'EFI/BOOT/BOOTx64.efi')
|
||||
|
||||
if os.path.exists('EFI/OC/OpenCore.efi'):
|
||||
self.__xcopy('./tmp/X64/EFI/OC/OpenCore.efi', 'EFI/OC/OpenCore.efi')
|
||||
|
||||
if os.path.exists('EFI/OC/Drivers'):
|
||||
for efi in os.listdir('EFI/OC/Drivers'):
|
||||
self.__xcopy('./tmp/X64/EFI/OC/Drivers/{}'.format(efi), 'EFI/OC/Drivers/{}'.format(efi))
|
||||
|
||||
if os.path.exists('EFI/OC/Tools'):
|
||||
for efi in os.listdir('EFI/OC/Tools'):
|
||||
self.__xcopy('./tmp/X64/EFI/OC/Tools/{}'.format(efi), 'EFI/OC/Tools/{}'.format(efi))
|
||||
|
||||
if os.path.exists('EFI/OC/Resources'):
|
||||
background = ''
|
||||
if os.path.exists('EFI/OC/Resources/Image/Acidanthera/GoldenGate/Background.icns'):
|
||||
with open('EFI/OC/Resources/Image/Acidanthera/GoldenGate/Background.icns', mode="rb") as f:
|
||||
background = f.read()
|
||||
self.__xcopy('./tmp/X64/EFI/OC/Resources', 'EFI/OC/Resources', ignore = shutil.ignore_patterns('.*'))
|
||||
os.remove('EFI/OC/Resources/Image/Acidanthera/GoldenGate/Background.icns')
|
||||
if background != '':
|
||||
with open('EFI/OC/Resources/Image/Acidanthera/GoldenGate/Background.icns', mode="wb") as f:
|
||||
f.write(background)
|
||||
shutil.rmtree('./tmp')
|
||||
break
|
||||
break
|
||||
|
||||
|
||||
|
||||
def update(self):
|
||||
|
||||
if self.alpha is True:
|
||||
for kext in self.kexts:
|
||||
try:
|
||||
self.upgradeDortaniaKexts(kext[0], kext[1], kext[2])
|
||||
except:
|
||||
print('Dortania Kexts update error!')
|
||||
return 1
|
||||
else:
|
||||
# no idea
|
||||
pass
|
||||
|
||||
try:
|
||||
self.upgradeIntel()
|
||||
except:
|
||||
print('Intel Kexts update error!')
|
||||
return 2
|
||||
|
||||
try:
|
||||
self.upgradeRTL8125E()
|
||||
except:
|
||||
print('RTL8125E Kexts update error!')
|
||||
return 2
|
||||
|
||||
try:
|
||||
self.upgradeOC()
|
||||
except:
|
||||
print('OC update error!')
|
||||
return 3
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
u1 = UpdateKexts(alpha = True)
|
||||
ret = u1.update()
|
||||
|
||||
if ret == 0:
|
||||
with open(date_last_file, mode="w") as f:
|
||||
f.write(datetime.datetime.now(tz=datetime.timezone.utc).isoformat())
|
||||
else:
|
||||
print('error!')
|
||||
|
||||
sys.exit(ret)
|
||||
Reference in New Issue
Block a user