Skip to content

Commit 0ce09dc

Browse files
committed
Merge branch 'dev'
2 parents 3844106 + bf16c2e commit 0ce09dc

File tree

13 files changed

+160
-113
lines changed

13 files changed

+160
-113
lines changed

Dockerfile

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
FROM docker.io/bitnami/minideb:bookworm
1+
FROM docker.io/debian:trixie-slim
22

33
# User
44
ARG userid=1000
55
ARG groupid=1000
66
ARG username=droid
7-
ENV USER "${username}"
7+
ENV USER="${username}"
88

99
# Dirs
1010
ARG ROOT_DIR=/droid_workdir
11-
ENV SCRIPT_DIR "${ROOT_DIR}"/scripts
12-
ENV ROM_DIR "${ROOT_DIR}"/src/Los15
13-
ENV KEYS_DIR "${ROOT_DIR}"/keys
14-
ENV BIN_DIR "${ROOT_DIR}"/bin
15-
ENV LOGS_DIR "${ROOT_DIR}"/logs
11+
ENV SCRIPT_DIR="${ROOT_DIR}"/scripts
12+
ENV ROM_DIR="${ROOT_DIR}"/src/Los15
13+
ENV KEYS_DIR="${ROOT_DIR}"/keys
14+
ENV BIN_DIR="${ROOT_DIR}"/bin
15+
ENV LOGS_DIR="${ROOT_DIR}"/logs
1616

1717
# Switch to Root for Setup
1818
USER root
1919

2020
# Android build dependencies
21-
RUN install_packages \
21+
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
2222
bc \
2323
bison \
2424
build-essential \
@@ -36,12 +36,12 @@ RUN install_packages \
3636
lib32readline-dev \
3737
lib32z1-dev \
3838
libelf-dev \
39-
liblz4-tool \
40-
libncurses5 \
39+
libncurses6 \
4140
libsdl1.2-dev \
4241
libssl-dev \
4342
libxml2 \
4443
libxml2-utils \
44+
lz4 \
4545
lzop \
4646
pngcrush \
4747
python3 \
@@ -54,21 +54,21 @@ RUN install_packages \
5454
zip \
5555
zlib1g-dev \
5656
# Python
57-
libffi-dev \
5857
libbz2-dev \
59-
libncursesw5-dev \
60-
libreadline-dev \
61-
libsqlite3-dev \
62-
libxml2-dev \
63-
libxmlsec1-dev \
6458
liblzma-dev \
65-
tk-dev \
66-
xz-utils \
59+
libsqlite3-dev \
60+
libreadline-dev \
6761
# Automation
6862
file \
6963
jq \
7064
unzip
7165

66+
RUN rm --recursive /var/lib/apt/lists /var/cache/apt/archives
67+
68+
# Symlink libncurses for compatibility
69+
RUN ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
70+
RUN ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
71+
7272
# Create dirs and copy scripts
7373
RUN mkdir -p "${SCRIPT_DIR}" "${BIN_DIR}" "${KEYS_DIR}"
7474
COPY scripts/ "${SCRIPT_DIR}"/
@@ -96,30 +96,33 @@ RUN sed -i "s/ password/password=\"\"/g; s/echo; exit 1' EXIT INT QUIT/' EXIT/g
9696
# Make scripts executable
9797
RUN chmod -R 500 "${BIN_DIR}" "${SCRIPT_DIR}"
9898

