Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-15 18:08:00 +01:00
parent d327c31227
commit 0b2aca0925
638 changed files with 76461 additions and 0 deletions

BIN
tools/bootctl Normal file

Binary file not shown.

32
tools/bootctl.patch Executable file
View file

@ -0,0 +1,32 @@
# How to build the bootctl bundled within the Magisk app:
#
# 1. Checkout and sync the AOSP tree:
# https://source.android.com/setup/build/downloading
# 2. Build for arm64:
# lunch aosp_arm64-eng
# 3. Apply patches:
# cd system/extras; patch -p1 < bootctl.patch
# 4. Build the executable:
# m bootctl
diff --git a/bootctl/Android.bp b/bootctl/Android.bp
index f63871cf..8a551bbe 100644
--- a/bootctl/Android.bp
+++ b/bootctl/Android.bp
@@ -26,11 +26,15 @@ cc_binary {
"-Werror",
],
- shared_libs: [
+ static_libs: [
"android.hardware.boot@1.0",
"android.hardware.boot@1.1",
"android.hardware.boot@1.2",
+ ],
+ shared_libs: [
"libhidlbase",
"libutils",
+ "libcutils",
+ "liblog",
],
}

1
tools/elf-cleaner/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

133
tools/elf-cleaner/Cargo.lock generated Normal file
View file

@ -0,0 +1,133 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "adler2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "anyhow"
version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crc32fast"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
dependencies = [
"cfg-if",
]
[[package]]
name = "elf-cleaner"
version = "0.0.0"
dependencies = [
"anyhow",
"object",
]
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "flate2"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "hashbrown"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
dependencies = [
"foldhash",
]
[[package]]
name = "indexmap"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "miniz_oxide"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5"
dependencies = [
"adler2",
]
[[package]]
name = "object"
version = "0.36.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
dependencies = [
"crc32fast",
"flate2",
"hashbrown",
"indexmap",
"memchr",
"ruzstd",
]
[[package]]
name = "ruzstd"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad02996bfc73da3e301efe90b1837be9ed8f4a462b6ed410aa35d00381de89f"
dependencies = [
"twox-hash",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "twox-hash"
version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
"cfg-if",
"static_assertions",
]

View file

@ -0,0 +1,13 @@
[package]
name = "elf-cleaner"
version = "0.0.0"
edition = "2024"
[dependencies]
object = { version = "0.36", features = ["build"] }
anyhow = "1.0"
[profile.release]
strip = true
lto = true
codegen-units = 1

View file

@ -0,0 +1,85 @@
use object::build::elf::{Builder, Dynamic, SectionData};
use object::elf;
use std::{env, fs};
// Implementation adapted from https://github.com/termux/termux-elf-cleaner
// Missing ELF constants
const DT_AARCH64_BTI_PLT: u32 = elf::DT_LOPROC + 1;
const DT_AARCH64_PAC_PLT: u32 = elf::DT_LOPROC + 3;
const DT_AARCH64_VARIANT_PCS: u32 = elf::DT_LOPROC + 5;
const SUPPORTED_DT_FLAGS: u32 = elf::DF_1_NOW | elf::DF_1_GLOBAL;
fn print_remove_dynamic(name: &str, path: &str) {
println!("Removing dynamic section entry {} in '{}'", name, path);
}
fn process_elf(path: &str) -> anyhow::Result<()> {
let bytes = fs::read(path)?;
let mut elf = Builder::read(bytes.as_slice())?;
let is_aarch64 = elf.header.e_machine == elf::EM_AARCH64;
elf.sections.iter_mut().for_each(|section| {
if let SectionData::Dynamic(entries) = &mut section.data {
// Remove unsupported entries
entries.retain(|e| {
let tag = e.tag();
match tag {
elf::DT_RPATH => {
print_remove_dynamic("DT_RPATH", path);
return false;
}
elf::DT_RUNPATH => {
print_remove_dynamic("DT_RUNPATH", path);
return false;
}
_ => {}
}
if is_aarch64 {
match tag {
DT_AARCH64_BTI_PLT => {
print_remove_dynamic("DT_AARCH64_BTI_PLT", path);
return false;
}
DT_AARCH64_PAC_PLT => {
print_remove_dynamic("DT_AARCH64_PAC_PLT", path);
return false;
}
DT_AARCH64_VARIANT_PCS => {
print_remove_dynamic("DT_AARCH64_VARIANT_PCS", path);
return false;
}
_ => {}
}
}
true
});
// Remove unsupported flags
for entry in entries.iter_mut() {
if let Dynamic::Integer { tag, val } = entry {
if *tag == elf::DT_FLAGS_1 {
let new_flags = *val & SUPPORTED_DT_FLAGS as u64;
if new_flags != *val {
println!(
"Replacing unsupported DT_FLAGS_1 {:#x} with {:#x} in '{}'",
*val, new_flags, path
);
*val = new_flags;
}
break;
}
}
}
}
});
let mut out_bytes = Vec::new();
elf.write(&mut out_bytes)?;
fs::write(path, &out_bytes)?;
Ok(())
}
fn main() -> anyhow::Result<()> {
env::args().skip(1).try_for_each(|s| process_elf(&s))
}

