2023-6-6 hongxi.zhu
从google下载对应的adb&fastboot工具安装包 [传送门],然后解压到家目录:
unzip platform-tools-latest-linux.zip -d ~
将adb&fastboot工具添加到系统PATH中, 这里是添加到~/.profile
:
# add Android SDK platform tools to path
if [ -d "$HOME/platform-tools" ] ; then
PATH="$HOME/platform-tools:$PATH"
fi
然后记得运行source ~/.profile
更新下系统环境变量。
sudo apt-get install
安装以下的依赖bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick
lib32ncurses5-dev lib32readline-dev lib32z1-dev libelf-dev liblz4-tool libncurses5 libncurses5-dev
libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync
schedtool squashfs-tools xsltproc
zip zlib1g-dev libwxgtk3.0-dev git-lfs
java -version
查看。python --version
查看。mkdir -p ~/bin
mkdir -p ~/android/lineage
~/bin
是用于存放repo
这个可执行文件的地方,如果没有这个目录就需要创建。
~/android/lineage
是存放我们源码文件的目录
~/bin
加到系统PATH路径中# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
然后记得运行source ~/.profile
更新下系统环境变量。
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
repo
需要是通过Git
的方式去拉取源码,所以我们这里需要配置Git
的信息。
git config --global user.email "[email protected]"
git config --global user.name "hongxi.zhu"
cd ~/android/lineage
repo init -u https://github.com/LineageOS/android.git -b lineage-20.0 --git-lfs
repo sync
这里线程数默认是4,如果加-j
, 一定要小于8,推荐4~8, 因为LineageOS大部分是去拉AOSP的仓库,Google每个IP限制8个线程,超过就禁止连接,同步失败,由于时差,国内白天时,全球拉取的人数少,拉取速度快于晚上。
代码同步结束还不能直接编译,需要拉取对应的device仓库
、kernel仓库
、设备闭源文件
以及必需的其他模块
。
Pixel 2XL的device仓库
cd ~/android/lineage/device/google/
git clone https://github.com/LineageOS/android_device_google_taimen.git taimen -b lineage-20
这里有个坑,因为Pixel 2XL(代号taimen
)是从Pixel 2派生的,它们开发在Google内部有个共同代码叫wahoo
, taimen
很多文件都是引用了wahoo
,所以我们还需要拉取wahoo
device[仓库],否则编译将缺少很多文件。
cd ~/android/lineage/device/google/
git clone https://github.com/LineageOS/android_device_google_wahoo.git wahoo -b lineage-20
Pixel 2和Pixel 2XL都是使用wahoo的内核源码,所以需要直接拉取wahoo内核仓库。
cd ~/android/lineage/kernel/google
git clone https://github.com/LineageOS/android_kernel_google_wahoo wahoo -b lineage-20
ElmyraService
模块仓库ElmyraService
是Google更新的关于手势的开源仓库,lineage没有及时纳入到Pixel 2XL 的device更新,所以需要我们手动导入这个模块,也是一个坑点之一,仓库地址。
cd ~/android/lineage/packages/apps
git clone https://github.com/LineageOS/android_packages_apps_ElmyraService ElmyraService -b lineage-20.0
注意这个仓库的分支和上面的不一样。
Pixel 2XL Google也是有一些文件,处于vendor分区的,并不开源,我们需要从已经刷入相同Lineage 20的Pixel 2XL中通过adb pull
拉取, 这里具体怎么拉取,拉取那几个文件Lineage已经帮我们写成了一个快捷脚本extract-files.sh
, 使用方法:
adb root
cd ~/android/lineage/device/google/taimen
./extract-files.sh
拉取成功后,文件将会在~/android/lineage/vendor/google/taimen
目录下
cd ~/android/lineage
source build/envsetup.sh
breakfast taimen
brunch taimen
无论是下载官方的文件还是自己编译的,需要烧录下面这几个文件:(如果是自编译在out目录下找到这几个文件)
产物 | 烧录方式 |
---|---|
lineage-20.0-20230601-nightly-taimen-signed.zip | recovery |
boot.img | fastboot |
dtbo.img | fastboot |
vbmeta.img | fastboot |
首先进入fastboot
模式
adb reboot fastboot
fastboot flash boot boot.img
fastboot flash dtbo dtbo.img
fastboot flash vbmeta vbmeta.img
然后通过音量键下+电源键选中进入Recovery模式
Factory reset -> Foramt data/factory reset
进行data分区的数据擦除Apply update - > Apply from ADB
adb sideload lineage-20.0-20230601-nightly-taimen-signed.zip
Reboot system now
参考:
https://wiki.lineageos.org/devices/taimen/build#create-the-directories
https://wiki.lineageos.org/devices/taimen/install
https://download.lineageos.org/devices/taimen/builds