Skip to content

Commit

Permalink
Recode [BETA]
Browse files Browse the repository at this point in the history
  • Loading branch information
AnGgIt86 committed Jul 26, 2024
1 parent a394a6f commit 5b5c699
Show file tree
Hide file tree
Showing 14 changed files with 797 additions and 240 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea/
*.iml
65 changes: 35 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
FROM ubuntu:latest
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND noninteractive

ARG SDK_VERSION=34.0.0
ENV ANDROID_HOME /opt/android-sdk-linux
ENV ANDROID_SDK_HOME ${ANDROID_HOME}
ENV ANDROID_SDK_ROOT ${ANDROID_HOME}
ENV ANDROID_SDK ${ANDROID_HOME}
LABEL de.mindrunner.android-docker.flavour="ubuntu-standalone"

ENV PATH "${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin"
ENV PATH "${PATH}:${ANDROID_HOME}/cmdline-tools/tools/bin"
ENV PATH "${PATH}:${ANDROID_HOME}/tools/bin"
ENV PATH "${PATH}:${ANDROID_HOME}/build-tools/${SDK_VERSION}"
ENV PATH "${PATH}:${ANDROID_HOME}/platform-tools"
ENV PATH "${PATH}:${ANDROID_HOME}/emulator"
ENV PATH "${PATH}:${ANDROID_HOME}/bin"
ENV ANDROID_SDK_HOME /opt/android-sdk-linux
ENV ANDROID_SDK_ROOT /opt/android-sdk-linux
ENV ANDROID_HOME /opt/android-sdk-linux
ENV ANDROID_SDK /opt/android-sdk-linux

RUN dpkg --add-architecture i386 && \
apt-get update -yqq && \
apt-get install -y curl expect git libc6:i386 libgcc1:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 openjdk-17-jdk wget unzip vim sudo && \
apt-get clean
ENV PATH $PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin/:$ANDROID_HOME/build-tools/35.0.0/:$ANDROID_HOME/emulator/:$ANDROID_HOME/bin:/opt/tools

RUN bash -c "$(curl -fsSL https://deb.nodesource.com/setup_21.x)" && \
apt-get install -y nodejs
ENV DEBIAN_FRONTEND noninteractive

RUN groupadd android && useradd -d /opt/android-sdk-linux -g android android
RUN dpkg --add-architecture i386 && apt-get update -yqq && apt-get install -y \
curl \
expect \
git \
libarchive-tools \
locales \
make \
openjdk-17-jdk \
openssh-client \
unzip \
vim \
wget \
zip \
dos2unix \
apksigner \
golang \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& go install github.com/tcnksm/ghr@latest

ENV LANG en_US.UTF-8

RUN groupadd android && useradd -d /opt/android-sdk-linux -g android -u 1000 android

COPY tools /opt/tools

COPY licenses /opt/licenses

WORKDIR /opt/android-sdk-linux

RUN /opt/tools/entrypoint.sh built-in

RUN /opt/android-sdk-linux/cmdline-tools/tools/bin/sdkmanager "cmdline-tools;latest"
RUN /opt/android-sdk-linux/cmdline-tools/tools/bin/sdkmanager "build-tools;${SDK_VERSION}"
RUN /opt/android-sdk-linux/cmdline-tools/tools/bin/sdkmanager "platform-tools"
RUN /opt/android-sdk-linux/cmdline-tools/tools/bin/sdkmanager "platforms;android-30"
RUN /opt/android-sdk-linux/cmdline-tools/tools/bin/sdkmanager "system-images;android-30;google_apis;x86_64"
RUN entrypoint.sh built-in

CMD /opt/tools/entrypoint.sh built-in
CMD entrypoint.sh built-in
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions licenses/android-googletv-license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

601085b94cd77f0b54ff86406957099ebe79c4d6
3 changes: 2 additions & 1 deletion licenses/android-sdk-license
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

8933bad161af4178b1185d1a37fbf41ea5269c55
d56f5187479451eabf01fb78af6dfcb131a6481e
24333f8a63b6825ea9c5514f83c2829b004d1fee
2 changes: 1 addition & 1 deletion licenses/android-sdk-preview-license
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

84831b9409646a918e30573bab4c9c91346d8abd
84831b9409646a918e30573bab4c9c91346d8abd
2 changes: 2 additions & 0 deletions licenses/google-gdk-license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

33b6a2b64607f11b759f320ef9dff4ae5c47d97a
2 changes: 2 additions & 0 deletions licenses/mips-android-sysimage-license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

e9acab5b5fbb560a72cfaecce8946896ff6aab9d
20 changes: 11 additions & 9 deletions tools/android-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ export ANDROID_SDK_ROOT=${ANDROID_HOME}
export ANDROID_SDK_HOME=${ANDROID_HOME}
export ANDROID_SDK=${ANDROID_HOME}

export PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin
export PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/tools/bin
export PATH=${PATH}:${ANDROID_HOME}/tools/bin
export PATH=${PATH}:${ANDROID_HOME}/build-tools/34.0.0
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/emulator
export PATH=${PATH}:${ANDROID_HOME}/bin
export PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/emulator:${ANDROID_HOME}/bin:

if [[ ! -z "$http_proxy" ]] || [[ ! -z "$https_proxy" ]]; then
export JAVA_OPTS="-Djava.net.useSystemProxies=true $JAVA_OPTS -Dhttp.noProxyHosts=${no_proxy}"
# This only works if there is a proxy listening on docker host machine and
# container is started with --net=host. No other options for now. Thanks
# google....
export SDKMNGR_OPTS=" --proxy=http --proxy_host=127.0.0.1 --proxy_port=3128 --no_https "
fi

