Skip to content

Commit

Permalink
release: add 4.14 kernel build support
Browse files Browse the repository at this point in the history
  • Loading branch information
seppzer0 committed Dec 2, 2023
1 parent 6c6112b commit 0137025
Show file tree
Hide file tree
Showing 17 changed files with 375 additions and 282 deletions.
16 changes: 7 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ job-build:
services:
- docker:dind
script:
- export DOCKER_HOST=tcp://docker:2375/
- apk update && apk add python3 py3-pip
- python3 -m pip install poetry
- python3 -m poetry config virtualenvs.create false
Expand All @@ -26,21 +25,20 @@ job-build:
when: on_success
expire_in: never
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- when: manual

job-tag:
stage: tag
needs:
- job-build
script:
- USERNAME=$CUSTOM_CI_USERNAME
- PASSWD=$CUSTOM_CI_PASSWD
- TAGNAME=$(python3 scripts/get_version.py)
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- PASSWORD=$CUSTOM_CI_PASSWORD
- EMAIL=$CUSTOM_CI_EMAIL
- TAGNAME=v$(sh scripts/get_version.sh)
- git config --global user.name "${USERNAME}"
- git config --global user.email "${EMAIL}"
- git remote remove origin
- git remote add origin https://$USERNAME:$PASSWD@gitlab.com/$CI_PROJECT_PATH
- git remote add origin https://${USERNAME}:${PASSWORD}@gitlab.com/${CI_PROJECT_PATH}
- if [ $(git tag | grep "$TAGNAME") ]; then echo "[ * ] Tag already exists, skipping.."; else git tag $TAGNAME && git push origin $TAGNAME; fi
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- when: manual
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3.12-slim-bookworm as base
FROM python:3.12-slim-bookworm AS base

# variable store
ARG WDIR="/zero_build"
ARG WDIR=/zero_build
ENV CONAN_UPLOAD_CUSTOM 0

# place sources from host to container
COPY . $WDIR
WORKDIR $WDIR
COPY . ${WDIR}
WORKDIR ${WDIR}

# install basic packages
RUN \
Expand Down Expand Up @@ -41,7 +41,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/bridge.py --tools
RUN python3 ${WDIR}/wrapper/bridge.py --tools

