Skip to content

Commit 0fef4d3

Browse files
committed
Merge branch 'dev'
2 parents 0ce09dc + 673552a commit 0fef4d3

File tree

20 files changed

+477
-191
lines changed

20 files changed

+477
-191
lines changed

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# Python
1+
# Python Virtual Environments
22
venv
33
.venv
4+
py-utils/__pycache__/
45

5-
# Env
6+
# Environment files
67
*.env
8+
9+
# IntelliJ
10+
.idea

Dockerfile

Lines changed: 15 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,31 @@
1-
FROM docker.io/debian:trixie-slim
1+
FROM docker.io/sirrgb/dockdroid-base:latest
22

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

9-
# Dirs
7+
# Directories
108
ARG ROOT_DIR=/droid_workdir
119
ENV SCRIPT_DIR="${ROOT_DIR}"/scripts
12-
ENV ROM_DIR="${ROOT_DIR}"/src/Los15
10+
ENV ROM_DIR=''
1311
ENV KEYS_DIR="${ROOT_DIR}"/keys
14-
ENV BIN_DIR="${ROOT_DIR}"/bin
1512
ENV LOGS_DIR="${ROOT_DIR}"/logs
1613

17-
# Switch to Root for Setup
1814
USER root
1915

20-
# Android build dependencies
21-
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
22-
bc \
23-
bison \
24-
build-essential \
25-
ca-certificates \
26-
ccache \
27-
curl \
28-
flex \
29-
g++-multilib \
30-
gcc-multilib \
31-
git \
32-
git-lfs \
33-
gnupg \
34-
gperf \
35-
imagemagick \
36-
lib32readline-dev \
37-
lib32z1-dev \
38-
libelf-dev \
39-
libncurses6 \
40-
libsdl1.2-dev \
41-
libssl-dev \
42-
libxml2 \
43-
libxml2-utils \
44-
lz4 \
45-
lzop \
46-
pngcrush \
47-
python3 \
48-
python-is-python3 \
49-
rsync \
50-
schedtool \
51-
ssh \
52-
squashfs-tools \
53-
xsltproc \
54-
zip \
55-
zlib1g-dev \
56-
# Python
57-
libbz2-dev \
58-
liblzma-dev \
59-
libsqlite3-dev \
60-
libreadline-dev \
61-
# Automation
62-
file \
63-
jq \
64-
unzip
65-
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-
7216
# Create dirs and copy scripts
73-
RUN mkdir -p "${SCRIPT_DIR}" "${BIN_DIR}" "${KEYS_DIR}"
17+
RUN mkdir --parents "${SCRIPT_DIR}"
7418
COPY scripts/ "${SCRIPT_DIR}"/
19+
COPY py-utils/ "${BIN_DIR}"/
7520

7621
# Set up user and work directories
77-
RUN groupadd -g "${groupid}" "${username}" \
78-
&& useradd -m -s /bin/bash -u "${userid}" -g "${groupid}" "${username}" -d "${ROOT_DIR}"
79-
RUN chown -R "${userid}":"${groupid}" "${ROOT_DIR}" && chmod -R ug+srw "${ROOT_DIR}"
22+
RUN chown --recursive "${userid}":"${groupid}" "${ROOT_DIR}" && chmod --recursive u+srw "${ROOT_DIR}"
8023

8124
# Switch to user for execution
82-
USER "${username}"
83-
84-
# Install and verify repo
85-
RUN gpg --recv-key 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65
86-
RUN curl -o "${BIN_DIR}"/repo https://storage.googleapis.com/git-repo-downloads/repo
87-
RUN curl https://storage.googleapis.com/git-repo-downloads/repo.asc | gpg --verify - "${BIN_DIR}"/repo
88-
89-
# Provide make_key to create signing keys
90-
RUN curl https://raw.githubusercontent.com/LineageOS/android_development/refs/heads/lineage-23.0/tools/make_key > "${BIN_DIR}"/make_key
91-
92-
# Patch for longer key size and drop input
93-
RUN sed -i "/read -p \"Enter password for '\$1' (blank for none\; password will be visible): \" \\\/d" "${BIN_DIR}"/make_key
94-
RUN sed -i "s/ password/password=\"\"/g; s/echo; exit 1' EXIT INT QUIT/' EXIT/g; s/2048/4096/g" "${BIN_DIR}"/make_key
25+
USER "${USER}"
9526

9627
# Make scripts executable
97-
RUN chmod -R 500 "${BIN_DIR}" "${SCRIPT_DIR}"
28+
RUN chmod --recursive 500 "${SCRIPT_DIR}" "${BIN_DIR}"
9829

