Skip to content

Commit

Permalink
release: bump KSU version, rename wrapper directory
Browse files Browse the repository at this point in the history
  • Loading branch information
seppzer0 authored Apr 12, 2024
1 parent eb2be89 commit 2006505
Show file tree
Hide file tree
Showing 67 changed files with 212 additions and 211 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUN python3 -m pip install pip --upgrade && \
# This significantly reduces the total build time, as each time we make a build call for a device,
# only device-specific kernel source is being downloaded into the container.
#
RUN python3 ${WDIR}/wrapper/utils/bridge.py --shared
RUN python3 ${WDIR}/builder/utils/bridge.py --shared

# launch app
CMD [ "/bin/bash" ]
87 changes: 44 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# zero_kernel

An advanced Android kernel builder with Kali NetHunter support.
An advanced Android kernel builder with assets collection and Kali NetHunter support.

## Contents

- [zero\_kernel](#zero_kernel)
- [Contents](#contents)
- [**Important**](#important)
- [**Important to Read**](#important-to-read)
- [Description](#description)
- [Kernel Features](#kernel-features)
- [Supported Devices \& ROMs](#supported-devices--roms)
Expand All @@ -19,10 +19,10 @@ An advanced Android kernel builder with Kali NetHunter support.
- [See also](#see-also)
- [Credits](#credits)

## **Important**
## **Important to Read**

> [!IMPORTANT]
> **\- Disclaimer \-**
> **\- DISCLAIMER \-**
>
> **This kernel is made for educational purposes only.**
>
Expand All @@ -33,15 +33,15 @@ An advanced Android kernel builder with Kali NetHunter support.
> [!NOTE]
> \- ROM artifacts in releases \-
>
> The contents of each release include ROM builds compatible with corresponding kernel builds. These ROM files are <u>**unmodified and mirrored from official sources**</u>.
> The contents of each release include ROM builds compatible with corresponding kernel builds. These ROM files are **unmodified and mirrored from official sources**.
>
>This can be verified via the checksums, which should be identical to the ones presented on the ROM project's official web page.
>
>You can always download the same ROM file from official sources if you'd like. The mirroring in this repository is only done due to the fact that some ROM projects remove their older builds once they become too outdated.
## Description

The codebase of this project is essentially an extensive wrapper automating the entire Android kernel build process, starting from kernel source collection and ending with artifact packaging.
The codebase of this project is an extensive build wrapper automating the entire Android kernel build process, starting from kernel source collection and ending with artifact packaging.

The key goal is to modify the kernel in such a way that enables unique features of [Kali NetHunter](https://www.kali.org/docs/nethunter) — a ROM layer designed to add extended functionality for penetration testing in a mobile form factor.

Expand All @@ -61,40 +61,41 @@ The kernel has the following features:
<details>
<summary>OnePlus 5/T</summary>

<br>
- 4.4 Linux kernel version:
- LineageOS;
- ParanoidAndroid;
- x_kernel supported (universal)`*`.

4.4 Linux kernel version:
- 4.14 Linux kernel version:
- ParanoidAndroid (unofficial & testing);
- x-ft_kernel supported (universal)`**`.

- LineageOS;
- ParanoidAndroid;
- x_kernel supported (universal)*.
`*` -- this is mostly relevant to ROMs based on LineageOS; however, technically speaking, this includes ParanoidAndroid as well, which makes x_kernel-based builds universal.

4.14 Linux kernel version:

- ParanoidAndroid (unofficial & testing);
- x-ft_kernel supported (universal)**.

---

\* -- this is mostly relevant to ROMs based on LineageOS; however, technically speaking, this includes ParanoidAndroid as well, which makes x_kernel-based builds universal.

\** -- this, **in theory**, is relevant to all 4.14-based ROMs for this device in existence.
`**` -- this, **in theory**, is relevant to all 4.14-based ROMs for this device in existence.

</details>

## Usage

The custom build wrapper consists of 3 main components:
The custom build wrapper (aka "builder") consists of 2 core components and 3 primary commands:

Components:

- kernel builder;
- assets collector;
- kernel + assets bundler.
- assets collector.

Commands:

- kernel;
- assets;
- bundle.

```help
$ python3 wrapper --help
usage: wrapper [-h] [--clean] {kernel,assets,bundle} ...
$ python3 builder --help
usage: builder [-h] [--clean] {kernel,assets,bundle} ...
A custom wrapper for the zero_kernel.
A custom builder for the zero_kernel.
positional arguments:
{kernel,assets,bundle}
Expand All @@ -112,7 +113,7 @@ optional arguments:
**It is highly recommended to use `docker` option to run this tool.** For that you need Docker Engine or Docker Desktop, depending on your OS.

> [!WARNING]
> Because of how *specific* Linux kernel source is, building it on Windows even with Docker might be challenging.
> Because of how *specific* Linux kernel source is, building it on Windows even with Docker (using WSL2 back-end) might be [challenging](https://stackoverflow.com/questions/76754956/how-to-clone-the-linux-kernel-repository-to-my-machine-i-keep-geting-errors).
To run this tool in a `local` environment, you will need:

Expand All @@ -122,18 +123,18 @@ To run this tool in a `local` environment, you will need:
You will also need to configure your Python installation, including some of the packages installation:

```sh
export PYTHONPATH=$(pwd)
python3 -m pip install poetry
python3 -m poetry install --no-root
export PYTHONPATH=$(pwd)
```

### Kernel

Kernel build process can be launched using the `kernel` subcommand of the wrapper.
Kernel build process can be launched using the `kernel` subcommand.

```help
$ python3 wrapper kernel --help
usage: wrapper kernel [-h] --build-env {local,docker,podman} --base
$ python3 builder kernel --help
usage: builder kernel [-h] --build-env {local,docker,podman} --base
{los,pa,x,aosp} --codename CODENAME --lkv LKV [-c]
[--clean-image] [--log-level {normal,verbose,quiet}]
[-o OUTLOG] [--ksu]
Expand Down Expand Up @@ -162,8 +163,8 @@ options:
As mentioned, there is also an asset downloader, which can collect latest versions of ROM, TWRP, Magisk and it's modules, Kali Chroot etc.

```help
$ python3 wrapper assets --help
usage: wrapper assets [-h] --build-env {local,docker,podman} --base
$ python3 builder assets --help
usage: builder assets [-h] --build-env {local,docker,podman} --base
{los,pa,x,aosp} --codename CODENAME --chroot
{full,minimal} [--rom-only] [--clean-image] [--clean]
[--log-level {normal,verbose,quiet}] [-o OUTLOG] [--ksu]
Expand All @@ -190,11 +191,11 @@ options:

### Bundle

There is an option named `bundle` which combines build artifacts of both `kernel` and `assets` commands into a single package.
The `bundle` command is a combined usage of kernel builder and assets collector core modules.

This is especially useful for linking the kernel version with the appropriate ROM version.
This is especially useful for linking the kernel build with the appropriate ROM build.

There are cases when an old kernel version is used with the newer ROM version (adapted for the *newer* version of kernel). Such cases can ultimately lead to your system working improperly or breaking down completely, which is why it is important to use a specific kernel build with a corresponding ROM build.
There are cases when an old kernel build is used with the newer ROM build. Such cases can ultimately lead to your system working improperly or breaking down completely, which is why it is important to use a *specific* kernel build with a corresponding ROM build.

Currently, there are three types of packaging available:

Expand All @@ -204,11 +205,11 @@ Currently, there are three types of packaging available:

Options `full` and `conan` collect all of the assets required to successfuly flash the kernel onto your device. The difference between the two is that `full` option places everything into a local directory, while `conan` organizes everything as a Conan package.

An option named `slim` is a much lighter version of `full` packaging, as only the ROM is collected from the asset list. This is done to reduce package sizes while ensuring the kernel+ROM compatibility.
Option named `slim` is a much lighter version of `full` packaging, as only the ROM is collected from the asset list. This is done to reduce package sizes while ensuring the kernel+ROM compatibility.

```help
$ python3 wrapper bundle --help
usage: wrapper bundle [-h] --build-env {local,docker,podman} --base
$ python3 builder bundle --help
usage: builder bundle [-h] --build-env {local,docker,podman} --base
{los,pa,x,aosp} --codename CODENAME --lkv LKV
--package-type {conan,slim,full} [--conan-upload]
[--clean-image] [--log-level {normal,verbose,quiet}]
Expand Down Expand Up @@ -241,19 +242,19 @@ Here are some examples of commands:
**(Recommended)** Build kernel and collect ROM via Docker:

```sh
python3 wrapper bundle --build-env=docker --base=los --codename=dumpling --lkv=4.4 --package-type=slim
python3 builder bundle --build-env=docker --base=los --codename=dumpling --lkv=4.4 --package-type=slim
```

Build kernel locally:

```sh
python3 wrapper kernel --build-env=local --base=los --codename=dumpling --lkv=4.4
python3 builder kernel --build-env=local --base=los --codename=dumpling --lkv=4.4
```

Collect all of the assets locally:

```sh
python3 wrapper assets --build-env=local --base=los --codename=dumpling --package-type=full
python3 builder assets --build-env=local --base=los --codename=dumpling --package-type=full
```

## See also
Expand Down
12 changes: 6 additions & 6 deletions wrapper/__main__.py → builder/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import json
import argparse

from wrapper.tools import cleaning as cm, messages as msg
from wrapper.configs import ArgumentConfig, DirectoryConfig as dcfg
from wrapper.engines import DockerEngine, PodmanEngine
from wrapper.commands import KernelCommand, AssetsCommand, BundleCommand
from builder.tools import cleaning as cm, messages as msg
from builder.configs import ArgumentConfig, DirectoryConfig as dcfg
from builder.engines import DockerEngine, PodmanEngine
from builder.commands import KernelCommand, AssetsCommand, BundleCommand

def parse_args() -> argparse.Namespace:
"""Parse the script arguments."""
# show the 'help' message if no arguments supplied
args = None if sys.argv[1:] else ["-h"]
# parser and subparsers
parser_parent = argparse.ArgumentParser(description="A custom wrapper for the zero kernel.")
parser_parent = argparse.ArgumentParser(description="A custom builder for the zero kernel.")
subparsers = parser_parent.add_subparsers(dest="command")
parser_kernel = subparsers.add_parser("kernel", help="build the kernel")
parser_assets = subparsers.add_parser("assets", help="collect assets")
Expand Down Expand Up @@ -226,7 +226,7 @@ def main(args: argparse.Namespace) -> None:
sys.exit(0)
os.environ["LOGLEVEL"] = args.loglvl
# define env variable with kernel version
with open(dcfg.root / "pyproject.toml") as f:
with open(dcfg.root / "pyproject.toml", encoding="utf-8") as f:
os.environ["KVERSION"] = f.read().split("version = \"")[1].split("\"")[0]
# create a config for argument check and storage
arguments = vars(args)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions wrapper/clients/github.py → builder/clients/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Optional
from pydantic import BaseModel

from wrapper.tools import cleaning as cm, commands as ccmd, messages as msg
from wrapper.configs import DirectoryConfig as dcfg
from builder.tools import cleaning as cm, commands as ccmd, messages as msg
from builder.configs import DirectoryConfig as dcfg


class GitHubApi(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion wrapper/clients/los.py → builder/clients/los.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wrapper.clients.rom_api import RomApi
from builder.clients.rom_api import RomApi


class LineageOsApi(RomApi):
Expand Down
2 changes: 1 addition & 1 deletion wrapper/clients/pa.py → builder/clients/pa.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import override

from wrapper.clients.rom_api import RomApi
from builder.clients.rom_api import RomApi


class ParanoidAndroidApi(RomApi):
Expand Down
4 changes: 2 additions & 2 deletions wrapper/clients/rom_api.py → builder/clients/rom_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import requests
from pydantic import BaseModel

from wrapper.tools import messages as msg
from wrapper.interfaces import IRomApi
from builder.tools import messages as msg
from builder.interfaces import IRomApi


class RomApi(BaseModel, IRomApi):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion wrapper/commands/assets.py → builder/commands/assets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wrapper.core import AssetsCollector
from builder.core import AssetsCollector


class AssetsCommand(AssetsCollector):
Expand Down
10 changes: 5 additions & 5 deletions wrapper/commands/bundle.py → builder/commands/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import itertools
from pydantic import BaseModel

from wrapper.core import KernelBuilder, AssetsCollector
from wrapper.tools import cleaning as cm, commands as ccmd, fileoperations as fo, messages as msg
from wrapper.configs import DirectoryConfig as dcfg
from wrapper.interfaces import IBundleCommand
from builder.core import KernelBuilder, AssetsCollector
from builder.tools import cleaning as cm, commands as ccmd, fileoperations as fo, messages as msg
from builder.configs import DirectoryConfig as dcfg
from builder.interfaces import IBundleCommand


class BundleCommand(BaseModel, IBundleCommand):
Expand Down Expand Up @@ -72,7 +72,7 @@ def _conan_sources(self) -> None:

@staticmethod
def _conan_options(json_file: str) -> dict:
with open(json_file) as f:
with open(json_file, encoding="utf-8") as f:
json_data = json.load(f)
return json_data

Expand Down
2 changes: 1 addition & 1 deletion wrapper/commands/kernel.py → builder/commands/kernel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wrapper.core import KernelBuilder
from builder.core import KernelBuilder


class KernelCommand(KernelBuilder):
Expand Down
2 changes: 2 additions & 0 deletions builder/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .arguments import ArgumentConfig
from .directories import DirectoryConfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from typing import Optional
from pydantic import BaseModel

from wrapper.tools import commands as ccmd, messages as msg
from builder.tools import commands as ccmd, messages as msg


class ArgumentConfig(BaseModel):
"""A variable storage to use across the application.
:param benv: Build environment.
:param command: Wrapper command to be launched.
:param command: Builder command to be launched.
:param codename: Device codename.
:param base: Kernel source base.
:param lkv: Linux kernel version.
Expand Down Expand Up @@ -52,7 +52,7 @@ def check_settings(self) -> None:
except Exception:
msg.error("Detected Linux distribution is not Debian-based.")
# check if specified device is supported
with open(Path(__file__).absolute().parents[2] / "wrapper" / "manifests" / "devices.json") as f:
with open(Path(__file__).absolute().parents[2] / "builder" / "manifests" / "devices.json", encoding="utf-8") as f:
devices = json.load(f)
if self.codename not in devices.keys():
msg.error("Unsupported device codename specified.")
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
from pydantic import BaseModel

from wrapper.tools import cleaning as cm, fileoperations as fo, messages as msg
from wrapper.clients import GitHubApi, LineageOsApi, ParanoidAndroidApi
from wrapper.configs import DirectoryConfig as dcfg
from wrapper.interfaces import IAssetsCollector
from builder.tools import cleaning as cm, fileoperations as fo, messages as msg
from builder.clients import GitHubApi, LineageOsApi, ParanoidAndroidApi
from builder.configs import DirectoryConfig as dcfg
from builder.interfaces import IAssetsCollector


class AssetsCollector(BaseModel, IAssetsCollector):
Expand Down
Loading

0 comments on commit 2006505

Please sign in to comment.