function print_header() {
figlet SBB CFF FFS
Expand All @@ -34,15 +36,15 @@ function help() {
}

function update_sdk() {
android-accept-licenses.sh "sdkmanager --update"
android-accept-licenses.sh "sdkmanager ${SDKMNGR_OPTS} --update"
}

function andep() {
if [ -z ${1} ]; then
help
return 1
fi
android-accept-licenses.sh "sdkmanager ${1}"
android-accept-licenses.sh "sdkmanager ${SDKMNGR_OPTS} ${1}"
}

export -f help
Expand Down
43 changes: 27 additions & 16 deletions tools/android-sdk-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ source /opt/android-sdk-linux/bin/android-env.sh

built_in_sdk=1


echo $#

echo $1

if [ $# -ge 0 ] && [ "$1" == "lazy-dl" ]
then
echo "Using Lazy Download Flavour"
Expand All @@ -27,16 +22,16 @@ fi
cd ${ANDROID_HOME}
echo "Set ANDROID_HOME to ${ANDROID_HOME}"

if [ -f commandlinetools-linux.zip ]
if [ -f .bootstrapped ]
then
echo "SDK Tools already bootstrapped. Skipping initial setup"
echo "SDK Tools already bootstrapped. Skipping initial setup"
else
echo "Bootstrapping SDK-Tools"
wget -q https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip -O commandlinetools-linux.zip
unzip commandlinetools-linux.zip
mkdir cmdline-tools
mv tools cmdline-tools/
rm commandlinetools-linux.zip
echo "Bootstrapping SDK-Tools"
mkdir -p cmdline-tools/latest/ \
&& curl -sSL https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o sdk-tools-linux.zip \
&& bsdtar xvf sdk-tools-linux.zip --strip-components=1 -C cmdline-tools/latest \
&& rm sdk-tools-linux.zip \
&& touch .bootstrapped
fi

echo "Make sure repositories.cfg exists"
Expand All @@ -50,16 +45,32 @@ echo "Copying Tools"
mkdir -p ${ANDROID_HOME}/bin
cp -v /opt/tools/*.sh ${ANDROID_HOME}/bin

echo "Print sdkmanager version"
sdkmanager --version


echo "Installing packages"
if [ $built_in_sdk -eq 1 ]
then
android-accept-licenses.sh "sdkmanager --package_file=/opt/tools/package-list-minimal.txt --verbose"
while read p; do
android-accept-licenses.sh "sdkmanager ${SDKMNGR_OPTS} ${p}"
done < /opt/tools/package-list-minimal.txt
else
android-accept-licenses.sh "sdkmanager --package_file=/opt/tools/package-list.txt --verbose"
while read p; do
android-accept-licenses.sh "sdkmanager ${SDKMNGR_OPTS} ${p}"
done < /opt/tools/package-list.txt
fi

echo "Updating SDK"
update_sdk

echo "Accepting Licenses"
android-accept-licenses.sh "sdkmanager --licenses --verbose"
android-accept-licenses.sh "sdkmanager ${SDKMNGR_OPTS} --licenses"

# https://stackoverflow.com/questions/35128229/error-no-toolchains-found-in-the-ndk-toolchains-folder-for-abi-with-prefix-llv
if [ -d /opt/android-sdk-linux/ndk-bundle/toolchains ]
then
( cd /opt/android-sdk-linux/ndk-bundle/toolchains \
&& ln -sf aarch64-linux-android-4.9 mips64el-linux-android \
&& ln -sf arm-linux-androideabi-4.9 mipsel-linux-android )
fi
2 changes: 1 addition & 1 deletion tools/android-wait-for-emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ until [[ "${bootcomplete}" =~ "1" ]]; do
if [[ ${failcounter} -gt ${maxfail} ]]; then
echo "Timeout ($timeout seconds) reached; failed to start emulator"
while pkill -9 "emulator" >/dev/null 2>&1; do
echo "Killing emulator proces...."
echo "Killing emulator process...."
pgrep "emulator"
done
echo "Process terminated"
Expand Down
9 changes: 2 additions & 7 deletions tools/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ function su_mt_user() {

chown android:android /opt/android-sdk-linux

printenv

if checkbin; then
exec su-exec android:android /opt/tools/android-sdk-update.sh "$@"
else
su_mt_user /opt/tools/android-sdk-update.sh ${1}
fi







21 changes: 11 additions & 10 deletions tools/package-list-minimal.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
add-ons;addon-google_apis-google-26
add-ons;addon-google_apis-google-27
build-tools;26.0.3
build-tools;27.0.0
cmake;3.6.4111459
build-tools;32.0.0
build-tools;33.0.2
build-tools;34.0.0
cmake
emulator
extras;android;gapid;1
extras;android;gapid;3
extras;android;m2repository
extras;google;auto
Expand All @@ -15,9 +13,12 @@ extras;google;market_apk_expansion
extras;google;market_licensing
extras;google;simulators
extras;google;webdriver
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2
lldb;2.3
platforms;android-26
platforms;android-27
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2
lldb
ndk-bundle
platform-tools
platforms;android-32
platforms;android-33
platforms;android-34
tools
Loading

0 comments on commit 5b5c699

Please sign in to comment.