9930
# ROM variables
10031
ENV LOCAL_MANIFEST=''
@@ -110,19 +41,25 @@ ENV LUNCH_PREFIX_FALLBACK=''
11041
ENV ROM_PREFIX_FALLBACK=''
11142
ENV ROM_VERSION_FALLBACK=''
11243
ENV ROM_OTA_BRANCH_FALLBACK=''
44+
ENV RELEASETOOL_EXTRA_FLAGS=''
11345

11446
# Extra variables
11547
ENV CCACHE_SIZE=40
11648
ENV OTA_REPO_URL=''
11749
ENV KEYS_SUBJECT='/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]'
118-
ENV TIME_ZONE="UTC"
50+
ENV TIME_ZONE='UTC'
11951
ENV REPOPICK_PICKS=''
12052
ENV REPOPICK_TOPICS=''
53+
ENV REPOPICK_PULLS=''
54+
ENV DEBUG=''
12155

12256
# Authentification
12357
ENV TELEGRAM_TOKEN=''
12458
ENV GITHUB_TOKEN=''
12559
ENV SF_USER=''
12660
ENV SF_RELEASES_REPO=''
61+
ENV SSH_USER=''
62+
ENV SSH_UPLOAD_URL=''
63+
ENV SSH_DOWNLOAD_URL=''
12764

12865
ENTRYPOINT ["/bin/bash", "-c", "${SCRIPT_DIR}/init.sh"]

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ Then we need to chown that directory to the Docker user:
4545

4646
#### Debian/Ubuntu
4747
```
48-
sudo chown -R 100999:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
48+
sudo chown --recursive 100999:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
4949
```
5050

5151
#### Fedora
5252
```
53-
sudo chown -R 52587:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
53+
sudo chown --recursive 52587:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
5454
```
5555

5656
#### Other
5757
(If you know a smarter way to do this please tell me,
58-
I know the available subuids can be found with `cat /etc/subuid | grep $USER | cut -d":" -f2`
58+
I know the available subuids can be found with `grep $USER < /etc/subuid | cut --delimiter=":" --fields=2`
5959
I just do not know if the container uid is predictable,
6060
it seems to be 1000 for debian/ubuntu and 100 for fedora)
6161

6262
Let other users read the directory
6363
```
64-
sudo chmod -R 507 ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
64+
sudo chmod --recursive 507 ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
6565
```
6666
Run the first docker build
6767
```
@@ -75,7 +75,7 @@ ls -n ~/docker_droid/src/Los15/.repo
7575
Give ownership to the uid you found out:
7676
(replace the 1st UID)
7777
```
78-
sudo chown -R UID:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
78+
sudo chown --recursive UID:"${UID}" ~/docker_droid/src ~/docker_droid/dotfiles ~/docker_droid/ccache ~/docker_droid/logs ~/docker_droid/keys
7979
```
8080
And remove the incomplete sync
8181
```
@@ -100,7 +100,7 @@ or
100100
These variables should be defined in the target.env.
101101

102102
```
103-
cp example.env target.env
103+
cp ~/docker_droid/minideb/example.env ~/docker_droid/minideb/target.env
104104
```
105105

