My motivation 2017-04 for building my own "Android" was, there is no official build for the Sony Z1 from LinegeOS, the only available inofficial build is from 2016-12 and the last offcial build from CynogenMod is from 2016-10.
First you need the "repo" tool from google, which is a xk line python code wrapper for single git commands.
You should store it in directory which is in
PATH variable. e.b.
Storing it in another place and calling
python $yourpathtotherepofile/repo does not work, because some scripts call it too.
Decide where to store the data (~53GB for cm-14.1) and change dir to this new empty directory. Initialize the repo and sync. How long you must wait for the sync depends on your internet connection speed.
Maybe you will now copy or backup these unmodified Data.
repo init -u git://github.com/LineageOS/android.git -b cm-14.1 repo sync
Prepare code. You need to know your codename of your phone! Try wikipedia or the lineageos wiki if you don't. e.g. mako for the nexus4. You can use this to try if everything ist working with an official supported device.
source build/envsetup.sh breakfast $codename
Extract firmwares. Connect your phone and allow adb debug and root for adb in your current running android.
You will find the files in
export codename=mako # codename of your phone cd device/$vendor/$codename ./extract-files.sh adb kill-server cd ../../../
Now you can try to build it. You need at least 10GiB Ram (8GiB with the same size for swap will work to)
unset _JAVA_OPTIONS export USE_CCACHE=1 prebuilts/misc/linux-x86/ccache/ccache -M 50G source build/envsetup.sh croot export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g" prebuilts/sdk/tools/jack-admin start-server brunch $codename
you need to revert
hardware/qcom/audio/default/hal/audio_extn/utils.c:150:25: error: use of undeclared identifier 'HFP_ASM_RX_TX' pcm_device_id = HFP_ASM_RX_TX;
LineageOS/android_hardware_qcom_audioto commit ad6c9e57400481166783c8023c8f7f3c2d79045f