# launch app
CMD [ "/bin/bash" ]
96 changes: 49 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ An Android kernel with Kali NetHunter functionality.
- [Contents](#contents)
- [**Disclaimer**](#disclaimer)
- [Kernel Features](#kernel-features)
- [Supported ROMs and devices](#supported-roms-and-devices)
- [ROMs](#roms)
- [Devices](#devices)
- [Supported ROMs](#supported-roms)
- [Important Note](#important-note)
- [Usage](#usage)
- [Prerequisites](#prerequisites)
Expand Down Expand Up @@ -38,20 +36,21 @@ The kernel has the following features:
- packet injection support for internal Wi-Fi chipset;
- optional KernelSU support.

## Supported ROMs and devices
## Supported ROMs

#### ROMs
For OnePlus 5/T devices:

- LineageOS;
- ParanoidAndroid;
- x_kernel supported (universal)*.
- 4.4 Linux kernel version:
- LineageOS;
- ParanoidAndroid;
- x_kernel supported (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.

#### Devices

- OnePlus 5;
- OnePlus 5T.
\** -- this, **in theory**, is relevant to all 4.14-based ROMs for this device in existence.

## Important Note

Expand Down Expand Up @@ -111,18 +110,19 @@ For more options you can refer to the help message below.

```help
$ python3 wrapper kernel --help
usage: wrapper kernel [-h] [-c] [--clean-image]
[--log-level {normal,verbose,quiet}] [-o OUTLOG] [--ksu]
{local,docker,podman} {los,pa,x} codename
positional arguments:
{local,docker,podman}
select build environment
{los,pa,x} select a ROM for the build
codename select device codename
usage: wrapper kernel [-h] --buildenv {local,docker,podman} --base
{los,pa,x,aosp} --codename CODENAME --lkv LKV [-c]
[--clean-image] [--log-level {normal,verbose,quiet}]
[-o OUTLOG] [--ksu]
options:
-h, --help show this help message and exit
--buildenv {local,docker,podman}
select build environment
--base {los,pa,x,aosp}
select a kernel base for the build
--codename CODENAME select device codename
--lkv LKV select Linux Kernel Version
-c, --clean don't build anything, just clean the environment
--clean-image remove Docker/Podman image from the host machine after
build
Expand All @@ -139,22 +139,20 @@ As mentioned, there is also an asset downloader, which can collect latest versio

```help
$ python3 wrapper assets --help
usage: wrapper assets [-h] [--extra-assets EXTRA_ASSETS] [--rom-only]
[--clean-image] [--clean]
usage: wrapper assets [-h] --buildenv {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]
{local,docker,podman} {los,pa,x} codename {full,minimal}
positional arguments:
{local,docker,podman}
select build environment
{los,pa,x} select a ROM for the build
codename select device codename
{full,minimal} select Kali chroot type
options:
-h, --help show this help message and exit
--extra-assets EXTRA_ASSETS
select a JSON file with extra assets
--buildenv {local,docker,podman}
select build environment
--base {los,pa,x,aosp}
select a kernel base for the build
--codename CODENAME select device codename
--chroot {full,minimal}
select Kali chroot type
--rom-only download only the ROM as an asset
--clean-image remove Docker/Podman image from the host machine after
build
Expand Down Expand Up @@ -186,20 +184,22 @@ An option named `slim` is a much lighter version of `full` packaging, as only th

```help
$ python3 wrapper bundle --help
usage: wrapper bundle [-h] [--conan-upload] [--clean-image]
[--log-level {normal,verbose,quiet}] [-o OUTLOG] [--ksu]
{local,docker,podman} {los,pa,x} codename
{conan,slim,full}
positional arguments:
{local,docker,podman}
select build environment
{los,pa,x} select a ROM for the build
codename select device codename
{conan,slim,full} select package type of the bundle
usage: wrapper bundle [-h] --buildenv {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}]
[-o OUTLOG] [--ksu]
options:
-h, --help show this help message and exit
--buildenv {local,docker,podman}
select build environment
--base {los,pa,x,aosp}
select a kernel base for the build
--codename CODENAME select device codename
--lkv LKV select Linux Kernel Version
--package-type {conan,slim,full}
select package type of the bundle
--conan-upload upload Conan packages to remote
--clean-image remove Docker/Podman image from the host machine after
build
Expand All @@ -215,15 +215,17 @@ options:
Here are some examples of commands:

- **(Recommended)** Build kernel and collect ROM via Docker:
- `python3 wrapper bundle docker los dumpling slim`;
- `python3 wrapper bundle --buildenv=docker --base=los --codename=dumpling --lkv=4.4 --package-type=slim`;
- Build kernel locally:
- `python3 wrapper kernel local los dumpling`;
- `python3 wrapper kernel --buildenv=local --base=los --codename=dumpling --lkv=4.4`;
- Collect all the assets locally:
- `python3 wrapper assets local los dumpling full`.
- `python3 wrapper assets --buildenv=local --base=los --codename=dumpling --package-type=full`.

## Credits

- [x_kernel_oneplus_msm8998](https://github.com/ederekun/x_kernel_oneplus_msm8998): OnePlus 5/T kernel with many optimizations and improvements;
- [x-ft_kernel_oneplus_msm8998](https://github.com/ederekun/x-ft_kernel_oneplus_msm8998): 4.14-based variation of x_kernel;
- [4.14-kernel-oneplus-msm8998](https://github.com/roberto-sartori-gl/4.14-kernel-oneplus-msm8998): a base of 4.14 kernels for OnePlus 5/T, with KernelSU patches;
- [kali-nethunter-kernel](https://gitlab.com/kalilinux/nethunter/build-scripts/kali-nethunter-kernel): official kernel patches from Kali NetHunter project.

## See also
Expand Down
4 changes: 2 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

class S0nhConan(ConanFile):
name = "zero"
version = "0.3.3"
version = "0.4.0"
author = "seppzer0"
url = "https://gitlab.com/api/v4/projects/40803264/packages/conan"
description = "An Android kernel with Kali NetHunter functionality."
topics = ("zero_kernel", "kali-nethunter")
settings = None
options = {
"rom": ("los", "pa", "x"),
"rom": ("los", "pa", "x", "aosp"),
"chroot": ("minimal", "full"),
"codename": ("dumpling", "cheeseburger")
}
Expand Down
11 changes: 6 additions & 5 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@
- [ ] use `pydantic`;
- [x] add a FAQ page;
- [ ] add wiki;
- [ ] refactor Docker/Podman command formation;
- [x] refactor Docker/Podman command formation;
- [ ] refactor logging mechanism;
- [x] fix Podman usage (.dockerignore);
- [ ] dedicate kernel source patchers as separate modules (LineageOS, AOSP, AOSPA etc);
- [x] add a separate method for multiline patching in files;
- [ ] check Alpine Linux as a base for Docker/Podman images;
- [ ] make kernel building and assets collection processes asynchronous when launching the `bundle` option;
- [ ] add a dataclass for wrapper's arguments;
- [x] add a dataclass for wrapper's arguments;
- [x] add PA ROM support;
- [ ] add a GH workflow for checking PRs;
- [x] decompose `run()` method in `ContainerEngine`;
- [x] skip building Docker/Podman image if it's already present in local cache;
- [x] for containerized build, download the contents of manifests during image build;
- [ ] add system app debloater;
- [ ] add a new argument respobsible for Linux kernel version selection;
- [ ] add 4.14 Linux kernel version builds.
- [x] add a new argument responsible for Linux kernel version selection;
- [x] add 4.14 Linux kernel version builds;
- [ ] decompose `run` methods into separate functions as much as possible;
- [ ] new device support: OP9.
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[tool.poetry]
name = "zero-kernel-builder"
version = "0.3.3"
version = "0.4.0"
description = "An Android kernel with Kali NetHunter functionality."
authors = ["seppzer0"]
readme = "README.md"
packages = [{include = "wrapper"}]

[tool.poetry.dependencies]
Expand Down
45 changes: 35 additions & 10 deletions scripts/multi_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,48 @@ def main(args: argparse.Namespace) -> None:
"module": "kernel",
"rom": "x",
"codename": "dumpling",
"ksu": "false"
"lkv": "4.4",
"ksu": False
},
{
"module": "kernel",
"rom": "x",
"codename": "dumpling",
"ksu": "true"
"lkv": "4.4",
"ksu": True
},
{
"module": "kernel",
"rom": "pa",
"codename": "dumpling",
"lkv": "4.14",
"ksu": True
},
{
"module": "kernel",
"rom": "x",
"codename": "dumpling",
"lkv": "4.14",
"ksu": True
},
{
"module": "kernel",
"rom": "x",
"codename": "dumpling",
"lkv": "4.14",
"ksu": False
},
{
"module": "assets",
"rom": "los",
"codename": "cheeseburger",
"ksu": "true"
"ksu": True
},
{
"module": "assets",
"rom": "pa",
"codename": "cheeseburger",
"ksu": "true"
"ksu": True
},
)
os.chdir(apath)
Expand All @@ -74,17 +97,19 @@ def main(args: argparse.Namespace) -> None:
# create artifact holder directory
if dir_shared not in os.listdir():
os.mkdir(dir_shared)
# extract individual values
# define values individually
module = argset["module"]
rom = argset["rom"]
codename = argset["codename"]
ksu = "--ksu" if argset["ksu"] == "true" else ""
size = argset["size"] if argset["module"] == "bundle" else ""
buildenv = f"--buildenv {args.env}"
base = f'--base {argset["rom"]}'
codename = f'--codename {argset["codename"]}'
lkv = f'--lkv {argset["lkv"]}' if argset["module"] in ("kernel", "bundle") else ""
ksu = "--ksu" if argset["ksu"] else ""
size = f'--package-type {argset["size"]}' if argset["module"] == "bundle" else ""
extra = "minimal --rom-only --clean" if argset["module"] == "assets" else ""
# if the build is last, make it automatically remove the Docker/Podman image from runner
clean = "--clean-image" if count == len(argsets) and args.env in ("docker", "podman") else ""
# form and launch the command
cmd = f"python3 wrapper {module} {args.env} {rom} {codename} {size} {ksu} {clean} {extra}"
cmd = f"python3 wrapper {module} {buildenv} {base} {codename} {lkv} {size} {ksu} {clean} {extra}"
print(f"[CMD]: {cmd}")
subprocess.run(cmd.strip(), shell=True, check=True)
# copy artifacts into the shared directory
Expand Down
Loading

0 comments on commit 0137025

Please sign in to comment.