106106
```
@@ -153,6 +153,7 @@ [email protected]:user/ota_config
153153
```
154154
podman compose up --force-recreate --build
155155
```
156+
or
156157
```
157158
docker compose up --force-recreate --build
158159
```

TODO.md

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

base/Dockerfile

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
FROM docker.io/debian:trixie-slim
2+
3+
# User
4+
ARG userid=1000
5+
ARG groupid=1000
6+
ENV USER=droid
7+
8+
# Switch to Root for Setup
9+
USER root
10+
11+
# Directories
12+
ARG ROOT_DIR=/droid_workdir
13+
ENV BIN_DIR="${ROOT_DIR}"/bin
14+
15+
# Android build dependencies
16+
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \
17+
bc \
18+
bison \
19+
build-essential \
20+
ca-certificates \
21+
ccache \
22+
curl \
23+
flex \
24+
g++-multilib \
25+
gcc-multilib \
26+
git \
27+
git-lfs \
28+
gnupg \
29+
gperf \
30+
imagemagick \
31+
lib32readline-dev \
32+
lib32z1-dev \
33+
libelf-dev \
34+
libncurses6 \
35+
libsdl1.2-dev \
36+
libssl-dev \
37+
libxml2 \
38+
libxml2-utils \
39+
lz4 \
40+
lzop \
41+
pngcrush \
42+
python3 \
43+
python-is-python3 \
44+
rsync \
45+
schedtool \
46+
ssh \
47+
squashfs-tools \
48+
xsltproc \
49+
zip \
50+
zlib1g-dev \
51+
# Python
52+
libbz2-dev \
53+
liblzma-dev \
54+
libsqlite3-dev \
55+
libreadline-dev \
56+
# Automation
57+
file \
58+
unzip
59+
60+
RUN rm --recursive /var/lib/apt/lists /var/cache/apt/archives
61+
62+
# Symlink libncurses for compatibility
63+
RUN ln --symbolic /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
64+
RUN ln --symbolic /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
65+
66+
# Create dirs and copy scripts
67+
RUN mkdir --parents "${BIN_DIR}"
68+
69+
# Set up user and work directories
70+
RUN groupadd --gid "${groupid}" "${USER}" \
71+
&& useradd --create-home --shell /bin/bash --uid "${userid}" --gid "${groupid}" "${USER}" --home-dir "${ROOT_DIR}"
72+
RUN chown --recursive "${userid}":"${groupid}" "${ROOT_DIR}" && chmod --recursive u+srw "${ROOT_DIR}"
73+
74+
# Switch to user for execution
75+
USER "${USER}"
76+
77+
# Curl flags
78+
RUN echo '/usr/bin/curl --fail --silent --show-error --location "$@"' > "${BIN_DIR}"/curl_cmd
79+
80+
# Make scripts executable
81+
RUN chmod --recursive 700 "${BIN_DIR}"
82+
ENV PYENV_ROOT="${ROOT_DIR}"/pyenv-master
83+
ENV PATH="${PYENV_ROOT}"/bin:"${BIN_DIR}":"${PATH}"
84+
85+
# Install and verify repo
86+
RUN gpg --recv-key 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65
87+
RUN curl_cmd https://storage.googleapis.com/git-repo-downloads/repo --output "${BIN_DIR}"/repo
88+
RUN curl_cmd https://storage.googleapis.com/git-repo-downloads/repo.asc | gpg --verify - "${BIN_DIR}"/repo
89+
90+
# Provide make_key to create signing keys
91+
RUN curl_cmd https://raw.githubusercontent.com/LineageOS/android_development/refs/heads/lineage-23.2/tools/make_key --output "${BIN_DIR}"/make_key
92+
93+
# Patch for longer key size and drop input
94+
RUN sed --in-place "/read -p \"Enter password for '\$1' (blank for none\; password will be visible): \" \\\/d" "${BIN_DIR}"/make_key
95+
RUN sed --in-place "s/ password/password=\"\"/g; s/echo; exit 1' EXIT INT QUIT/' EXIT/g; s/2048/4096/g" "${BIN_DIR}"/make_key
96+
97+
# Make scripts executable
98+
RUN chmod --recursive 500 "${BIN_DIR}"
99+
100+
# PyEnv
101+
RUN curl_cmd --remote-name https://github.com/pyenv/pyenv/archive/refs/heads/master.zip --output-dir /tmp
102+
RUN unzip /tmp/master.zip -d "${ROOT_DIR}"/
103+
RUN rm /tmp/*
104+
RUN pyenv install 2 3.11

base/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
all: build run
2+
tag ?= $$(date +%Y%m%d%H%M)
3+
4+
build:
5+
docker build . --tag docker.io/sirrgb/dockdroid-base:latest
6+
7+
run:
8+
docker run --interactive --tty docker.io/sirrgb/dockdroid-base:latest
9+
10+
publish:
11+
docker tag docker.io/sirrgb/dockdroid-base:latest docker.io/sirrgb/dockdroid-base:$(tag)
12+
docker image push docker.io/sirrgb/dockdroid-base:$(tag)
13+
docker image push docker.io/sirrgb/dockdroid-base:latest

compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ services:
1818
- ~/docker_droid/dotfiles/.ssh:/droid_workdir/.ssh:ro
1919
env_file:
2020
- path: ./target.env
21-
required: false
21+
required: true
2222
- path: ./config.env
2323
required: false

py-utils/json_arg_parser.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/python3
2+
3+
import json
4+
import sys
5+
6+
7+
def main() -> None:
8+
try:
9+
json_target = json.loads(str(sys.stdin.read()))
10+
search_target = str(sys.argv[1])
11+
except TypeError:
12+
print("Invalid arguments")
13+
sys.exit(1)
14+
15+
try:
16+
print(json_target[search_target])
17+
except KeyError:
18+
print("Argument not found")
19+
sys.exit(1)
20+
21+
22+
if __name__ == '__main__':
23+
main()

0 commit comments

Comments
 (0)