99-
# ROM
100-
ENV LOCAL_MANIFEST ""
101-
ENV CLONE_REPOS ""
102-
ENV DEVICE ""
103-
ENV BUILD_TYPE ""
104-
ENV ROM_MANIFEST ""
105-
ENV ROM_BRANCH ""
106-
ENV ROM_BUILD_FLAGS ""
107-
108-
ENV LUNCH_PREFIX_FALLBACK ""
109-
ENV ROM_PREFIX_FALLBACK ""
110-
ENV ROM_VERSION_FALLBACK ""
111-
ENV ROM_OTA_BRANCH_FALLBACK ""
112-
113-
# Extra
114-
ENV CCACHE_SIZE 40
115-
ENV OTA_REPO_URL ""
116-
ENV KEYS_SUBJECT '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]'
117-
ENV TIME_ZONE "UTC"
118-
119-
# Auth
120-
ENV TELEGRAM_TOKEN ""
121-
ENV GITHUB_TOKEN ""
122-
ENV SF_USER ""
123-
ENV SF_RELEASES_REPO ""
124-
125-
ENTRYPOINT "${SCRIPT_DIR}"/init.sh
99+
# ROM variables
100+
ENV LOCAL_MANIFEST=''
101+
ENV CLONE_REPOS=''
102+
ENV DEVICE=''
103+
ENV BUILD_TYPE=''
104+
ENV ROM_MANIFEST=''
105+
ENV ROM_BRANCH=''
106+
ENV ROM_BUILD_FLAGS=''
107+
108+
# Fallbacks (required for non-standard naming and conflicts)
109+
ENV LUNCH_PREFIX_FALLBACK=''
110+
ENV ROM_PREFIX_FALLBACK=''
111+
ENV ROM_VERSION_FALLBACK=''
112+
ENV ROM_OTA_BRANCH_FALLBACK=''
113+
114+
# Extra variables
115+
ENV CCACHE_SIZE=40
116+
ENV OTA_REPO_URL=''
117+
ENV KEYS_SUBJECT='/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]'
118+
ENV TIME_ZONE="UTC"
119+
ENV REPOPICK_PICKS=''
120+
ENV REPOPICK_TOPICS=''
121+
122+
# Authentification
123+
ENV TELEGRAM_TOKEN=''
124+
ENV GITHUB_TOKEN=''
125+
ENV SF_USER=''
126+
ENV SF_RELEASES_REPO=''
127+
128+
ENTRYPOINT ["/bin/bash", "-c", "${SCRIPT_DIR}/init.sh"]

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## Why Docker/Podman?
22

33
Docker/Podman provides a uniform build environment, without external dependencies, that you have to set up manually.
4-
The goal is to make building properly with ota and signing easy for everyone.
4+
The goal is to make building properly with ota and signing easy for everyone.
5+
This project targets Android 7 up to the most recent version.
56

67

78
<details>
@@ -10,19 +11,19 @@ The goal is to make building properly with ota and signing easy for everyone.
1011
## Prerequisites
1112

