下载SDK (包含adb等)

1
2
3
wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip -d ~
PATH="$HOME/platform-tools:$PATH"

安装依赖

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

Ubuntu 15.10 (wily) 需要lib32readline-gplv2-dev → lib32readline6-dev
Ubuntu 16.04 (xenial) 需要libwxgtk2.8-dev → libwxgtk3.0-dev

如果是LineageOS 11.0-13.0: 安装OpenJDK 1.7 (install openjdk-7-jdk)
如果是LineageOS 14.1: 安装OpenJDK 1.8 (install openjdk-8-jdk)

Ubuntu14 (16上有)上面没有jdk8的源,你需要添加

1
2
3
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-7-jdk

如果 sudo: add-apt-repository: command not found
运行sudo apt-get install software-properties-common
下载repo同步工具

1
2
3
4
5
6
7
8
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
mkdir -p ~/bin
mkdir -p ~/android/lineage
PATH="$HOME/bin:$PATH"
cd ~/android/lineage
repo init -u https://github.com/LineageOS/android.git -b cm-14.1
repo sync

貌似大概40G多

编译

1
2
3
4
5
6
7
8
source build/envsetup.sh
breakfast hammerhead0 #(这个换成你需要的设备名字)
export USE_CCACHE=1# 使用CCAHCE缓存加速编译
prebuilts/misc/linux-x86/ccache/ccache -M 50G
export CCACHE_COMPRESS=1
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
croot
brunch hammerhead

成功之后再out文件夹下
recovery.img ,这是LineageOS恢复映像。
lineage-14.1-xxx-hammerhead.zip ,它是LineageOS安装程序包。
参考
https://wiki.lineageos.org/devices/hammerhead/build#put-the-bin-directory-in-your-path-of-execution