逆寒手游活动资讯网

lineageOS编译环境及构建指南

本系列所有文章

lineageOS编译环境及构建指南最新LOS_gsi构建指南

你可以通过使用右下角的小齿轮,来开启黑夜模式和阅读模式。

如果你发现文章内容有错漏、你对文章内容有任何改进意见或者你阅读文章遇到了困难,都可以通过博客首页的邮箱联系我。

操作系统Debian12*需要root权限

【核心硬件建议:

CPU核心数:至少 8 核以上。性能优先级:多核性能 > 单核性能(编译过程高度并行化)。

内存(RAM)最低要求:16GB(勉强可用,但可能因设备代码量不同而频繁卡顿),需要扩展swap,不然进程会被kill。推荐配置:32GB 或更高(避免因内存不足导致编译中断)。

存储(硬盘)容量:至少 500GB 可用空间(源码 + 编译产物可能占用 300GB 以上,内存不够得开swap、后续加速编译要开ccache,也得个大几十GB)。类型:NVMe SSD(编译过程涉及大量文件读写,SSD 速度直接影响效率)。

操作系统官方支持:Debian Stable(如 本文档使用的就是Debian12)或 Ubuntu LTS(如 22.04/24.04)。其他系统:可尝试 Arch Linux 或 Fedora,但需自行解决依赖兼容性问题。尽量避免使用 Windows,WSL 2虽然可行,但性能和兼容性较差。】

云编译建议使用tmux,避免由于网络差丢失ssh连接,从而被杀进程。基础使用:

创建会话 tmux new -s ‘这里输入你想创建的会话名称’ 示例: tmux new -s lineage_build

若需要离开tmux窗口,先按 Ctrl+b再按d,即可退出会话

列出tmux后台会话进程,tmux ls

重新连接后进入tmux会话或者查看编译进度,tmux attach -t ‘这里输入你创建的会话名称’ 示例:tmux attach -t lineage_build

配置编译环境,安装软件包、编译依赖、编译工具以及同步lineageOS源代码sudo apt update && sudo apt upgrade -ysudo apt install -y bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick lib32ncurses-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.2-dev libxml2 libxml2-utils lzop maven pngcrush python3 python-is-python3 rsync schedtool squashfs-tools tmux unzip wget zip zlib1g-dev openjdk-17-jdk android-sdk-platform-tools-common protobuf-compiler python3-protobuf lib32readline-dev libdw-dev libelf-dev lz4 xsltproc libncurses5 libtinfo5

mkdir -p ~/binmkdir -p ~/android/lineage

mkdir ~/.ccacheecho 'export USE_CCACHE=1' >> ~/.bashrcecho 'export CCACHE_DIR=~/.ccache' >> ~/.bashrcsource ~/.bashrcccache -M 50G # 设置缓存大小为 50GB,可以按需求自行调整,但是就算只编译一种设备的映像文件也建议25G起步。ccache -o compression=true

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repochmod a+x ~/bin/repoecho 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrcsource ~/.bashrc

git config --global user.email "you@example.com"git config --global user.name "Your Name"

git lfs install

git config --global trailer.changeid.key "Change-Id"

cd ~/android/lineagerepo init -u https://github.com/LineageOS/android.git -b lineage-21.0 --git-lfs 【可选参数--no-clone-bundle】 #自行修改要拉取的lineage版本

repo sync

编译lineageOS通用镜像【可以自行选择编译的lineageos的对应脚本】注意,安卓15的td编译脚本,推荐使用MisterZtr的lineageOS编译脚本。github上可以找到仓库。

git clone https://github.com/AndyCGYan/lineage_build_unified lineage_build_unified -b lineage-21-lightgit clone https://github.com/AndyCGYan/lineage_patches_unified lineage_patches_unified -b lineage-21-light

td即TD-based,应用TrebleDroid的全量补丁集,对旧设备、mtk处理器、三星等手机有更好的兼容性。

light脚本应用的补丁则少得多,几乎只对一般的现代设备有用,编译出来的系统映像文件兼容性比td的要差些。

请按自己的实际情况来选择,一般而言,除了老旧的设备和奇怪的冷门设备,一般可以使用light脚本构建的系统映像文件。

bash lineage_build_unified/buildbot_unified.sh treble 64VN 64VS 64GN #按需要选择参数编译

编译指定设备的lineageos,需要到github下载设备树、驱动、内核以oneplus 8t为例:手动下载设备树、内核、专有文件(或通过local_manifest.xml自动拉取)设备树路径:device/oneplus/kebab内核路径:kernel/oneplus/sm8250专有文件路径:vendor/oneplus/kebab 和 vendor/oneplus/sm8250-common硬件支持路径:hardware/oplus

一加8T 设备树 https://github.com/LineageOS/android_device_oneplus_kebab 文件放置路径 device/oneplus/kebabSM8250 一加通用设备树:https://github.com/LineageOS/android_device_oneplus_sm8250 文件放置路径device/oneplus/sm8250-commonSM8250 一加内核:https://github.com/LineageOS/android_kernel_oneplus_sm8250 文件放置路径 kernel/oneplus/sm8250SM8250 一加通用专有文件:https://github.com/TheMuppets/proprietary_vendor_oneplus_sm8250-common 文件放置路径 vendor/oneplus/kebab/sm8250-common一加8T专有文件:https://github.com/TheMuppets/proprietary_vendor_oneplus_kebab 文件放置路径 vendor/oneplus/kebab一加硬件支持:https://github.com/LineageOS/android_hardware_oplus 文件放置路径 hardware/oplus

推荐通过 local_manifest.xml 自动拉取

在源码根目录创建 .repo/local_manifests/roomservice.xml

添加设备树、内核、专有文件的仓库定义以下是local_manifest.xml参考内容:

编译lineageOS映像文件1】对于编译通用镜像GSI,命令行进入lineageOS源码根目录,使用脚本指令

bash lineage_build_unified/buildbot_unified.sh treble 64VN

即可输出文件在用户主目录下,build-output里面

2】对于编译指定设备的lineageOS,命令行进入lineageOS源码根目录,依次输入下列指令

source build/envsetup.shbreakfast kebabcrootbrunch kebab

进入输出文件夹(假设构建完成并且没有错误)

cd $OUT

2026-07-07 09:51:04


“心机女”沈梦辰的黑红上位史,和她背后的3个男人
甲壳素面膜好不好 甲壳素面膜怎么用 07月07日更新