1213
- [Podman](https://podman.io/docs/installation)
13-
- [Python venv](https://docs.python.org/3/library/venv.html#creating-virtual-environments)
1414
- [Podman compose](https://github.com/containers/podman-compose?tab=readme-ov-file#pip)
1515
- or [Docker](https://docs.docker.com/engine/install)
16+
- [Docker Compose](https://docs.docker.com/compose/install)
1617
- [Docker Rootless](https://docs.docker.com/engine/security/rootless/)
1718
- [SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
1819
- [GitConfig](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup)
19-
- ZRam (highly recommended): [Debian](https://wiki.debian.org/ZRam), [Fedora](https://github.com/systemd/zram-generator), [Ubuntu](https://wiki.ubuntuusers.de/zRam)
20+
- ZRam (highly recommended): [Debian](https://wiki.debian.org/ZRam), [Fedora](https://github.com/systemd/zram-generator), [Ubuntu, Arch and others](https://wiki.archlinux.org/title/Zram)
2021

2122

2223
### Setting up permissions
2324

2425
First we need to find the UID, that is used for Docker/Podman.
25-
For Debian/Ubuntu this seems to be 100999 and on Fedora 52587,
26+
For Debian, Ubuntu and Gentoo this seems to be 100999 and on Fedora 52587,
2627
which should be $subUID+$containerUID-1 according to the [docker forums](https://forums.docker.com/t/map-more-uid-on-rootless-docker-and-mount-volume/102928/8).
2728

2829

TODO.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
## ToDo
22
- move printing to printf
33
- 94fa96faf062de55062bb79909548e778b692bfb
4+
- automatic repo pulling for officially supported lineage devices
5+
- move json and xml handling to python
6+
- general ssh upload

scripts/compat.sh

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
11
#!/bin/bash
22

3-
# Set up Py2
4-
_setup_py2() {
3+
# Initialize PyEnv
4+
_setup_pyenv() {
55
curl -fsSL https://pyenv.run | bash
66
export PYENV_ROOT="${HOME}"/.pyenv
77
[[ -d "${PYENV_ROOT}"/bin ]] && export PATH="${PYENV_ROOT}"/bin:"${PATH}"
88
eval "$(pyenv init - bash)"
99
"${SHELL}"
10+
}
1011

12+
# Set up PyEnv with Python 2.7
13+
_init_py2() {
14+
_setup_pyenv
1115
pyenv install 2
1216
pyenv global 2
1317
}
1418

15-
# Set up JDK8 and re-enable TLS 1/1.1
19+
# Set up PyEnv with Python 3.11
20+
_init_py3() {
21+
_setup_pyenv
22+
pyenv install 3.11
23+
pyenv global 3.11
24+
}
25+
26+
# Set up Temurin 8 and re-enable TLS 1/1.1
1627
_setup_jdk8() {
1728
local jdk_dir jdk_tag jdk_name
1829
jdk_dir="${HOME}"/java/jdk
19-
jdk_tag=jdk8u462-b08
30+
jdk_tag=jdk8u472-b08
2031
jdk_name=OpenJDK8U-jdk_x64_linux_hotspot_"$(echo ${jdk_tag//jdk/} | tr -d -)".tar.gz
2132
mkdir -p "${jdk_dir}"
2233
curl -fsSOL https://github.com/adoptium/temurin8-binaries/releases/download/"${jdk_tag}"/"${jdk_name}" --output-dir "${jdk_dir}"
23-
echo 5d64ae542b59a962b3caadadd346f4b1c3010879a28bb02d928326993de16e79 "${jdk_dir}"/"${jdk_name}" | sha256sum --check
34+
echo 55963261b4df76f76109eaa442b8e9621425a4a45c69fd5507bb33899dffd7d5 "${jdk_dir}"/"${jdk_name}" | sha256sum --check
2435
tar xvf "${jdk_dir}"/"${jdk_name}" --directory="${jdk_dir}"
2536
rm "${jdk_dir}"/"${jdk_name}"
2637

2738
export JAVA_HOME="${jdk_dir}"/"${jdk_tag}"
2839
export PATH="${JAVA_HOME}"/bin:"${PATH}"
2940

3041
sed -i 's/TLSv1, TLSv1.1, //g' "${JAVA_HOME}"/jre/lib/security/java.security
31-
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
42+
export ANDROID_JACK_VM_ARGS='-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G'
3243
export LC_ALL=C
3344
}
3445

@@ -41,13 +52,24 @@ _key_size_recovery() {
4152
sed -i 's/!= 2048/< 2048/' "${ROM_DIR}"/bootable/recovery/tools/dumpkey/DumpPublicKey.java
4253
}
4354

44-
_setup_py2
55+
56+
# A7-9
57+
if [[ "${ANDROID_VERSION}" -lt 10 ]]; then
58+
_init_py2
59+
# A10-15
60+
else
61+
_init_py3
62+
fi
63+
64+
# A7/A8
4565
if [[ "${ANDROID_VERSION}" -lt 9 ]]; then
4666
_setup_jdk8
4767
fi
4868

49-
if [[ "${ANDROID_VERSION}" -gt 7 ]]; then
69+
# A8/9
70+
if [[ "${ANDROID_VERSION}" -gt 7 ]] && [[ "${ANDROID_VERSION}" -lt 10 ]]; then
5071
_key_size_recovery
51-
else
72+
# A7
73+
elif [[ "${ANDROID_VERSION}" -lt 8 ]]; then
5274
_key_size_sys_core
5375
fi

scripts/init.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export PATH="${BIN_DIR}":"${PATH}"
77

88
# Set up logs
99
find "${LOGS_DIR}"/ -type d -ctime +1 -exec rm -r {} \; || true
10-
BUILD_DATE_UNIX=$(date "+%s")
11-
BUILD_DATE=$(env TZ="${TIME_ZONE}" date -d @"${BUILD_DATE_UNIX}" "+%Y%m%d-%H%M%S")
10+
BUILD_DATE_UNIX="$(date '+%s')"
11+
BUILD_DATE=$(env TZ="${TIME_ZONE}" date -d @"${BUILD_DATE_UNIX}" '+%Y%m%d-%H%M%S')
1212
mkdir "${LOGS_DIR}"/"${BUILD_DATE}"
1313
unset BIN_DIR
1414

scripts/lunch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ _lunch() {
1111
local release_codename
1212
release_codename=
1313
if [[ -d "${ANDROID_BUILD_TOP}"/build/release/aconfig/ ]]; then
14-
release_codename=-$(find "${ANDROID_BUILD_TOP}"/build/release/aconfig/* -maxdepth 0 -type d -name "[a-z][a-z][0-9][a-z]" -printf '%f\n' | tail -n1)
14+
release_codename=-$(find "${ANDROID_BUILD_TOP}"/build/release/aconfig/* -maxdepth 0 -type d -name '[a-z][a-z][0-9][a-z]' -printf '%f\n' | tail -n1)
1515
fi
1616

1717
# Extract lunch prefix from AndroidProducts
1818
local product
1919
if [[ -n "${LUNCH_PREFIX_FALLBACK}" ]]; then
2020
product="${LUNCH_PREFIX_FALLBACK}"_"${TARGET_DEVICE}"
2121
else
22-
product=$(grep -E "${TARGET_DEVICE}" "${ANDROID_BUILD_TOP}"/device/*/"${TARGET_DEVICE}"/AndroidProducts.mk | cut -d"/" -f2 | cut -d"." -f1 | head -n1)
22+
product=$(grep -E "${TARGET_DEVICE}" "${ANDROID_BUILD_TOP}"/device/*/"${TARGET_DEVICE}"/AndroidProducts.mk | cut -d'/' -f2 | cut -d'.' -f1 | head -n1)
2323
fi
2424

2525
# It's all coming together

scripts/ota.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ source "${SCRIPT_DIR}"/print.sh
77
_ota_info() {
88
local file_size id datetime custom_build_type
99
file_size=$(stat -c%s "${OUT}"/"${PACKAGE_NAME}")
10-
id=$(sha256sum "${OUT}"/"${PACKAGE_NAME}" | cut -d" " -f1)
11-
datetime=$(grep ro\.build\.date\.utc "${OUT}"/system/build.prop | cut -d"=" -f2)
10+
id=$(sha256sum "${OUT}"/"${PACKAGE_NAME}" | cut -d' ' -f1)
11+
datetime=$(grep ro\.build\.date\.utc "${OUT}"/system/build.prop | cut -d'=' -f2)
1212
custom_build_type="UNOFFICIAL"
1313
jq -n "{\"response\": [{\"datetime\": ${datetime},\"filename\": \"${PACKAGE_NAME}\",\"id\": \"${id}\",\"romtype\": \"${custom_build_type}\", \"size\": ${file_size}, \"url\": \"${DL_OTA_URL}\", \"version\": \"${ROM_VERSION}\"}]}" > "${OUT}"/"${PACKAGE_NAME}".json
1414
}
@@ -34,13 +34,14 @@ _push_ota_info() {
3434
target_ota_repo_url="${OTA_REPO_URL//git@github.com:/https://${GITHUB_TOKEN}@github.com/}"
3535
fi
3636

37-
# Append extraversion to avoid collision of different flavours
37+
# Specify a fallback, so that roms, that purely rely on android numbers dont collide
3838
if [[ -n "${ROM_OTA_BRANCH_FALLBACK}" ]]; then
3939
target_ota_branch="${ROM_OTA_BRANCH_FALLBACK}"
4040
else
4141
target_ota_branch="${ROM_BRANCH}"
4242
fi
4343

44+
# Append extraversion to avoid collision of different flavours
4445
if [[ -n "${ROM_EXTRAVERSION}" ]]; then
4546
target_ota_branch="${target_ota_branch}"-"$(tr -d - <<< "${ROM_EXTRAVERSION,,}")"
4647
fi

scripts/packaging.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ _version() {
1313

1414
# Search for line containing the regex inside *[V|v]ersion.mk|common.mk, cut that number and set points in between
1515
if [[ -z "${ROM_PREFIX_FALLBACK}" ]]; then
16-
ROM_PREFIX=$(find "${ANDROID_BUILD_TOP}"/vendor/*/build/tasks/* "${ANDROID_BUILD_TOP}"/build/core/Makefile -exec grep '_TARGET_PACKAGE[[:space:]]:=' {} \; | cut -d"=" -f2 | cut -d"/" -f2 | cut -d"$" -f1)
16+
ROM_PREFIX=$(find "${ANDROID_BUILD_TOP}"/vendor/*/build/tasks/* "${ANDROID_BUILD_TOP}"/build/core/Makefile -exec grep '_TARGET_PACKAGE[[:space:]]:=' {} \; | cut -d'=' -f2 | cut -d'/' -f2 | cut -d'$' -f1)
1717
else
1818
ROM_PREFIX="${ROM_PREFIX_FALLBACK}"
1919
fi
2020
if [[ -z "${ROM_VERSION_FALLBACK}" ]]; then
21-
ROM_VERSION=$(find "${ANDROID_BUILD_TOP}"/vendor/*/config/ \( -name "*[vV]ersion.mk" -o -name common.mk \) -exec grep -E "${major_version_regex}" {} \; | tr -d 'A-z:= \n').\
22-
$(find "${ANDROID_BUILD_TOP}"/vendor/*/config/ \( -name "*[vV]ersion.mk" -o -name common.mk \) -exec grep -E "${minor_version_regex}" {} \; | tr -d 'A-z:= \n')
21+
ROM_VERSION=$(find "${ANDROID_BUILD_TOP}"/vendor/*/config/ \( -name '*[vV]ersion.mk' -o -name common.mk \) -exec grep -E "${major_version_regex}" {} \; | tr -d 'A-z:= \n').\
22+
$(find "${ANDROID_BUILD_TOP}"/vendor/*/config/ \( -name '*[vV]ersion.mk' -o -name common.mk \) -exec grep -E "${minor_version_regex}" {} \; | tr -d 'A-z:= \n')
2323
else
2424
ROM_VERSION="${ROM_VERSION_FALLBACK}"
2525
fi
26-
ROM_EXTRAVERSION=""
27-
if [[ -n $(find "${OUT}" -mindepth 2 -name "FakeStore.apk" -print -quit) ]]; then
28-
ROM_EXTRAVERSION="MICROG-"
29-
elif [[ -n $(find "${OUT}" -mindepth 2 -name "GmsCore.apk" -print -quit) ]]; then
30-
ROM_EXTRAVERSION="GMS-"
26+
ROM_EXTRAVERSION=''
27+
if [[ -n $(find "${OUT}" -mindepth 2 -name 'FakeStore.apk' -print -quit) ]]; then
28+
ROM_EXTRAVERSION='MICROG-'
29+
elif [[ -n $(find "${OUT}" -mindepth 2 -name 'GmsCore.apk' -print -quit) ]]; then
30+
ROM_EXTRAVERSION='GMS-'
3131
fi
32-
PACKAGE_NAME="${ROM_PREFIX}""${ROM_VERSION}"-"${ROM_EXTRAVERSION}"$(env TZ="${TIME_ZONE}" date -d @"${BUILD_DATE_UNIX}" +%Y%m%d)-"${TARGET_DEVICE}"-signed.zip
32+
PACKAGE_NAME="${ROM_PREFIX}""${ROM_VERSION}"-"${ROM_EXTRAVERSION}"$(env TZ="${TIME_ZONE}" date -d @"${BUILD_DATE_UNIX}" '+%Y%m%d')-"${TARGET_DEVICE}"-signed.zip
3333
}
3434

3535
# Create flashable zip from target files
3636
_packaging() {
3737
_version
38-
local releasetools_prefix=""
38+
local releasetools_prefix=''
3939
# A10 and below need this prepended for signing to work
4040
if [[ "${ANDROID_VERSION}" -lt 11 ]]; then
4141
releasetools_prefix="${ANDROID_BUILD_TOP}"/build/tools/releasetools/

0 commit comments

Comments
 (0)