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.

126 lines
4.6 KiB

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