{"id":15997113,"url":"https://github.com/PinNaCode/magiskboot_build","last_synced_at":"2025-10-21T05:30:20.996Z","repository":{"id":133612882,"uuid":"611162624","full_name":"PinNaCode/magiskboot_build","owner":"PinNaCode","description":"unofficial magiskboot build system (and port) targeting multi-platform (does not require NDK)","archived":true,"fork":false,"pushed_at":"2024-07-14T03:10:08.000Z","size":487,"stargazers_count":155,"open_issues_count":8,"forks_count":27,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-31T20:10:46.764Z","etag":null,"topics":["android","cygwin","emscripten","linux","macos","mingw","termux","wasm","web","windows"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PinNaCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-08T08:49:51.000Z","updated_at":"2024-12-29T15:25:24.000Z","dependencies_parsed_at":"2023-12-16T04:58:23.973Z","dependency_job_id":"785af97b-4f60-4c3a-b991-d5d0b86d3670","html_url":"https://github.com/PinNaCode/magiskboot_build","commit_stats":null,"previous_names":["wearcode/magiskboot_build","pinnacode/magiskboot_build","ookiineko/magiskboot_build"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PinNaCode%2Fmagiskboot_build","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PinNaCode%2Fmagiskboot_build/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PinNaCode%2Fmagiskboot_build/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PinNaCode%2Fmagiskboot_build/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PinNaCode","download_url":"https://codeload.github.com/PinNaCode/magiskboot_build/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237436552,"owners_count":19309930,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cygwin","emscripten","linux","macos","mingw","termux","wasm","web","windows"],"created_at":"2024-10-08T08:01:25.609Z","updated_at":"2025-10-21T05:30:15.629Z","avatar_url":"https://github.com/PinNaCode.png","language":"C","readme":"## magiskboot_build\n\n![Magisk Version Badge](https://img.shields.io/badge/Magisk%20version-v27.0%20Canary%20(27002)-green?logo=magisk)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ookiineko/magiskboot_build/ci.yaml?logo=githubactions\u0026logoColor=orange\u0026label=CI%20build)\n![Last Upstream Sync Date](https://img.shields.io/github/gist/last-commit/cc0e3019a9107116d12df1e94e4a5c79?logo=git\u0026label=Last%20upstream%20sync\u0026color=blue)\n\na simple portable CMake-based build system for magiskboot\n\n### Requirements\n\nmagiskboot itself depends on the following libraries:\n\n1. [LZMA][LZMA]\n2. [LZ4][LZ4]\n3. [bzip2][bzip]\n4. [zlib][zlib]\n\nfor build-time dependencies:\n\n1. [pkg-config][pkg-config]\n2. [Clang][Clang] (maybe also others, but GCC doesn't work, see [this part](#your-compiler-is-not-capable-of-building-magiskboot))\n3. [Rust][Rust] (stable channel is OK... spoiler: `RUSTC_BOOTSTRAP` HACK is used)\n4. [CMake][CMake]\n5. [Libc++][Libcxx] (optional, see [this part](#can-i-build-without-libcxx))\n\nplease make sure you have installed the above softwares before building\n\nhere are examples for some supported popular operating systems/distributions:\n\n\u003cdetails\u003e\u003csummary\u003eAndroid\u003c/summary\u003e\n\n#### Android\n\nPlease check the instructions for [Cross compiling](#cross-compiling) first.\n\nDownload [ONDK][ONDK], set environment variable `ANDROID_NDK_HOME` to the extracted directory, and use [vcpkg][vcpkg] to install the dependencies.\n\nUse `/path/to/your/ondk/build/cmake/android.toolchain.cmake` as the toolchain file for vcpkg.\n\nThen, set the CMake variable `ANDROID_PLATFORM` to the desired API level, and `ANDROID_ABI` to the desired archiecture,\n\nfor more details about these variables, please refer to the [NDK documentation](https://developer.android.com/ndk/guides/cmake#variables).\n\nMake sure to enable source build for the Rust standard library (STD), then activate the Rust toolchain by append it to your current `PATH`:\n\n````shell\nexport PATH=/path/to/your/ondk/toolchains/rust/bin:$PATH\n````\n\n#### Termux\n\n\u003e **Note**\n\u003e\n\u003e Termux build is not actively tested by CI, but it might work without problem.\n\u003e\n\u003e If you find the build is broken, please file a [bug report](../../issues).\n\n````shell\napt update\napt upgrade  # upgrade all existing packages (optional)\napt install build-essential liblzma liblz4 libbz2 zlib pkg-config \\\n            clang rust cmake ninja\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eLinux\u003c/summary\u003e\n\n#### Ubuntu 22.04 (jammy)\n\n````shell\nsudo apt update\nsudo apt upgrade  # upgrade all existing packages (optional)\n\n# replace clang-15, libc++-15-dev, libc++abi-15-dev with\n# appropriate version according to your Ubuntu release\nsudo apt install build-essential lzma-dev liblzma-dev liblz4-dev libbz2-dev \\\n                 zlib1g-dev pkg-config clang-15 libc++-15-dev libc++abi-15-dev cmake \\\n                 ninja-build rustc cargo\n````\n\nWhen configuring, set `CC` and `CXX` to correct values, for example: `clang-15` and `clang++-15`.\n\n#### Alpine Linux (edge)\n\n````shell\nsudo apk update\nsudo apk upgrade  # upgrade all existing packages (recommended)\nsudo apk add build-base linux-headers xz-dev lz4-dev bzip2-dev \\\n             zlib-dev pkgconf clang libc++-dev cmake \\\n             samurai rust cargo\n````\n\n#### archlinux\n\n````shell\nsudo pacman -S --needed base-devel xz lz4 bzip2 zlib pkgconf \\\n                        clang libc++ cmake ninja rust\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003emacOS\u003c/summary\u003e\n\n#### macOS Monterey (or higher verison)\n\ninstall [Homebrew][Homebrew] first\n\n````shell\nbrew update\nbrew upgrade  # upgrade all existing packages (optional)\nbrew install xz lz4 pkg-config cmake ninja rust\n````\n\nTheoretically you can build for older macOS version as well, but Homebrew only support the last three OS releases of macOS, so you will need to install the depended packages using other ways (maybe using MacPorts or sth?)\n\n#### LTO configuration\n\nTo use [LTO](#lto) (optional), also install the `llvm` package, and add it to your current `PATH`:\n\n````shell\nexport PATH=\"$(brew --prefix)/opt/llvm/bin:$PATH\" CC=clang CXX=clang++\n````\n\nand pass `-DCMAKE_AR=llvm-ar -DCMAKE_RANLIB=llvm-ranlib` to CMake when configuring.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eWindows\u003c/summary\u003e\n\n#### Windows (MinGW)\n\nInstall [MSYS2][MSYS2] first, and change the setting of `mintty.exe` to grant it with administrator privileges (needed for using native symlinks in some conditions).\n\n\u003e **Warning**\n\u003e\n\u003e LLD from MINGW/UCRT environments currently has a bug that produces bad executables, so if you want to use LTO, please build under CLANG environments.\n\u003e\n\u003e For more details on differences between these environments, you can refer to the [MSYS2 documentation](https://www.msys2.org/docs/environments/).\n\ndon't forget to set this environtment variable to allow symlinks to work properly: `export MSYS=winsymlinks:native` (required for the build I guess)\n\n````shell\npacman -Syu  # upgrade all existing packages (optional, you may need to do this for multiple times)\npacman -S --needed base-devel pactoys\npacboy -S --needed {xz,lz4,bzip2,zlib,pkgconf,clang,cmake,libc++,ninja,rust}:p\n````\n\n##### Cross builds\n\nIf you are cross-compiling from a non-Windows host and using vcpkg to manage the dependencies, please make sure CMake variable `MINGW` is set to `TRUE` during configuring.\n\n#### Cygwin (Experimental)\n\n\u003e **Warning**\n\u003e\n\u003e Cygwin support is experimental, you may run into problems.\n\n\u003e **Note**\n\u003e\n\u003e You can get a prebuilt binary at [GitHub releases](../../releases/tag/cygwin-test).\n\nTo build for Cygwin, you need to compile a Rust toolchain from source, for more info: [Cygwin Rust porting](https://gist.github.com/ookiineko/057eb3a91825313caeaf6d793a33b0b2)\n\nCurrently Cygwin Rust has no host tools support, so cross compiling is needed, make sure to read the instructions for [Cross compiling](#cross-compiling).\n\nThe cross compiler is available on Fedora Linux, provided by the [Fedora Cygwin][fedora-cygwin], alternatively, you can also try [arch-cygwin](https://github.com/ookiineko/arch-cygwin).\n\nWhen configuring, use `cygwin64-cmake` (`x86_64-pc-cygwin-cmake` on arch-cygwin) instead of `cmake`, but don't use it for `cmake --build` and other CMake commands.\n\nFor Fedora Cygwin, you need to build the LLVM \u0026 Clang yourself, a patched [LLVM 15 source](https://github.com/ookiineko-cygport/llvm-project) is there. To use the patched Clang in Fedora Cygwin, set both `CMAKE_C_COMPILER_TARGET` and `CMAKE_CXX_COMPILER_TARGET` to `x86_64-unknown-windows-cygnus` and `CMAKE_SYSROOT` to `/usr/x86_64-pc-cygwin/sys-root` when configuring.\n\nOn Fedora Cygwin, there is another issue that `cygwin64-cmake` overrides C and C++ compilers to GCC, this is not supported by Magisk, and somehow ignoring the `CC` and `CXX` variables we are settings. To workaround this, set `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER` manually to the path of the previous Cygwin cross Clang and Clang++.\n\nOn arch-cygwin, set `CYGWIN_CC` and `CYGWIN_CXX` to `x86_64-pc-cygwin-clang` and `x86_64-pc-cygwin-clang++`.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eWebAssembly\u003c/summary\u003e\n\n#### Emscripten\n\n\u003e **Note**\n\u003e\n\u003e Currently this port only support running with NodeJS.\n\u003e\n\u003e A web frontend wrapper must be written to handle the argument passing and file system management in browsers.\n\u003e\n\u003e This should be implemented soon in the future ([#19](../../issues/19)), but unfortunately I am not a web developer, any help on this will be welcome QwQ\n\nPlease read the [Cross compiling](#cross-compiling) instructions first.\n\nInstall the [Emscripten][Emscripten] SDK and also a Rust compiler with Emscripten target (probably via [rustup][rustup]).\n\n\u003e **Warning**\n\u003e\n\u003e emsdk version 3.1.37 is recommended, you might run into weird problems with other versions.\n\nUse [vcpkg][vcpkg] to install the [depended libraries](#requirements), the triplet is called `wasm32-emscripten`.\n\nWhen configuring, use `emcmake cmake` instead of `cmake` (but don't use it for `cmake --build` and other CMake commands) , and use `/path/to/your/emsdk/emscripten/cmake/Modules/Platform/Emscripten.cmake` as the toolchain file for vcpkg.\n\nFor NodeJS, make sure to set `CMAKE_EXE_LINKER_FLAGS` to `-sNODERAWFS` to allow using the host filesystem.\n\nfinally, you can run the result with [NodeJS][NodeJS] using: `node magiskboot.js`\n\n\u003c/details\u003e\n\n### Usage\n\nPlease refer to [Magisk documentation](https://topjohnwu.github.io/Magisk/tools.html#magiskboot).\n\n### Download\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e The official magiskboot only supports running on Android and Linux,\n\u003e\n\u003e If you find something that works on the officially supported platforms,\n\u003e but not on the extra platforms supported by magiskboot_build, then that\n\u003e is a magiskboot_build-specific bug.\n\u003e\n\u003e Please, do ***NOT*** report magiskboot_build bugs to the upstream Magisk!\n\nFor prebuilt binaries, go check [GitHub Releases](../../releases/latest) for selected CI builds.\n\n### Build \u0026 Install\n\nFirst get and extract the latest source tarball (called `magiskboot_\u003cCOMMIT_ID\u003e_\u003cVERCODE\u003e-src.tar.xz`) from [Github Releases](../../releases/latest).\n\nOr clone this repository using Git, note that cloning with `--recurse-submodules` is not recommended, and you should run `scripts/clone_submodules.sh` after clone because it skips the submodules that is not necessary for building magiskboot.\n\n````shell\nCC=clang CXX=clang++ cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release  # configure\ncmake --build build -j $(nproc)  # build\n./build/magiskboot  # running\n# install to system (may need sudo, to specify different install dir, set the `DESTDIR' environment variable)\ncmake --install build\n````\n\nTo produce a statically linked binary (optional), pass `-DPREFER_STATIC_LINKING=ON` to CMake while configuring, make sure you have the static version of the [depended libraries](#requirements), otherwise you'll run into configure or link errors.\n\n#### Rust\n\nYou can specify extra arguments passed to Cargo by setting CMake variable `CARGO_FLAGS` while configuring, you can also provide an initial value of environment `RUSTFLAGS` by setting the corresponding CMake variable.\n\nNote: these variables are using [CMake's list syntax](https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#cmake-language-lists), not string. that is, replace all your spaces with `;`, e.g. `-DCARGO_FLAGS=\"-Z;no-index-update\"` instead of `-DCARGO_FLAGS=\"-Z no-index-update\"`\n\n#### Cross compiling\n\nFirst get a cross-compiler and likely also a Clang from somewhere (usually your distribution's package manager). If you don't have Libc++ installed for your crossed target, you could probably also try to link against [Libstdc++][Libstdcxx] instead, see [this part](#can-i-build-without-libcxx).\n\nInstall Rust using [rustup][rustup] and add your cross target like this: `rustup target add aarch64-unknown-linux-gnu` (replace `aarch64-unknown-linux-gnu` with the Rust target of your target platform).\n\nIf the cross Rust target can't be installed using [rustup][rustup], you can still compile if you build the Rust standard library (STD) from source, to do this, pass `-DRUST_BUILD_STD=ON` during configuration (Note this will require Nightly Rust and the STD source code to be installed on your system).\n\nTo cross-compile, you may need a [CMake toolchain file][cmake-toolchains] describing your target specs (for example the sysroot location, and target triplet for using Clang), the location of the cross compiler toolchain and strategy for CMake to seek for the depended libraries.\n\nYou can install the depended libraries for your cross target by using [vcpkg][vcpkg], for example:\n\n````shell\nvcpkg install --host-triplet=arm64-linux bzip2 lz4 zlib liblzma\n````\n\n`arm64-linux` is the triplet of your cross target, pass this value to CMake using the `VCPKG_TARGET_TRIPLET` variable during configuration.\n\nSet variable `Rust_CARGO_TARGET` to the Rust target you wanted to cross compile for, e.g. `aarch64-unknown-linux-gnu` (You can find them in [rustc documentation](https://doc.rust-lang.org/rustc/platform-support.html)).\n\nTo integrate vcpkg with CMake, pass `-DCMAKE_TOOLCHAIN_FILE=/path/to/your/vcpkg/scripts/buildsystems/vcpkg.cmake` to CMake, to use your toolchain file with vcpkg, set the variable `VCPKG_CHAINLOAD_TOOLCHAIN_FILE` to the path of your actual toolchain file.\n\n#### LTO\n\nSet `LDFLAGS` to `\" -flto\"` before calling CMake.\n\nIf you want to perform LTO for the Rust part at final link time, pass `-DFULL_RUST_LTO=ON` to CMake during configuring. (And you will need to install [LLD][LLD]. Note: you may need to make sure your LLVM and LLD are sharing the same LLVM version with Rust.)\n\n### Testing\n\n\u003e [!NOTE]\n\u003e Features not tested by CI doesn't necessarily mean it can't work.\n\nA very basic shell script is provided under the [`scripts`](scripts/magiskboot_test.sh) directory, currently the following functions are automatically tested with Github CI:\n\n- [x] unpack* (currently not all header versions and variants are tested)\n- [x] repack* (same as above)\n- [ ] verify\n- [ ] sign\n- [ ] extract\n- [x] hexpatch\n\n* cpio* (currently not widely tested on all common ramdisks)\n  - [ ] cpio exists\n  - [x] cpio ls\n  - [ ] cpio rm\n  - [ ] cpio mkdir\n  - [ ] cpio ln\n  - [ ] cpio mv\n  - [x] cpio add\n  - [x] cpio extract\n  - [ ] cpio test\n  - [ ] cpio patch\n  - [ ] cpio backup\n  - [ ] cpio restore\n\n* dtb\n  - [ ] dtb print\n  - [x] dtb test\n  - [ ] dtb patch\n\n- [ ] split\n- [x] sha1\n- [ ] cleanup\n- [x] compress\n- [x] decompress\n\n### Generating source tarball\n\n\u003e [!NOTE]\n\u003e\n\u003e You may not be able to generate source tarball on Windows/Cygwin due to issues with symlinks.\n\n````shell\n# configure for only packaging source\nCC=true cmake -G Ninja -B build \\\n    -DCMAKE_C_COMPILER_WORKS=YES -DWITHOUT_BUILD=ON\ncmake --build build -t package_source  # make a source package\n````\n\nMake sure to pass the above flags to CMake while configuring, which will allow creating source tarball without installing the [build dependencies](#requirements).\n\nyou should be able to find your source package under the `build` folder\n\n### FAQ\n\n#### Something isn't working\n\nPlease use debug builds and paste your information (like crash or error logs) in a new [Issue](../../issues).\n\n#### Can I build without Libcxx?\n\nIf you need to build with [Libstdc++][Libstdcxx] instead of [Libc++][Libcxx], pass `-DWITH_LIBCXX=OFF` to CMake during configuring, also apply [this patch](patches-contrib/Magisk/0029-workaround-support-building-with-libstdcxx.patch).\n\n#### \"Your compiler is not capable of building magiskboot\"\n\nMake sure you are using Clang to build. GCC doesn't work because of: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36566\n\n#### Is this thing using the latest Magisk source?\n\nCheck the version status badges at [the top of README](#magiskboot_build).\n\nThis project is very similiar to [android-tools][android-tools] which just maintains a set of patches on top of a specific upstream Magisk commit and require manual adaption for compiling with newer source.\n\nAlthough I may update the version once in a while, [Pull requests](../../pulls) are welcome.\n\n#### Can you add ... platform support?\n\nThis project aims to be portable, it should be possible to port it to new platforms with some efforts, as long as your platform meets the the above [requirements](#requirements).\n\nFeel free to add an [Issue](../../issues) about support on your new platform.\n\n### Development\n\n#### Clean builds\n\nTo quickly discard the current `build` directory and dirty vendored submodule (`src/`) changes, please run `make clean`.\n\n#### Vendor projects patching\n\nIf you are building directly from the Git source tree, all the patches under the `patches/` directory will be automatically applied on the first configure. After that a flag file called `.mbb_patched` is created under your build directory (i.e. `build/`).\n\nRemoving the flag file and re-configure will discard any dirty changes in vendored projects, and re-apply all the patches to them again.\n\nTo avoid applying any patch at configure time, create the flag file manually before calling CMake. Note that in this case this project might not build on anything other than Android.\n\n### License\n\nPatches and stub codes created by this project (not borrowed from other places) are licensed under Apache 2.0 or GNU General Public License (GPL) v3 at your option,\n\nAll parts of the code borrowed from other projects are licensed under their corresponding license.\n\nHowever, please note that when combining them are a whole and to distribute the magiskboot binary, all sources have to be licensed under GPL v3.\n\nFor more details about these licenses, please see [LICENSE](LICENSE) and [LICENSE.magiskboot](LICENSE.magiskboot).\n\n### Special thanks to\n\n- [android-tools][android-tools] developers for many code and inspiration of this repository\n- [Magisk][Magisk] developers for the magiskboot utility\n- all other used projects' developers (mentioned in the [Requirements](#requirements) section)\n\n[pkg-config]: https://www.freedesktop.org/wiki/Software/pkg-config/\n[LZMA]: https://tukaani.org/lzma/\n[LZ4]: https://lz4.github.io/lz4/\n[bzip]: http://www.bzip.org/\n[zlib]: https://zlib.net/\n[Clang]: https://clang.llvm.org/\n[LLD]: https://lld.llvm.org/\n[Rust]: https://www.rust-lang.org/\n[CMake]: https://cmake.org/\n[Magisk]: https://github.com/topjohnwu/Magisk.git\n[android-tools]: https://github.com/nmeum/android-tools\n[rustup]: https://rustup.rs/\n[Homebrew]: https://brew.sh/\n[Libcxx]: https://libcxx.llvm.org/\n[Libstdcxx]: https://gcc.gnu.org/onlinedocs/libstdc++/\n[MSYS2]: https://www.msys2.org/\n[fedora-cygwin]: https://copr.fedorainfracloud.org/coprs/yselkowitz/cygwin/\n[cmake-toolchains]: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html\n[vcpkg]: https://vcpkg.io/\n[Emscripten]: https://github.com/emscripten-core/emsdk\n[NodeJS]: https://nodejs.org/\n[ONDK]: https://github.com/topjohnwu/ondk\n","funding_links":[],"categories":["C","android"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPinNaCode%2Fmagiskboot_build","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPinNaCode%2Fmagiskboot_build","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPinNaCode%2Fmagiskboot_build/lists"}