[Moto G 4G Android Development] sdembiske:
How to build & update this rom yourself: Updated for Ubuntu 20.04+ based systems.

For those members wishing to build this rom for themselves and keep it updated, The following roomservice.xml file is what I've been using (forked from sevenrock's github site (https://github.com/sevenrock) - full credit to him:

<?xml version="1.0" encoding="UTF-8"?>

<manifest>

<project name="sdembis/android_device_motorola_peregrine" path="device/motorola/peregrine" remote="github" revision="lineage-16.0" />

<project name="sdembis/android_device_motorola_msm8226-common" path="device/motorola/msm8226-common" remote="github" revision="lineage-16.0" />

<project name="sdembis/android_kernel_motorola_msm8226" path="kernel/motorola/msm8226" remote="github" revision="lineage-16.0" />

<project name="sdembis/proprietary_vendor_motorola" path="vendor/motorola"

remote="github" revision="lineage-16.0" />

<project name="LineageOS/android_system_qcom" path="system/qcom" remote="github" revision="lineage-16.0" />

<project name="LineageOS/android_packages_resources_devicesettings" path="packages/resources/devicesettings" remote="github" revision="lineage-16.0"/>

</manifest>

* Follow the directions from here for setting up the build environment: Build for peregrine

- * Do not go any further in setting up your build environment than the paragraph including the Configure git instructions. After setting up the git configuration, ignore the rest of the instructions posted there and follow the guide posted here.

Note

: If Building on an Ubuntu 20.04 (e.g., Linux Mint 20.0) or newer based Linux versions show the content of the following:

To get around all the errors I encountered I had to do the following:

In the "Software Manager" confirm all the following are installed to check your installation method

- openjdk-8-jdk

- openjdk-8-jdk-headless

- openjdk-8-jre

- openjdk-8-jre-headless

with no environment path or any other path you might have set for Java.

Use the Switch Manager command to set Python2 as the default version (refer to this how to - https://linuxconfig.org/ubuntu-20-04-python-version-switch-manager)

Insert (if not already included) export LC_ALL=C and export CCACHE_EXEC=/usr/bin/ccache in, save it and source it for the /.bashrc file.

If you haven't already done so, make sure you install the additional language packs noted in the System Reports.

That should get you going to successfully build for LineageOS on any Ubuntu 20.04 based system.

Recommended

:

- Seriously consider installing Linux Mint - Xfce (for example),

in a dual-boot set-up

before setting up your build environment. Your builds will run much faster with fewer problems versus setting up your build environment in VirtualBox!

- add an 8GB swap file (particularly important if running low ram, e.g., 4GB).

Once you've set up the android build environment,

initialize the LineageOS source repository

inside a new folder labelled, for example, LineageOS_16.0 with the following command:

repo init -u git://github.com/LineageOS/android.git -b lineage-16.0

To add the roomservice.xml file above to the .repo folder (

Note

: if the .repo folder is not visible in your LineageOS_16.0 folder after initializing, try Ctrl H to make it visible):

- make a new folder inside the .repo folder and label the new folder: local_manifests

- create an empty document inside the local_manifests folder and label it roomservice.xml

- copy the roomservice.xml file contents exactly as above and paste it into the document, making sure you save it.

Then, in the LineageOS_16.0 folder, open a command prompt, type the following and enter it:

repo sync --force-sync -c -j1

(

Note

: j1 can be a higher number depending on the number of cores your processor has - the default is j4 but I have had the fewest problems using j1 initially if trying to build with lower ram).

Recomended

:

- Turn on caching to speed up your builds:

export USE_CCACHE=1 (

add the line to your ~/.bashrc file

using this command, for example: sudo nano ~/.bashrc to open the file, before adding the line and saving it). Then update your environment using this command: source ~/.profile

- In the LineageOS_14.1 folder you created open a command prompt and type & enter the following:

prebuilts/misc/linux-x86/ccache/ccache -M 50G this will permanently set your cache to 50GB and speed up your builds hugely. Only has to be done once.

- Configure Jack by adding this as well to your ~/.bashrc file, the same way that you set up using ccache:

export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xms8G -Xmx8G. Then update your environment using this command: source ~/.profile. Adjust the -Xms8G -Xmx8G if trying to build with lower ram (e.g., 4GB). I'm currently running 20GB ram (shortly going to 24) and use 8GB for these particular commands.

-

Note

: If running very low ram (Not recommended as you will likely have problems or fail to complete the build, but if trying to build with, e.g., 4 GB), set jack.server.max-service=1 in the .jack-server folder in /home/"user-name"/.jack-server/config.properties (open the config.properties file with a text editor, make the change and save it). The default is jack.server.max-service=4.

* If experiencing out of memory issues/stalls etc. building with jack-server/Java

and

you have a swap file/partition seriously consider enabling ZSWAP with lz4 compression - refer to this excellent how-to and follow it exactly: http://grimore.org/linux/zswap

Then to build the rom, use the following commands in the LineageOS_16.0 folder, separately in order:

. build/envsetup.sh && croot - then, when it's completed

brunch peregrine - where the rom build actually takes place

Your rom zip file will be found in the out > target > product > peregrine folder in your LineageOS_16.0 folder.

Once you've completed a successful build refer to the following to learn how to update the critical security patches by thealaskalinuxuser: How to manually update your custom rom source code with security updates - as I mentioned above in my previous post, it's not that difficult a process but you do have to build the rom again and test it to make sure all is in order.

To do another build when a new security patch is posted, run the make clobber command in the LineageOS_16.0 folder to clean out the previous build and the ccache -c command to clean-up the ccache build-up before running the repo-sync --force-sync - c -j1 command again, then check the security patch date (in /build/core/version_defaults.mk) and, only if needed and you cannot repopick the security patch topic from the LineageOS Gerrit site, add the security additions/deletions (copy and paste the additions, removing the + signs, and delete the subtractions) to the relevant files and then run the build again with the . build/envsetup.sh && croot and brunch peregrine commands.