====== Information ======
* Custom builds of LineageOS for the Nexus 6
* lineage-15.0 branch
===== Prerequisites =====
* [[distros:fedora_workstation_gnome | Fedora Workstation]]
====== xda-developers ======
* https://forum.xda-developers.com/nexus-6/development/rom-lineageos-easy-microg-unifiednlp-t3632360
====== Dependencies ======
****
sudo dnf install java-1.8.0-openjdk-devel ImageMagick-devel patch ncurses-compat-libs schedtool libstdc++.i686 glibc.i686 m4 xz-lzma-compat gcc && sync
====== Prepare Build Environment ======
===== Cleanup =====
****
cd ~ && sudo rm -Rf ~/'android/lineage-15.0/'* ~/'.ccache' ~/'.jack-server' ~/'.jack-settings' && sync
===== Install git-repo =====
* https://code.google.com/archive/p/git-repo
mkdir -p ~/'bin' && wget -O ~/'bin/repo' 'https://storage.googleapis.com/git-repo-downloads/repo' && chmod +x ~/'bin/repo'
===== Configure Git =====
nano ~/'.gitconfig'
[user]
email = espionage724@x
name = Sean Lynn Rhone
[color]
ui = auto
===== Initialize Repo =====
****
mkdir -p ~/'android/lineage-15.0' && cd ~/'android/lineage-15.0' && repo init --manifest-url='https://github.com/LineageOS/android.git' --manifest-branch='lineage-15.0' --depth=1 && sync
===== Motorola Manifest =====
* If pulling in fresh sources, do not add this until the sources are backed-up ((that way the backup can be a clean-slate and be used for other non-Moto devices))
==== cm-14.1 ====
mkdir -p ~/'android/lineage-15.0/.repo/local_manifests' && nano ~/'android/lineage-15.0/.repo/local_manifests/motorola.xml'
==== lineage-15.0 ====
* As of 2017/10/29, this is behind the ''cm-14.1'' branch for some reason ((refer to [[https://github.com/TheMuppets/proprietary_vendor_motorola/branches | branches]]))
mkdir -p ~/'android/lineage/.repo/local_manifests' && nano ~/'android/lineage/.repo/local_manifests/motorola.xml'
===== Sources Management =====
==== Pull-in and Update Sources ====
=== Network Sync ===
* As of 2017/10/29, this downloads 11.3GB for ''lineage-15.0''
* If pulling fresh sources, this command is good to leave running overnight, and then followed up with a [[#backup_sources | backup]]
cd ~/'android/lineage-15.0' && repo sync --current-branch --network-only --jobs='4' --force-broken --force-sync && sync
=== Complete Sync ===
* Performs both Network and Local file sync
cd ~/'android/lineage-15.0' && repo sync --current-branch --network-only --jobs='4' --force-broken --force-sync && sync && repo sync --current-branch --local-only --jobs='16' && sync
==== Backup Sources ====
****
cd ~/'android/lineage-15.0' && tar -cvzf ~/'Downloads/lineageos-lineage-15.0-'$(date +%Y-%m-%d)'.tar.gz' '.repo' && cd ~ && sync
==== Restore Sources ====
****
mkdir -p ~/'android/lineage-15.0' && cd ~/'android/lineage-15.0' && tar -xvzf ~/'Downloads/lineageos-lineage-15.0-'*'.tar.gz' '.repo' && sync
====== Modifications ======
===== Allow Signature Spoofing =====
* This allows **microG Services Core** and **FakeStore** to fake GApps properly
* https://github.com/FreeMobileOS/android_packages_apps_GmsCore/blob/20c65a1fc33ee28ae0d12a927bd243d4ee2e3abc/patches/android_frameworks_base-O.patch
* Keep eyes on https://github.com/microg/android_packages_apps_GmsCore/pull/418 for when this is officially merged
wget -O ~/'Downloads/GmsCore-android_frameworks_base-O.patch' 'https://raw.githubusercontent.com/FreeMobileOS/android_packages_apps_GmsCore/20c65a1fc33ee28ae0d12a927bd243d4ee2e3abc/patches/android_frameworks_base-O.patch' && cd ~/'android/lineage-15.0' && patch --no-backup-if-mismatch --strip='1' --directory='frameworks/base' < ~/'Downloads/GmsCore-android_frameworks_base-O.patch' && rm -f ~/'Downloads/GmsCore-android_frameworks_base-O.patch' && sync
===== Allow Location Providers Outside /system =====
* https://github.com/microg/android_packages_apps_UnifiedNlp/blob/master/patches/android_frameworks_base-N.patch
* This allows ** microG Services Core** to provide **UnifiedNlp** without having to be installed to ''/system/priv-app'' or having to have an outdated ''NetworkLocation.apk'' there
wget -O ~/'Downloads/UnifiedNlp-android_frameworks_base-N.patch' 'https://raw.githubusercontent.com/microg/android_packages_apps_UnifiedNlp/master/patches/android_frameworks_base-N.patch' && cd ~/'android/lineage-15.0' && patch --no-backup-if-mismatch --strip='1' --directory='frameworks/base' < ~/'Downloads/UnifiedNlp-android_frameworks_base-N.patch' && rm -f ~/'Downloads/UnifiedNlp-android_frameworks_base-N.patch' && sync
===== Remove Deprecated HWUI GCC Flag =====
* https://github.com/ValidusOs/frameworks_base/commit/f6e00f8ffba193ebe4b67da8a00b9122ff55ed73
* Removes the deprecated ''-mapcs'' flag and prevents clang++ from reporting an error about it later on
* Only has effect and needed if ''HWUI_COMPILE_FOR_PERF'' is ''true''
sed -i 's/-marm -mapcs/-marm/g' ~/'android/lineage-15.0/frameworks/base/libs/hwui/Android.mk'
===== Avoid GNSS denials =====
* https://github.com/elektroschmock/android_device_moto_shamu/commit/df314065c2f02cdfef2006b623dabc71049a2375
echo 'allow hal_gnss_default vndbinder_device:chr_file rw_file_perms;' | tee --append ~/'android/lineage-15.0/device/moto/shamu/sepolicy/hal_gnss_default.te' > '/dev/null'
===== Tweaks =====
* If this file doesn't exist, this is likely being ran on fresh sources, and requires [[#breakfast | breakfast]] to be served first
* Place this at the **top** of the file underneath the copyright ((this ensures the custom ''PRODUCT_PROPERTY_OVERRIDES'' are used, [[https://groups.google.com/d/msg/android-building/Y8Z1hWqL0lY/1NytPiDGg9oJ | see comment]]))
nano ~/'android/lineage-15.0/device/moto/shamu/device.mk'
# Begin Custom Stuff
# Dalvik/ART Tweaks
PRODUCT_PROPERTY_OVERRIDES += \
dalvik.vm.image-dex2oat-filter=everything \
dalvik.vm.dex2oat-filter=everything \
dalvik.vm.check-dex-sum=false \
dalvik.vm.checkjni=false \
dalvik.vm.usejit=true \
dalvik.vm.dexopt-flags=v=a,o=v \
dalvik.vm.dex2oat-swap=false \
dalvik.vm.dex2oat-threads=4 \
dalvik.vm.boot-dex2oat-threads=4 \
dalvik.vm.image-dex2oat-threads=4 \
dalvik.vm.heaptargetutilization=0.9 \
dalvik.vm.heapgrowthlimit=288m
# Single-user
PRODUCT_PROPERTY_OVERRIDES += \
fw.max_users=1
# HWUI Performance Compiler Options
HWUI_COMPILE_FOR_PERF := true
# Graphics Tweaks
PRODUCT_PROPERTY_OVERRIDES += \
debug.hwui.renderer=skiagl \
persist.sys.ui.hw=true
# Native Density
PRODUCT_PROPERTY_OVERRIDES += \
ro.sf.lcd_density=493
# Freedom
PRODUCT_PROPERTY_OVERRIDES += \
persist.sys.hdcp_checking=never
# End Custom Stuff
===== Steven Black's Unified Hosts File =====
* https://github.com/StevenBlack/hosts
* Includes ''fakenews'' and ''gambling'' extensions
rm -Rf '/tmp/master.zip' '/tmp/hosts-master' && wget 'https://github.com/StevenBlack/hosts/archive/master.zip' -O '/tmp/master.zip' && unzip '/tmp/master.zip' -d '/tmp' && python3 '/tmp/hosts-master/updateHostsFile.py' --auto --extensions 'fakenews' 'gambling' --output ~/'android/lineage-15.0/system/core/rootdir/etc' && rm -Rf '/tmp/master.zip' '/tmp/hosts-master' && sync
===== Don't Check Device in TWRP =====
* https://review.lineageos.org/#/c/186687/
repopick '186687'
====== Build Prep ======
===== Cleanup =====
****
cd ~/'android/lineage-15.0' && make 'clobber' && sync
===== Set-up Environment =====
****
cd ~/'android/lineage-15.0' && source ~/'android/lineage-15.0/build/envsetup.sh'
===== Breakfast! =====
* Be sure to run [[#tweaks | Tweaks]] after serving ''breakfast'' if using fresh sources
cd ~/'android/lineage-15.0' && breakfast 'shamu' && sync
===== Environment Variables =====
==== Disable ccache ====
****
unset 'CCACHE_DISABLE' && export 'CCACHE_DISABLE=1'
==== Jack ====
****
unset 'ANDROID_JACK_VM_ARGS' && export 'ANDROID_JACK_VM_ARGS=-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx12G'
====== Signed Build ======
===== Key Management =====
==== Generate ====
* Change the ''x'' in ''emailAddress=''
* If a backup exists and is being restored, don't run this
subject='/C=US/ST=Pennsylvania/L=Charleroi/O=Realm of Espionage/OU=Android/CN=Sean Lynn Rhone/emailAddress=espionage724@x' && mkdir ~/'.android-certs' && for x in releasekey platform shared media; do ~/'android/lineage-15.0/development/tools/make_key' ~/'.android-certs'/$x "$subject"; done
==== Backup ====
****
cd ~ && tar -cvzf ~/'Downloads/android-certs-'$(date +%Y-%m-%d)'.tar.gz' '.android-certs' && sync
==== Restore ====
****
cd ~ && tar -xvzf ~/'Downloads/android-certs-'*'.tar.gz' '.android-certs' && rm -f ~/'Downloads/android-certs-'*'.tar.gz' && sync
===== Build =====
* This takes approximately 1 hour and 25 minutes to complete
* If ''mka'' can't be found, make sure this is being ran from the Terminal window where previous commands took place
cd ~/'android/lineage-15.0' && mka target-files-package dist && sync
===== Sign Build =====
****
croot && ~/'android/lineage-15.0/build/tools/releasetools/sign_target_files_apks' -o -d ~/'.android-certs' ~/'android/lineage-15.0/out/dist/'*'-target_files-'*'.zip' ~/'android/lineage-15.0/signed-target_files.zip' && sync
===== Generate Zip =====
****
~/'android/lineage-15.0/build/tools/releasetools/ota_from_target_files' -k ~/'.android-certs/releasekey' --block --backup='true' ~/'android/lineage-15.0/signed-target_files.zip' ~/'Downloads/'$(date +%m-%d)'-oreo-los-N6-esp724.zip' && sync
===== Install Zip =====
* Flash ''~/Downloads/lineageos-lineage-15.0-shamu-unofficial-(date).zip''
====== Unsigned Build ======
===== Build and Generate Zip =====
* This takes approximately 1 hour to complete
cd ~/'android/lineage-15.0' && croot && brunch 'shamu' && sync
===== Install Zip =====
* Flash the 400MB+ zip found in ''~/'android/lineage-15.0/out/target/product/shamu''
====== Nexus 6 Configuration ======
* [[android;motorola_google_nexus_6_shamu|Proceed here]]
====== Changelog ======
===== Notes =====
* Unless otherwise specified, all uploaded builds are updated from the source (resync) prior to building
===== Changelog =====
* 2017/11/02: Re-enable forced-encryption, simplify zip filename
* 2017/11/01: Disable forced-encryption, vndbinder sepolicy fix, more Dalvik/ART tweaks, HWUI compiled in performance mode, disable HDCP checking, force 2D GPU acceleration, use Skia OpenGL rendering
* 2017/10/29: Initial build, Dalvik/ART tweaks, disabled multi-user