Last active
September 28, 2025 10:32
-
-
Save 0x384c0/48fa4be21c29b61fd9b1fda5f8f0184d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| # Ubuntu 18.04 | |
| AOSP_TARGET=sdk_phone_x86_64 | |
| AOSP_DIR="$HOME/aosp_build/android9" | |
| echo "Installing required packages..." | |
| sudo apt-get update | |
| sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig | |
| echo "Setting up git-repo..." | |
| TMP_DIR=$(mktemp -d) | |
| git clone --depth 1 --branch v2.56 [email protected]:GerritCodeReview/git-repo.git "$TMP_DIR/git-repo" | |
| mkdir -p ~/bin | |
| cp "$TMP_DIR/git-repo/repo" ~/bin/ | |
| export PATH=~/bin:$PATH | |
| rm -rf "$TMP_DIR" | |
| echo "Syncing AOSP source..." | |
| cd ~/Downloads | |
| mkdir -p $AOSP_DIR | |
| cd $AOSP_DIR | |
| repo init -u https://android.googlesource.com/platform/manifest -b android-security-9.0.0_r76 --depth=1 | |
| repo sync -c -j$(($(nproc)/2)) | |
| echo "Building AOSP..." | |
| source build/envsetup.sh | |
| lunch $AOSP_TARGET | |
| make -j$(($(nproc)/2)) sdk sdk_repo | |
| echo "Editing XML..." | |
| cd ./out/host/linux-x86/sdk/$AOSP_TARGET | |
| XML_FILE="repo-sys-img.xml" | |
| sed -i \ | |
| -e 's#<sdk:tag-id>.*</sdk:tag-id>#<sdk:tag-id>android</sdk:tag-id>#' \ | |
| -e 's#<sdk:host-os>.*</sdk:host-os>#<sdk:host-os>windows</sdk:host-os>#' \ | |
| -e 's#<sdk:description>.*</sdk:description>#<sdk:description>▇Custom Android SDK System Image▇</sdk:description>#' \ | |
| -e 's#<sdk:tag-display>.*</sdk:tag-display>#<sdk:tag-display>▇Custom Android System Image▇</sdk:tag-display>#' \ | |
| "$XML_FILE" | |
| echo "Starting HTTP server..." | |
| python3 -m http.server 8000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:18.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV AOSP_TARGET=sdk_phone_x86_64 | |
| ENV AOSP_DIR=/root/aosp_build/android9 | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends \ | |
| git-core gnupg flex bison build-essential zip curl zlib1g-dev \ | |
| libc6-dev-i386 x11proto-core-dev libx11-dev lib32z1-dev \ | |
| libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig \ | |
| python3 && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Install git-repo tool | |
| RUN mkdir -p /root/bin && \ | |
| git clone --depth 1 --branch v2.56 https://github.com/GerritCodeReview/git-repo.git /tmp/git-repo && \ | |
| cp /tmp/git-repo/repo /root/bin/ && \ | |
| rm -rf /tmp/git-repo | |
| ENV PATH="/root/bin:${PATH}" | |
| # Prepare build directories and get AOSP | |
| WORKDIR /root/aosp_build | |
| RUN mkdir -p /root/Downloads && \ | |
| cd /root/Downloads && \ | |
| mkdir -p $AOSP_DIR && \ | |
| cd $AOSP_DIR && \ | |
| repo init -u https://android.googlesource.com/platform/manifest -b android-security-9.0.0_r76 --depth=1 && \ | |
| repo sync -c -j$(($(nproc)/2)) | |
| WORKDIR /root/aosp_build/android9 | |
| # Build AOSP | |
| RUN bash -c "source build/envsetup.sh && lunch $AOSP_TARGET && make -j$(($(nproc)/2)) sdk sdk_repo" | |
| # Edit XML as described in script | |
| RUN cd ./out/host/linux-x86/sdk/$AOSP_TARGET && \ | |
| XML_FILE="repo-sys-img.xml" && \ | |
| sed -i \ | |
| -e 's#<sdk:tag-id>.*</sdk:tag-id>#<sdk:tag-id>android</sdk:tag-id>#' \ | |
| -e 's#<sdk:host-os>.*</sdk:host-os>#<sdk:host-os>windows</sdk:host-os>#' \ | |
| -e 's#<sdk:description>.*</sdk:description>#<sdk:description>▇Custom Android SDK System Image▇</sdk:description>#' \ | |
| -e 's#<sdk:tag-display>.*</sdk:tag-display>#<sdk:tag-display>▇Custom Android System Image▇</sdk:tag-display>#' \ | |
| "$XML_FILE" | |
| WORKDIR /root/aosp_build/android9/out/host/linux-x86/sdk/$AOSP_TARGET | |
| EXPOSE 8000 | |
| CMD ["python3", "-m", "http.server", "8000"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment