|
|
- # NOTE NOTE NOTE
- # This is a very rough shell script file. Untested, and not intended to run in a single run. Just tells chronological order of necessary commands to compile Android OS on an Arch Linux system.
-
- # Ref: https://gist.github.com/ssz66666/8422d46eae83ce7240f5547d129bf29c
- # Ref: https://github.com/anbox/anbox/blob/master/docs/build-android.md
-
- ##################
-
- # Required: aosp-devel packages
- # https://aur.archlinux.org/packages/aosp-devel/
- ROOTDIR="${PWD}"
-
- WORKDIR="${PWD}/aosp"
-
- if [ ! -d "${WORKDIR}" ]]; then
- mkdir -p "${WORKDIR}"
- fi
-
- rm -rf "${WORKDIR}"/out/*
-
- ln -s /usr/bin/python2 ./python
- export PATH=$PWD:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
-
- cd "${WORKDIR}"
-
- #sudo pacman -S repo
-
- # Get & sync AOSP source code, shallow copy ~ 27.2 GB
- #
- repo init -u https://github.com/anbox/platform_manifests.git -b anbox --depth 1
- repo sync -j6 -c
-
- # Check manually all deps of AUR pkg aosp-devel are installed (/home/fincer/ssd/arch_linux_programs/aosp-devel)
-
- # Audio timing fix:
- # https://github.com/anbox/anbox/pull/1034
-
- # Web view fix:
- # https://github.com/anbox/anbox/pull/1875
-
- cp -f "${ROOTDIR}"/patch_audio01_timing.patch "${WORKDIR}"/vendor/
- cp -f "${ROOTDIR}"/patch_audio02_pass-messenger.patch "${WORKDIR}"/vendor/
- cp -f "${ROOTDIR}"/patch_fix-webview.patch "${WORKDIR}"/vendor/
-
- cp -f "${ROOTDIR}"/patch_initcgroups.patch "${WORKDIR}"/
-
- # Disable foreground/background activity checks and functionality of built-in Gallery apps for Desktop use
- # Comment onPause and onResume functions and related parts
- # This helps when using multiple apps simultaneosly and playing a video/music track. Originally,
- # playback pauses which is not a wanted feature in desktop Android. In this patch, we disable all relevant code
- # parts which cause this pause.
- cp -f "${ROOTDIR}"/patch_gallery2_no-activity-checks.patch "${WORKDIR}"/
-
- cd "${WORKDIR}"/vendor/anbox
- patch -Np1 -i ../patch_audio01_timing.patch
- patch -Np1 -i ../patch_audio02_pass-messenger.patch
- patch -Np1 -i ../patch_fix-webview.patch
- cd "${WORKDIR}"
-
- # We don't have several cgroups in native Linux. Avoid unnecessary kernel errors.
- # Disabled 'schedtune' cgroup as it targets Android ARM devices. Reason for it is to
- # add more efficient CPU usage. However, native Linux kernel does not populate
- # cgroup subsystem 'schedtune', and we see complaints about that in dmesg output.
- # This image has modified /init.rc file with commented out lines related to schedtune
-
- # Additional cgroups have been also commented out in the same file to avoid kernel complaints
- # 'Need name or subsystem set'
- patch -Np1 -i ./patch_initcgroups.patch
-
- # Already merged, as of 6th June 2020
- #
- # Server side decoration fix:
- # https://github.com/anbox/anbox/pull/1415
- #ln -s patch_serversidedecoration.patch aosp/vendor/patch_serversidedecoration.patch
-
- patch -Np1 -i ./patch_gallery2_no-activity-checks.patch
-
- # archlinux-java set java-8-openjdk
-
-
- cd "${WORKDIR}"
-
- source build/envsetup.sh
- lunch anbox_x86_64-userdebug
-
- export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx2G"
-
- # RUN THIS IN SEPARATE SHELL!
- # Jack server must be run during compilation process
- while true; do
- sleep 2
- if [ -f aosp/out/host/linux-x86/bin/jack-admin ]; then
- aosp/out/host/linux-x86/bin/jack-admin start-server
- break
- fi
- done
-
- LC_ALL=C make -j$(nproc --ignore 1)
-
- # Takes ~3 hours to compile with 11 CPU cores
-
- if [[ $? -eq 0 ]]; then
- rm -f $HOME/.jack-settings
- rm -rf $HOME/.jack-server
- fi
-
- # Once compiled, do the following:
-
- cd "${WORKDIR}"/vendor/anbox/
- scripts/create-package.sh ${PWD}/../../out/target/product/x86_64/ramdisk.img ${PWD}/../../out/target/product/x86_64/system.img
- # This image will locate at aosp/vendor/anbox/android.img
-
-
-
-
-
-
-
-
- # To compile a single element (e.g. a modified system app), use the following (example)
-
- # cd aosp
- # source build/envsetup.sh
- # mmma packages/apps/Gallery2/
-
- # For more information:
- # https://elinux.org/Android_Build_System
-
- # ----------
-
- # Copy all parts from aosp/out/target/product/x86_64/system/ into unsquashed android.img using rsync
- # Correct ownership of the copied files (chown ...) and squash the files into a new android.img file
-
- # Stop Anbox container & session managers by issuing
- # sudo systemctl stop anbox-container-manager (stops user session manager automatically)
-
- # Copy the new image file into /var/lib/anbox/android.img
-
- # Restart Anbox container & session managers by issuing
- # sudo systemctl start anbox-container-manager.service && sleep 3 && systemctl --user start anbox-session-manager
|