From 567006dc32a7b3e0f2167c4e83a0508bcb34e543 Mon Sep 17 00:00:00 2001 From: Hoang Hong Quan Date: Wed, 16 Oct 2024 21:59:12 +0700 Subject: [PATCH] Update and add credits for code from SSDTTime --- OpCore-Simplify.bat | 7 +++-- OpCore-Simplify.command | 63 +++++++++++++++++++++++++++++++---------- Scripts/dsdt.py | 28 +++++++++++++++--- Scripts/run.py | 3 +- 4 files changed, 78 insertions(+), 23 deletions(-) mode change 100755 => 100644 OpCore-Simplify.bat mode change 100755 => 100644 Scripts/run.py diff --git a/OpCore-Simplify.bat b/OpCore-Simplify.bat old mode 100755 new mode 100644 index adb1379..ee1fcd0 --- a/OpCore-Simplify.bat +++ b/OpCore-Simplify.bat @@ -1,3 +1,5 @@ +# Source: https://github.com/corpnewt/SSDTTime/blob/97a3963e40a153a8df5ae61a73e150cd7a119b3c/SSDTTime.bat + @echo off REM Get our local path before delayed expansion - allows ! in path set "thisDir=%~dp0" @@ -310,11 +312,12 @@ if "!args!"=="" ( ) if /i "!pause_on_error!" == "yes" ( if not "%ERRORLEVEL%" == "0" ( + echo. echo Script exited with error code: %ERRORLEVEL% echo. + echo Press [enter] to exit... + pause > nul ) - echo Press Enter to exit... - pause > nul ) goto :EOF diff --git a/OpCore-Simplify.command b/OpCore-Simplify.command index 30f4078..3fbb13a 100755 --- a/OpCore-Simplify.command +++ b/OpCore-Simplify.command @@ -1,9 +1,11 @@ +# Source: https://github.com/corpnewt/SSDTTime/blob/97a3963e40a153a8df5ae61a73e150cd7a119b3c/SSDTTime.command + #!/usr/bin/env bash # Get the curent directory, the script name # and the script name with "py" substituted for the extension. args=( "$@" ) -dir="${0%/*}" +dir="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" script="${0##*/}" target="${script%.*}.py" @@ -13,6 +15,10 @@ target="${script%.*}.py" # FORCE = Use py3 use_py3="TRUE" +# We'll parse if the first argument passed is +# --install-python and if so, we'll just install +just_installing="FALSE" + tempdir="" compare_to_version () { @@ -55,7 +61,7 @@ set_use_py3_if () { get_remote_py_version () { local pyurl= py_html= py_vers= py_num="3" pyurl="https://www.python.org/downloads/macos/" - py_html="$(curl -L $pyurl 2>&1)" + py_html="$(curl -L $pyurl --compressed 2>&1)" if [ -z "$use_py3" ]; then use_py3="TRUE" fi @@ -84,7 +90,7 @@ download_py () { echo "Located Version: $vers" echo echo "Building download url..." - url="$(curl -L https://www.python.org/downloads/release/python-${vers//./}/ 2>&1 | grep -iE "python-$vers-macos.*.pkg\"" | awk -F'"' '{ print $2 }')" + url="$(curl -L https://www.python.org/downloads/release/python-${vers//./}/ --compressed 2>&1 | grep -iE "python-$vers-macos.*.pkg\"" | awk -F'"' '{ print $2 }')" if [ -z "$url" ]; then # Couldn't get the URL - bail print_error @@ -104,6 +110,7 @@ download_py () { fi echo echo "Running python install package..." + echo sudo installer -pkg "$tempdir/python.pkg" -target / if [ "$?" != "0" ]; then echo @@ -111,23 +118,36 @@ download_py () { echo exit $? fi - echo + # Now we expand the package and look for a shell update script + pkgutil --expand "$tempdir/python.pkg" "$tempdir/python" + if [ -e "$tempdir/python/Python_Shell_Profile_Updater.pkg/Scripts/postinstall" ]; then + # Run the script + echo + echo "Updating PATH..." + echo + "$tempdir/python/Python_Shell_Profile_Updater.pkg/Scripts/postinstall" + fi vers_folder="Python $(echo "$vers" | cut -d'.' -f1 -f2)" if [ -f "/Applications/$vers_folder/Install Certificates.command" ]; then # Certs script exists - let's execute that to make sure our certificates are updated + echo echo "Updating Certificates..." echo "/Applications/$vers_folder/Install Certificates.command" - echo fi + echo echo "Cleaning up..." cleanup echo - # Now we check for py again - echo "Rechecking py..." - downloaded="TRUE" - clear - main + if [ "$just_installing" == "TRUE" ]; then + echo "Done." + else + # Now we check for py again + echo "Rechecking py..." + downloaded="TRUE" + clear + main + fi } cleanup () { @@ -145,8 +165,13 @@ print_error() { echo echo "Python is not installed or not found in your PATH var." echo - echo "Please go to https://www.python.org/downloads/macos/" - echo "to download and install the latest version." + if [ "$kernel" == "Darwin" ]; then + echo "Please go to https://www.python.org/downloads/macos/ to" + echo "download and install the latest version, then try again." + else + echo "Please install python through your package manager and" + echo "try again." + fi echo exit 1 } @@ -228,8 +253,8 @@ get_python_version() { } prompt_and_download() { - if [ "$downloaded" != "FALSE" ]; then - # We already tried to download - just bail + if [ "$downloaded" != "FALSE" ] || [ "$kernel" != "Darwin" ]; then + # We already tried to download, or we're not on macOS - just bail print_error fi clear @@ -289,6 +314,9 @@ main() { "$python" "$dir/$target" "${args[@]}" } +# Keep track of whether or not we're on macOS to determine if +# we can download and install python for the user as needed. +kernel="$(uname -s)" # Check to see if we need to force based on # macOS version. 10.15 has a dummy python3 version # that can trip up some py3 detection in other scripts. @@ -298,4 +326,9 @@ downloaded="FALSE" # our OS version is 10.15 or greater. check_py3_stub="$(compare_to_version "3" "10.15")" trap cleanup EXIT -main +if [ "$1" == "--install-python" ] && [ "$kernel" == "Darwin" ]; then + just_installing="TRUE" + download_py +else + main +fi \ No newline at end of file diff --git a/Scripts/dsdt.py b/Scripts/dsdt.py index cfa37b0..b55aeb4 100644 --- a/Scripts/dsdt.py +++ b/Scripts/dsdt.py @@ -1,5 +1,4 @@ -# Original source: -# https://github.com/corpnewt/SSDTTime/blob/b3863aff1b387585a54825f325f071f43e1970db/Scripts/dsdt.py +# Original source: https://github.com/corpnewt/SSDTTime/blob/64446d553fcbc14a4e6ebf3d8d16e3357b5cbf50/Scripts/dsdt.py import os, errno, tempfile, shutil, plistlib, sys, binascii, zipfile, getpass, re from Scripts import resource_fetcher @@ -254,8 +253,29 @@ class DSDT: #source = self.dl.get_string(self.acpi_binary_tools, headers=self.h) source = self.fetcher.fetch_and_parse_content(self.acpi_binary_tools) for line in source.split("\n"): - if "href" in line and ">iasl compiler and windows acpi tools" in line.lower(): - return line.split('iasl compiler and windows acpi tools" in line.lower(): + # Check if we have a direct download link - i.e. ends with .zip - or if we're + # redirected to a different download page - i.e. ends with .html + dl_link = line.split('iASL Compiler and Windows ACPI Tools + # Only a suffix - prepend to it + dl_page_url = "https://www.intel.com" + line.split('