BIN
tools/futility Normal file

Binary file not shown.

BIN
tools/keys/kernel.keyblock Normal file

Binary file not shown.

Binary file not shown.

BIN
tools/keys/verity.pk8 Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIID/TCCAuWgAwIBAgIJAJcPmDkJqolJMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD
VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g
VmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UE
AwwHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
Fw0xNDExMDYxOTA3NDBaFw00MjAzMjQxOTA3NDBaMIGUMQswCQYDVQQGEwJVUzET
MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G
A1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UEAwwHQW5kcm9p
ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASIwDQYJKoZI
hvcNAQEBBQADggEPADCCAQoCggEBAOjreE0vTVSRenuzO9vnaWfk0eQzYab0gqpi
6xAzi6dmD+ugoEKJmbPiuE5Dwf21isZ9uhUUu0dQM46dK4ocKxMRrcnmGxydFn6o
fs3ODJMXOkv2gKXL/FdbEPdDbxzdu8z3yk+W67udM/fW7WbaQ3DO0knu+izKak/3
T41c5uoXmQ81UNtAzRGzGchNVXMmWuTGOkg6U+0I2Td7K8yvUMWhAWPPpKLtVH9r
AL5TzjYNR92izdKcz3AjRsI3CTjtpiVABGeX0TcjRSuZB7K9EK56HV+OFNS6I1NP
jdD7FIShyGlqqZdUOkAUZYanbpgeT5N7QL6uuqcGpoTOkalu6kkCAwEAAaNQME4w
HQYDVR0OBBYEFH5DM/m7oArf4O3peeKO0ZIEkrQPMB8GA1UdIwQYMBaAFH5DM/m7
oArf4O3peeKO0ZIEkrQPMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB
AHO3NSvDE5jFvMehGGtS8BnFYdFKRIglDMc4niWSzhzOVYRH4WajxdtBWc5fx0ix
NF/+hVKVhP6AIOQa+++sk+HIi7RvioPPbhjcsVlZe7cUEGrLSSveGouQyc+j0+m6
JF84kszIl5GGNMTnx0XRPO+g8t6h5LWfnVydgZfpGRRg+WHewk1U2HlvTjIceb0N
dcoJ8WKJAFWdcuE7VIm4w+vF/DYX/A2Oyzr2+QRhmYSv1cusgAeC1tvH4ap+J1Lg
UnOu5Kh/FqPLLSwNVQp4Bu7b9QFfqK8Moj84bj88NqRGZgDyqzuTrFxn6FW7dmyA
yttuAJAEAymk1mipd9+zp38=
-----END CERTIFICATE-----

1
tools/rustup-wrapper/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
target/

92
tools/rustup-wrapper/Cargo.lock generated Normal file
View file

@ -0,0 +1,92 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "home"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf"
dependencies = [
"windows-sys",
]
[[package]]
name = "rustup-wrapper"
version = "0.0.0"
dependencies = [
"home",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

View file

@ -0,0 +1,12 @@
[package]
name = "rustup-wrapper"
version = "0.0.0"
edition = "2024"
[dependencies]
home = "0.5"
[profile.release]
strip = true
lto = true
codegen-units = 1

View file

@ -0,0 +1,44 @@
use std::env;
use std::path::Path;
use std::process::{Command, Stdio};
use home::cargo_home;
/********************************
* Why do we need this wrapper?
********************************
*
* The command `rustup component list` does not work with custom toolchains:
* > error: toolchain 'magisk' does not support components
*
* However, this command is used by several IDEs to determine component
* availability, such as clippy, rustfmt etc.
* In this program, we use the output of the command with the nightly
* channel if any `component` command failed.
*/
fn main() -> std::io::Result<()> {
let exe = env::args().next().unwrap();
let exe = Path::new(&exe).file_name().unwrap().to_str().unwrap();
let real_exe = cargo_home()?.join("bin").join(exe);
let argv: Vec<String> = env::args().skip(1).collect();
if exe.starts_with("rustup") && argv.iter().any(|s| s == "component") {
let status = Command::new(&real_exe)
.args(&argv)
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()?;
if !status.success() {
let mut cmd = Command::new(&real_exe);
// Hardcode to use the nightly channel
cmd.arg("+nightly");
// Remove any explicit channel specification
cmd.args(argv.iter().filter(|s| !s.starts_with('+')));
return cmd.status().map(|_| ());
}
}
// Simply pass through
Command::new(&real_exe).args(argv.iter()).status().map(|_| ())
}