mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 07:57:39 +00:00
Provide external files to Magisk Manager with build script
This commit is contained in:
parent
24164c8580
commit
edaf8787d1
43
README.MD
43
README.MD
@ -4,29 +4,29 @@
|
|||||||
|
|
||||||
#### Building has been tested on 3 major platforms:
|
#### Building has been tested on 3 major platforms:
|
||||||
|
|
||||||
***macOS 10.12.5***
|
***macOS 10.12.5***
|
||||||
***Ubuntu 17.04 x64***
|
***Ubuntu 17.04 x64***
|
||||||
***Windows 10 Creators Update x64***
|
***Windows 10 Creators Update x64***
|
||||||
|
|
||||||
#### Environment Requirements
|
#### Environment Requirements
|
||||||
|
|
||||||
1. Python 3 **(>= 3.5)**: `python3` (or in some cases `python`) should be accessible
|
1. Python 3 **(>= 3.5)**: `python3` (or in some cases `python`) should be accessible
|
||||||
2. Java runtime: `java` should be accessible
|
2. Java runtime: `java` should be accessible
|
||||||
3. (Unix only) C compiler: `gcc` should be accessible
|
3. (Unix only) C compiler: `gcc` should be accessible
|
||||||
4. Android SDK: `ANDROID_HOME` environment variable should point to the Android SDK folder
|
4. Android SDK: `ANDROID_HOME` environment variable should point to the Android SDK folder
|
||||||
5. NDK: Install NDK using `sdkmanager`, or through Android SDK Manager
|
5. NDK: Install NDK using `sdkmanager`, or through Android SDK Manager
|
||||||
6. Android build-tools: Should have build-tools version matching `MagiskManager/app/build.gradle` installed
|
6. Android build-tools: Should have build-tools version matching `MagiskManager/app/build.gradle` installed
|
||||||
|
|
||||||
#### Instructions and Notes
|
#### Instructions and Notes
|
||||||
|
|
||||||
1. The python build script uses ANSI color codes to change the color of the terminal output. For Windows, this **only** works on Windows 10, as previous Windows console do not support them. If you insist to use an older Windows version, a quick Google search should provide many workarounds
|
1. The python build script uses ANSI color codes to change the color of the terminal output. For Windows, this **only** works on Windows 10, as previous Windows console do not support them. If you insist to use an older Windows version, a quick Google search should provide many workarounds
|
||||||
2. After installing the latest Python 3 on Windows (allow the installer to add Python to PATH, or you'll have to manually set the environment), instead of calling `python3` like most Unix environment, you should call `python` in shell (cmd or Powershell both OK). You can double check the version by `python --version`
|
2. After installing the latest Python 3 on Windows (allow the installer to add Python to PATH, or you'll have to manually set the environment), instead of calling `python3` like most Unix environment, you should call `python` in shell (cmd or Powershell both OK). You can double check the version by `python --version`
|
||||||
3. The build script will do several checks, it will refuse to run if the environment doesn't meet the requirements
|
3. The build script will do several checks, it will refuse to run if the environment doesn't meet the requirements
|
||||||
4. For further instructions, please check the built in help message by `python3 build.py -h`
|
4. For further instructions, please check the built in help message by `python3 build.py -h`
|
||||||
(Unix users can simply `./build.py -h`, Windows users, as mentioned, call `python` instead)
|
(Unix users can simply `./build.py -h`, Windows users, as mentioned, call `python` instead)
|
||||||
5. Each action has its own help message, access them by commands like `python3 build.py all -h`
|
5. Each action has its own help message, access them by commands like `python3 build.py all -h`
|
||||||
6. To build Magisk for release (enabled through the `--release` flag, the script builds in debug mode by default), you will need to provide a Java keystore file, and place it in `release_signature.jks` to sign Magisk Manager APK for release builds. For more information, check out [Google's Official Documentation](https://developer.android.com/studio/publish/app-signing.html#signing-manually)
|
6. To build Magisk for release (enabled through the `--release` flag, the script builds in debug mode by default), you will need to provide a Java keystore file, and place it in `release_signature.jks` to sign Magisk Manager APK for release builds. For more information, check out [Google's Official Documentation](https://developer.android.com/studio/publish/app-signing.html#signing-manually)
|
||||||
7. To properly setup the Android SDK environment, the easiest way is to use Android Studio and open Magisk Manager. If gradle sync passed, your build-tools etc. should be set properly. You can also access SDK Manager GUI within Android Studio to download NDK. Don't forget to add Android Studio's SDK path into environment variable ANDROID_HOME.
|
7. To properly setup the Android SDK environment, the easiest way is to use Android Studio and open Magisk Manager. If gradle sync passed, your build-tools etc. should be set properly. You can also access SDK Manager GUI within Android Studio to download NDK. Don't forget to add Android Studio's SDK path into environment variable ANDROID_HOME.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
@ -65,14 +65,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
**resetprop** (`jni/resetprop`)
|
**resetprop** (`jni/resetprop`)
|
||||||
* Copyright 2016-2017 John Wu (@topjohnwu)
|
* Copyright 2016-2017 John Wu (@topjohnwu)
|
||||||
* Copyright 2016 nkk71 (nkk71x@gmail.com)
|
* Copyright 2016 nkk71 (nkk71x@gmail.com)
|
||||||
|
|
||||||
**SELinux** (`jni/selinux`)
|
**SELinux** (`jni/selinux`)
|
||||||
* Makefile for NDK: Copyright 2016-2017, John Wu (@topjohnwu)
|
* Makefile for NDK: Copyright 2016-2017, John Wu (@topjohnwu)
|
||||||
* It is maintained by many developers in SELinux project, copyright belongs to them
|
* Maintained by many developers in SELinux project
|
||||||
|
|
||||||
**ndk-compression** (`jni/ndk-compression`)
|
**ndk-compression** (`jni/ndk-compression`)
|
||||||
* Makefile for NDK: Copyright 2017, John Wu (@topjohnwu)
|
* Makefile for NDK: Copyright 2017, John Wu (@topjohnwu)
|
||||||
* Each library has its own copyright message in each directories
|
* Each library has its own copyright message in corresponding directories
|
||||||
|
|
||||||
|
**ndk-busybox** (`jni/busybox`)
|
||||||
|
* Makefile for NDK, generated by [ndk-busybox-kitchen](https://github.com/topjohnwu/ndk-busybox-kitchen): Copyright 2017, John Wu (@topjohnwu)
|
||||||
|
* Patches for NDK: Many contributors along the way, all placed in [osm0sis/android-busybox-ndk](https://github.com/osm0sis/android-busybox-ndk)
|
||||||
|
* The copyright message for busybox should be included in its own directory
|
||||||
|
|
||||||
**Others Not Mentioned**
|
**Others Not Mentioned**
|
||||||
* Copyright 2016-2017, John Wu (@topjohnwu)
|
* Copyright 2016-2017, John Wu (@topjohnwu)
|
||||||
|
39
build.py
39
build.py
@ -34,6 +34,7 @@ import multiprocessing
|
|||||||
import zipfile
|
import zipfile
|
||||||
import datetime
|
import datetime
|
||||||
import errno
|
import errno
|
||||||
|
import shutil
|
||||||
|
|
||||||
def silentremove(file):
|
def silentremove(file):
|
||||||
try:
|
try:
|
||||||
@ -45,7 +46,7 @@ def silentremove(file):
|
|||||||
def zip_with_msg(zipfile, source, target):
|
def zip_with_msg(zipfile, source, target):
|
||||||
if not os.path.exists(source):
|
if not os.path.exists(source):
|
||||||
error('{} does not exist! Try build \'binary\' and \'apk\' before zipping!'.format(source))
|
error('{} does not exist! Try build \'binary\' and \'apk\' before zipping!'.format(source))
|
||||||
print('zip: ' + source + ' -> ' + target)
|
print('zip: {} -> {}'.format(source, target))
|
||||||
zipfile.write(source, target)
|
zipfile.write(source, target)
|
||||||
|
|
||||||
def build_all(args):
|
def build_all(args):
|
||||||
@ -67,6 +68,34 @@ def build_binary(args):
|
|||||||
def build_apk(args):
|
def build_apk(args):
|
||||||
header('* Building Magisk Manager')
|
header('* Building Magisk Manager')
|
||||||
|
|
||||||
|
for arch in ['armeabi-v7a', 'x86']:
|
||||||
|
source = os.path.join('libs', arch, 'busybox')
|
||||||
|
target = os.path.join('MagiskManager', 'app', 'src', 'main', 'jniLibs', arch)
|
||||||
|
if not os.path.exists(source):
|
||||||
|
error('{} does not exist! Please build \'binary\' before building apk'.format(source))
|
||||||
|
if not os.path.exists(target):
|
||||||
|
os.makedirs(target)
|
||||||
|
target = os.path.join(target, 'libbusybox.so')
|
||||||
|
print('cp: {} -> {}'.format(source, target))
|
||||||
|
shutil.copyfile(source, target)
|
||||||
|
|
||||||
|
for key in ['public.certificate.x509.pem', 'private.key.pk8']:
|
||||||
|
source = os.path.join('ziptools', key)
|
||||||
|
target = os.path.join('MagiskManager', 'app', 'src', 'main', 'assets', key)
|
||||||
|
print('cp: {} -> {}'.format(source, target))
|
||||||
|
shutil.copyfile(source, target)
|
||||||
|
|
||||||
|
for script in ['magisk_uninstaller.sh', 'util_functions.sh']:
|
||||||
|
source = os.path.join('scripts', script)
|
||||||
|
target = os.path.join('MagiskManager', 'app', 'src', 'main', 'assets', script)
|
||||||
|
print('cp: {} -> {}'.format(source, target))
|
||||||
|
with open(source, 'r') as file:
|
||||||
|
script_cont = file.read().replace('MAGISK_VERSION_STUB', '')
|
||||||
|
with open(target, 'w') as file:
|
||||||
|
file.write(script_cont)
|
||||||
|
|
||||||
|
print('')
|
||||||
|
|
||||||
os.chdir('MagiskManager')
|
os.chdir('MagiskManager')
|
||||||
if args.release:
|
if args.release:
|
||||||
if not os.path.exists(os.path.join('..', 'release_signature.jks')):
|
if not os.path.exists(os.path.join('..', 'release_signature.jks')):
|
||||||
@ -114,8 +143,8 @@ def sign_adjust_zip(unsigned, output):
|
|||||||
|
|
||||||
# Unsigned->signed
|
# Unsigned->signed
|
||||||
proc = subprocess.run(['java', '-jar', os.path.join('ziptools', 'signapk.jar'),
|
proc = subprocess.run(['java', '-jar', os.path.join('ziptools', 'signapk.jar'),
|
||||||
os.path.join('ziptools', 'test.certificate.x509.pem'),
|
os.path.join('ziptools', 'public.certificate.x509.pem'),
|
||||||
os.path.join('ziptools', 'test.key.pk8'), unsigned, 'tmp_signed.zip'])
|
os.path.join('ziptools', 'private.key.pk8'), unsigned, 'tmp_signed.zip'])
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
error('First sign flashable zip failed!')
|
error('First sign flashable zip failed!')
|
||||||
|
|
||||||
@ -132,8 +161,8 @@ def sign_adjust_zip(unsigned, output):
|
|||||||
|
|
||||||
# Adjusted -> output
|
# Adjusted -> output
|
||||||
proc = subprocess.run(['java', '-jar', os.path.join('ziptools', 'minsignapk.jar'),
|
proc = subprocess.run(['java', '-jar', os.path.join('ziptools', 'minsignapk.jar'),
|
||||||
os.path.join('ziptools', 'test.certificate.x509.pem'),
|
os.path.join('ziptools', 'public.certificate.x509.pem'),
|
||||||
os.path.join('ziptools', 'test.key.pk8'), 'tmp_adjusted.zip', output])
|
os.path.join('ziptools', 'private.key.pk8'), 'tmp_adjusted.zip', output])
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
error('Second sign flashable zip failed!')
|
error('Second sign flashable zip failed!')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user