[Xiaomi Mi 9 Guides, News, & Discussion] DRG-developer:
so, since i had my share of troubles building LineageOS for the Mi 9 (codename cepheus), I thought i'd help you guys out with building.

I DO HAVE A COMPILED ZIP, BUT SINCE I DON'T HAVE THE POINTS TO POST IN THE ROM PART YET, I WILL NOT SHARE IT BECAUSE I DOUBT MODS WILL LIKE THAT. MODS, PLEASE SAY IF I CAN SHARE THE ZIP FILE.

if you want the zip, give me "thanks" or something so i can get the 10 required points. if you **really** (and only if you REALLY appreciate this, it is ABSOLUTELY NOT expected or required to do this) appreciate this because you couldn't get android to build for the life of it: https://paypal.me/drgdeveloper

prereqs: a powerful PC, or a lot of time (read 24h +), at LEAST 8gb ram. on my dell poweredge (144gb ram, 2x Xeon X5650 (6 cores, 12 threads @ 2.66ghz)) it took over 4 hours (using over 40gb ram and 24 thread compilation). and 120gb + space

first, get the platform tools and add them to your path;

#if you unzipped it in your home directory
export PATH=$PATH:$HOME/platform-tools

get these dependencies:

bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev

then get the android developer tools

#this wil put the tools in your home directory

mkdir ~/bin
curl [url]https://storage.googleapis.com/git-repo-downloads/repo[/url] > ~/bin/repo
#add it to your path
export PATH=$PATH:$HOME/bin

then set up git:

# you can safely leave this at default settings
git config --global user.email "you@example.com"
git config --global user.name "Your Name"

create your building directory:

mkidr ~/android/lineage
cd ~/android/lineage
repo init -u [url]https://github.com/LineageOS/android.git[/url] -b lineage-17.1

get the source code (this will take 4-24hrs depending on your internet speed, you can safely stop this and resume later without losing time)

repo sync -c

NOTE: i got told that you should use repo sync -c to only get the current branches, if you have any issues with repo sync -c, then use repo sync without -c

Also, for faster downloads, if you have a decent internet speed, you can append -j and then a number. Pick a number that's between 2 and the amount of cpu cores you have. If your speed is above 100 mbit/s, just pick the amount of CPU cores (unless it's above 24 or something, then stick to 24).

So in , assuming you picked the number 4:

repo sync -c -j4

then create a local manifest for the mi 9 specific files:

cd ~/android/lineage/.repo

#this may already exist
mkdir local_manifests
cd local_manifests
touch cepheus.xml

edit cepheus.xml with your preferred text editor, and paste this

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

<manifest>
<project name="drg-developer/device_xiaomi_sm8150-common" path="device/xiaomi/sm8150-common" remote="github" revision="lineage-17.1"/>
<project name="drg-developer/device_xiaomi_cepheus" path="device/xiaomi/cepheus" remote="github" revision="lineage-17.1"/>
<project name="drg-developer/kernel_xiaomi_sm8150" path="kernel/xiaomi/sm8150" remote="github" revision="lineage-17.1"/>
<project name="drg-developer/vendor_xiaomi_sm8150-common" path="vendor/xiaomi/sm8150-common" remote="github" revision="lineage-17.1"/>
<project name="LineageOS/android_hardware_xiaomi" path="hardware/xiaomi" remote="github" revision="lineage-17.1"/>
<manifest>

these are the my personal mirrors or the files that i use, if you don't trust them, you can get most of them from Demon000, but not all (for example the vendor file because of DMCA takedown). so i gathered them all at one place. why? at one point i will become a trusted developer and then it's nice to have all the files at one place. (i don't have the required points yet to post in the rom part)

then type

repo sync

again.

after that, type

cd ~/android/lineage
source build/envsetup.sh

brunch lineage_cepheus-user

now this will take a LOONG time. sometimes the time will become red: just ignore that. only if the time is over 2 hours restart your pc. your pc will also most likely "freeze", just let it be.

and then you will wait tillit is finished. resolve any errors you have with common sense.

and now type:

cd $OUT
ls

you'll see a file called lineage-17.1-<DATE>-UNOFFICIAL-cepheus.zip. it's a flashable file. get the latest mauronofrio TWRP here: https://xdaforums.com/Mi-9/development/recovery-unofficial-twrp-xiaomi-mi-9-t3905825 and flash the twrp. then after that sideload the zip file, and, YOU DID IT!