Custom Anbox installation files & patches, including patched Android OS image file.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
4.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. # NOTE NOTE NOTE
  2. # 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.
  3. # Ref: https://gist.github.com/ssz66666/8422d46eae83ce7240f5547d129bf29c
  4. # Ref: https://github.com/anbox/anbox/blob/master/docs/build-android.md
  5. ##################
  6. # Required: aosp-devel packages
  7. # https://aur.archlinux.org/packages/aosp-devel/
  8. ROOTDIR="${PWD}"
  9. WORKDIR="${PWD}/aosp"
  10. if [ ! -d "${WORKDIR}" ]]; then
  11. mkdir -p "${WORKDIR}"
  12. fi
  13. rm -rf "${WORKDIR}"/out/*
  14. ln -s /usr/bin/python2 ./python
  15. 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
  16. cd "${WORKDIR}"
  17. #sudo pacman -S repo
  18. # Get & sync AOSP source code, shallow copy ~ 27.2 GB
  19. #
  20. repo init -u https://github.com/anbox/platform_manifests.git -b anbox --depth 1
  21. repo sync -j6 -c
  22. # Check manually all deps of AUR pkg aosp-devel are installed (/home/fincer/ssd/arch_linux_programs/aosp-devel)
  23. # Audio timing fix:
  24. # https://github.com/anbox/anbox/pull/1034
  25. # Web view fix:
  26. # https://github.com/anbox/anbox/pull/1875
  27. cp -f "${ROOTDIR}"/patch_audio01_timing.patch "${WORKDIR}"/vendor/
  28. cp -f "${ROOTDIR}"/patch_audio02_pass-messenger.patch "${WORKDIR}"/vendor/
  29. cp -f "${ROOTDIR}"/patch_fix-webview.patch "${WORKDIR}"/vendor/
  30. cp -f "${ROOTDIR}"/patch_initcgroups.patch "${WORKDIR}"/
  31. # Disable foreground/background activity checks and functionality of built-in Gallery apps for Desktop use
  32. # Comment onPause and onResume functions and related parts
  33. # This helps when using multiple apps simultaneosly and playing a video/music track. Originally,
  34. # playback pauses which is not a wanted feature in desktop Android. In this patch, we disable all relevant code
  35. # parts which cause this pause.
  36. cp -f "${ROOTDIR}"/patch_gallery2_no-activity-checks.patch "${WORKDIR}"/
  37. cd "${WORKDIR}"/vendor/anbox
  38. patch -Np1 -i ../patch_audio01_timing.patch
  39. patch -Np1 -i ../patch_audio02_pass-messenger.patch
  40. patch -Np1 -i ../patch_fix-webview.patch
  41. cd "${WORKDIR}"
  42. # We don't have several cgroups in native Linux. Avoid unnecessary kernel errors.
  43. # Disabled 'schedtune' cgroup as it targets Android ARM devices. Reason for it is to
  44. # add more efficient CPU usage. However, native Linux kernel does not populate
  45. # cgroup subsystem 'schedtune', and we see complaints about that in dmesg output.
  46. # This image has modified /init.rc file with commented out lines related to schedtune
  47. # Additional cgroups have been also commented out in the same file to avoid kernel complaints
  48. # 'Need name or subsystem set'
  49. patch -Np1 -i ./patch_initcgroups.patch
  50. # Already merged, as of 6th June 2020
  51. #
  52. # Server side decoration fix:
  53. # https://github.com/anbox/anbox/pull/1415
  54. #ln -s patch_serversidedecoration.patch aosp/vendor/patch_serversidedecoration.patch
  55. patch -Np1 -i ./patch_gallery2_no-activity-checks.patch
  56. # archlinux-java set java-8-openjdk
  57. cd "${WORKDIR}"
  58. source build/envsetup.sh
  59. lunch anbox_x86_64-userdebug
  60. export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx2G"
  61. # RUN THIS IN SEPARATE SHELL!
  62. # Jack server must be run during compilation process
  63. while true; do
  64. sleep 2
  65. if [ -f aosp/out/host/linux-x86/bin/jack-admin ]; then
  66. aosp/out/host/linux-x86/bin/jack-admin start-server
  67. break
  68. fi
  69. done
  70. LC_ALL=C make -j$(nproc --ignore 1)
  71. # Takes ~3 hours to compile with 11 CPU cores
  72. if [[ $? -eq 0 ]]; then
  73. rm -f $HOME/.jack-settings
  74. rm -rf $HOME/.jack-server
  75. fi
  76. # Once compiled, do the following:
  77. cd "${WORKDIR}"/vendor/anbox/
  78. scripts/create-package.sh ${PWD}/../../out/target/product/x86_64/ramdisk.img ${PWD}/../../out/target/product/x86_64/system.img
  79. # This image will locate at aosp/vendor/anbox/android.img
  80. # To compile a single element (e.g. a modified system app), use the following (example)
  81. # cd aosp
  82. # source build/envsetup.sh
  83. # mmma packages/apps/Gallery2/
  84. # For more information:
  85. # https://elinux.org/Android_Build_System
  86. # ----------
  87. # Copy all parts from aosp/out/target/product/x86_64/system/ into unsquashed android.img using rsync
  88. # Correct ownership of the copied files (chown ...) and squash the files into a new android.img file
  89. # Stop Anbox container & session managers by issuing
  90. # sudo systemctl stop anbox-container-manager (stops user session manager automatically)
  91. # Copy the new image file into /var/lib/anbox/android.img
  92. # Restart Anbox container & session managers by issuing
  93. # sudo systemctl start anbox-container-manager.service && sleep 3 && systemctl --user start anbox-session-manager