2016-12-05 18:41:05 +00:00
|
|
|
@ECHO OFF
|
|
|
|
SETLOCAL ENABLEEXTENSIONS
|
|
|
|
SET me=%~nx0
|
|
|
|
SET parent=%~dp0
|
|
|
|
SET tab=
|
|
|
|
SET OK=
|
2017-04-18 14:25:36 +00:00
|
|
|
SET DEBUG=
|
2016-12-05 18:41:05 +00:00
|
|
|
|
|
|
|
CD %parent%
|
|
|
|
|
2017-04-18 14:25:36 +00:00
|
|
|
call :%~1 "%~2" "%~3"
|
2016-12-05 18:41:05 +00:00
|
|
|
IF NOT DEFINED OK CALL :usage
|
|
|
|
|
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
:usage
|
2017-04-18 14:25:36 +00:00
|
|
|
ECHO %me% all ^<version name^> ^<version code^>
|
2016-12-05 18:41:05 +00:00
|
|
|
ECHO %tab%Build binaries, zip, and sign Magisk
|
|
|
|
ECHO %tab%This is equlivant to first ^<build^>, then ^<zip^>
|
|
|
|
ECHO %me% clean
|
|
|
|
ECHO %tab%Cleanup compiled / generated files
|
2017-04-18 14:25:36 +00:00
|
|
|
ECHO %me% build ^<version name^> ^<version code^>
|
2016-12-05 18:41:05 +00:00
|
|
|
ECHO %tab%Build the binaries with ndk
|
2017-04-18 14:25:36 +00:00
|
|
|
ECHO %me% debug
|
|
|
|
ECHO %tab%Build the binaries with the debug flag on
|
|
|
|
ECHO %tab%Call ^<zip^> afterwards if you want to flash on device
|
2016-12-05 18:41:05 +00:00
|
|
|
ECHO %me% zip ^<version name^>
|
|
|
|
ECHO %tab%Zip and sign Magisk
|
|
|
|
ECHO %me% uninstaller
|
|
|
|
ECHO %tab%Zip and sign the uninstaller
|
|
|
|
EXIT /B 1
|
|
|
|
|
|
|
|
:all
|
|
|
|
SET OK=y
|
2017-04-18 14:25:36 +00:00
|
|
|
CALL :build "%~1" "%~2"
|
2016-12-05 18:41:05 +00:00
|
|
|
CALL :zip "%~1"
|
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
|
2017-04-18 14:25:36 +00:00
|
|
|
:debug
|
|
|
|
SET OK=y
|
|
|
|
SET DEBUG=-DDEBUG
|
2017-04-19 21:07:52 +00:00
|
|
|
CALL :build "%~1" "%~2"
|
2017-04-18 14:25:36 +00:00
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
|
2016-12-05 18:41:05 +00:00
|
|
|
:build
|
|
|
|
SET OK=y
|
2017-04-18 14:25:36 +00:00
|
|
|
IF [%~1] == [] (
|
|
|
|
CALL :error "Missing version info"
|
|
|
|
CALL :usage
|
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
)
|
|
|
|
IF [%~2] == [] (
|
|
|
|
CALL :error "Missing version info"
|
|
|
|
CALL :usage
|
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
)
|
2017-04-19 21:07:52 +00:00
|
|
|
SET BUILD=Build
|
|
|
|
IF NOT [%DEBUG%] == [] (
|
|
|
|
SET BUILD=Debug
|
|
|
|
)
|
2016-12-05 18:41:05 +00:00
|
|
|
ECHO ************************
|
2017-04-19 21:07:52 +00:00
|
|
|
ECHO * %BUILD%: VERSION=%~1 CODE=%~2
|
2016-12-05 18:41:05 +00:00
|
|
|
ECHO ************************
|
|
|
|
FOR /F "tokens=* USEBACKQ" %%F IN (`where ndk-build`) DO (
|
|
|
|
IF [%%F] == [] (
|
|
|
|
CALL :error "Please add ndk-build to PATH!"
|
|
|
|
EXIT /B 1
|
|
|
|
)
|
|
|
|
)
|
2017-04-18 14:25:36 +00:00
|
|
|
CALL ndk-build APP_CFLAGS="-DMAGISK_VERSION=%~1 -DMAGISK_VER_CODE=%~2 %DEBUG%" -j%NUMBER_OF_PROCESSORS% || CALL :error "Magisk binary tools build failed...."
|
2016-12-05 18:41:05 +00:00
|
|
|
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
|
|
|
|
ECHO ************************
|
|
|
|
ECHO * Copying binaries
|
|
|
|
ECHO ************************
|
2017-04-15 18:49:01 +00:00
|
|
|
CALL :mkcp libs\armeabi-v7a\magisk zip_static\arm
|
|
|
|
CALL :mkcp libs\armeabi-v7a\magiskboot zip_static\arm
|
|
|
|
CALL :mkcp libs\arm64-v8a\magisk zip_static\arm64
|
|
|
|
CALL :mkcp libs\arm64-v8a\magiskboot zip_static\arm64
|
|
|
|
CALL :mkcp libs\x86\magisk zip_static\x86
|
|
|
|
CALL :mkcp libs\x86\magiskboot zip_static\x86
|
|
|
|
CALL :mkcp libs\x86_64\magisk zip_static\x64
|
|
|
|
CALL :mkcp libs\x86_64\magiskboot zip_static\x64
|
2017-03-11 17:24:30 +00:00
|
|
|
CALL :mkcp libs\armeabi-v7a\magiskboot uninstaller\arm
|
|
|
|
CALL :mkcp libs\arm64-v8a\magiskboot uninstaller\arm64
|
|
|
|
CALL :mkcp libs\x86\magiskboot uninstaller\x86
|
|
|
|
CALL :mkcp libs\x86_64\magiskboot uninstaller\x64
|
2016-12-05 18:41:05 +00:00
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
|
|
|
|
:clean
|
|
|
|
SET OK=y
|
|
|
|
ECHO ************************
|
|
|
|
ECHO * Cleaning up
|
|
|
|
ECHO ************************
|
|
|
|
CALL ndk-build clean
|
2017-02-13 22:28:07 +00:00
|
|
|
2>NUL RMDIR /S /Q zip_static\arm
|
|
|
|
2>NUL RMDIR /S /Q zip_static\arm64
|
|
|
|
2>NUL RMDIR /S /Q zip_static\x86
|
|
|
|
2>NUL RMDIR /S /Q zip_static\x64
|
2016-12-05 18:41:05 +00:00
|
|
|
2>NUL DEL zip_static\META-INF\com\google\android\update-binary
|
2017-03-12 10:13:58 +00:00
|
|
|
2>NUL DEL zip_static\common\*.sh
|
|
|
|
2>NUL DEL zip_static\common\*.rc
|
2017-02-05 19:22:37 +00:00
|
|
|
2>NUL RMDIR /S /Q uninstaller\common
|
2016-12-05 18:41:05 +00:00
|
|
|
2>NUL RMDIR /S /Q uninstaller\arm
|
|
|
|
2>NUL RMDIR /S /Q uninstaller\arm64
|
|
|
|
2>NUL RMDIR /S /Q uninstaller\x86
|
|
|
|
2>NUL RMDIR /S /Q uninstaller\x64
|
|
|
|
EXIT /B 0
|
|
|
|
|
|
|
|
:zip
|
|
|
|
SET OK=y
|
|
|
|
IF [%~1] == [] (
|
2017-04-18 14:25:36 +00:00
|
|
|
CALL :error "Missing version info"
|
2016-12-05 18:41:05 +00:00
|
|
|
CALL :usage
|
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
)
|
2017-03-11 17:24:30 +00:00
|
|
|
IF NOT EXIST "zip_static\arm\magiskboot" CALL :error "Missing binaries! Please run '%me% build' before zipping!"
|
2016-12-05 18:41:05 +00:00
|
|
|
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
|
|
|
|
ECHO ************************
|
|
|
|
ECHO * Adding version info
|
|
|
|
ECHO ************************
|
2017-04-21 23:05:10 +00:00
|
|
|
powershell.exe -nologo -noprofile -command "(gc -Raw scripts\flash_script.sh) -replace 'MAGISK_VERSION_STUB', 'Magisk v%~1 Installer' | sc zip_static\META-INF\com\google\android\update-binary"
|
|
|
|
rem powershell.exe -nologo -noprofile -command "(gc -Raw scripts\magic_mask.sh) -replace 'MAGISK_VERSION_STUB', 'setprop magisk.version \"%~1\"' | sc zip_static\common\magic_mask.sh"
|
2016-12-05 18:41:05 +00:00
|
|
|
ECHO ************************
|
2017-02-13 22:28:07 +00:00
|
|
|
ECHO * Copying Files
|
2016-12-05 18:41:05 +00:00
|
|
|
ECHO ************************
|
2017-03-30 22:25:22 +00:00
|
|
|
COPY /Y scripts\custom_ramdisk_patch.sh zip_static\common\custom_ramdisk_patch.sh
|
2017-01-31 22:02:43 +00:00
|
|
|
COPY /Y scripts\init.magisk.rc zip_static\common\init.magisk.rc
|
2017-02-13 22:28:07 +00:00
|
|
|
ECHO ************************
|
|
|
|
ECHO * Zipping Magisk v%~1
|
|
|
|
ECHO ************************
|
2016-12-05 18:41:05 +00:00
|
|
|
CD zip_static
|
|
|
|
2>NUL DEL "..\Magisk-v%~1.zip"
|
|
|
|
..\ziptools\win_bin\zip "..\Magisk-v%~1.zip" -r .
|
|
|
|
CD ..\
|
|
|
|
CALL :sign_zip "Magisk-v%~1.zip"
|
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
|
|
|
|
:uninstaller
|
|
|
|
SET OK=y
|
2017-03-11 17:24:30 +00:00
|
|
|
IF NOT EXIST "uninstaller\arm\magiskboot" CALL :error "Missing binaries! Please run '%me% build' before zipping!"
|
2016-12-05 18:41:05 +00:00
|
|
|
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
|
|
|
|
ECHO ************************
|
2017-02-13 22:28:07 +00:00
|
|
|
ECHO * Copying Files
|
2016-12-05 18:41:05 +00:00
|
|
|
ECHO ************************
|
2017-02-05 19:22:37 +00:00
|
|
|
CALL :mkcp scripts\magisk_uninstaller.sh uninstaller\common
|
2017-02-13 22:28:07 +00:00
|
|
|
ECHO ************************
|
|
|
|
ECHO * Zipping uninstaller
|
|
|
|
ECHO ************************
|
2016-12-05 18:41:05 +00:00
|
|
|
FOR /F "tokens=* USEBACKQ" %%F IN (`ziptools\win_bin\date "+%%Y%%m%%d"`) DO (set timestamp=%%F)
|
|
|
|
CD uninstaller
|
|
|
|
2>NUL DEL "../Magisk-uninstaller-%timestamp%.zip"
|
|
|
|
..\ziptools\win_bin\zip "../Magisk-uninstaller-%timestamp%.zip" -r .
|
|
|
|
CD ..\
|
|
|
|
CALL :sign_zip "Magisk-uninstaller-%timestamp%.zip"
|
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
|
|
|
|
:sign_zip
|
|
|
|
IF NOT EXIST "ziptools\win_bin\zipadjust.exe" (
|
|
|
|
ECHO ************************
|
|
|
|
ECHO * Compiling ZipAdjust
|
|
|
|
ECHO ************************
|
|
|
|
gcc -o ziptools\win_bin\zipadjust ziptools\src\*.c -lz || CALL :error "ZipAdjust Build failed...."
|
|
|
|
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
|
|
|
|
)
|
|
|
|
SET basename="%~1"
|
|
|
|
SET basename="%basename:.zip=%"
|
|
|
|
ECHO ************************
|
|
|
|
ECHO * First sign %~1
|
|
|
|
ECHO ************************
|
|
|
|
java -jar "ziptools\signapk.jar" "ziptools\test.certificate.x509.pem" "ziptools\test.key.pk8" "%~1" "%basename:"=%-firstsign.zip"
|
|
|
|
ECHO ************************
|
|
|
|
ECHO * Adjusting %~1
|
|
|
|
ECHO ************************
|
|
|
|
ziptools\win_bin\zipadjust "%basename:"=%-firstsign.zip" "%basename:"=%-adjusted.zip"
|
|
|
|
ECHO ************************
|
|
|
|
ECHO * Final sign %~1
|
|
|
|
ECHO ************************
|
|
|
|
java -jar "ziptools\minsignapk.jar" "ziptools\test.certificate.x509.pem" "ziptools\test.key.pk8" "%basename:"=%-adjusted.zip" "%basename:"=%-signed.zip"
|
|
|
|
|
|
|
|
MOVE /Y "%basename:"=%-signed.zip" "%~1"
|
|
|
|
DEL "%basename:"=%-adjusted.zip" "%basename:"=%-firstsign.zip"
|
|
|
|
EXIT /B %ERRORLEVEL%
|
|
|
|
|
|
|
|
:mkcp
|
|
|
|
2>NUL MKDIR "%~2"
|
|
|
|
2>NUL COPY /Y "%~1" "%~2"
|
|
|
|
EXIT /B 0
|
|
|
|
|
|
|
|
:error
|
|
|
|
ECHO.
|
|
|
|
ECHO ! %~1
|
|
|
|
ECHO.
|
|
|
|
EXIT /B 1
|