mcpField
L
lineageos

lineageos

github.com/hyperb1iss开发49101 次安装39 周前更新
代码仓库

关于 lineageos

lineageos 是面向 LineageOS ROM 开发者的开发技能,涵盖从同步源码、配置设备树到构建和提交更改的流程,并提供常用命令与故障排查指引。

主要功能

  1. 01初始化并同步源码
  2. 02配置设备树与依赖
  3. 03构建 ZIP、内核或系统镜像
  4. 04提取设备专有文件
  5. 05使用 repopick 获取 Gerrit 更改
  6. 06排查构建与 SELinux 问题

适用场景

  1. 01为设备配置 LineageOS 构建环境
  2. 02构建可刷入的 ROM ZIP
  3. 03提取设备的 vendor blobs
  4. 04准备并提交 Gerrit 更改

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/hyperb1iss/hyperdroid-skill --skill lineageos

安装后在 Claude Code 中输入/lineageos确认已加载。

附带文件references/gerrit-workflow.md

详细介绍

LineageOS 开发

本技能介绍 LineageOS 定制 ROM 开发,涵盖从同步源代码到构建和贡献。

入门

初始化源代码
mkdir ~/lineage && cd ~/lineage

# Install repo (if needed)
mkdir -p ~/.bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+x ~/.bin/repo
export PATH="$HOME/.bin:$PATH"

# Init LineageOS 21 (Android 14)
repo init -u https://github.com/LineageOS/android.git -b lineage-21.0 --git-lfs

# Sync
repo sync -c -j$(nproc) --force-sync --no-tags --no-clone-bundle
构建命令
# Setup environment
source build/envsetup.sh

# Setup device (syncs device repos too)
breakfast <device>

# Build flashable ZIP
brunch <device>
# Or separately:
breakfast <device>
mka bacon

# Output: out/target/product/<device>/lineage-21.0-*-UNOFFICIAL-<device>.zip

基本命令

命令用途
breakfast <device>设置设备并同步依赖项
brunch <device>执行 breakfast 并进行完整构建
mka bacon构建可刷入的 ZIP
mka bootimage仅构建内核
mka systemimage仅构建系统
repopick <change>从 Gerrit 拣选提交

设备树

必需文件
device/<vendor>/<device>/
├── lineage_<device>.mk      # Product makefile
├── lineage.dependencies     # Repo dependencies
├── vendorsetup.sh           # Add to lunch
├── BoardConfig.mk           # Hardware config
├── device.mk                # Packages and configs
└── extract-files.sh         # Vendor blob extraction
lineage_.mk
# Inherit device
$(call inherit-product, device/vendor/device/device.mk)

# Inherit LineageOS common
$(call inherit-product, vendor/lineage/config/common_full_phone.mk)

PRODUCT_NAME := lineage_device
PRODUCT_DEVICE := device
PRODUCT_BRAND := Vendor
PRODUCT_MODEL := Device Name
PRODUCT_MANUFACTURER := Vendor
lineage.dependencies
[
  {
    "repository": "android_kernel_vendor_device",
    "target_path": "kernel/vendor/device"
  },
  {
    "repository": "android_device_vendor_device-common",
    "target_path": "device/vendor/device-common"
  },
  {
    "repository": "proprietary_vendor_device",
    "target_path": "vendor/device"
  }
]

repopick - 从 Gerrit 拣选提交

# Single change
repopick 12345

# Multiple changes
repopick 12345 12346 12347

# By topic
repopick -t feature-topic

# With dependencies
repopick -Q 12345

# Force overwrite local changes
repopick -f 12345

# Show what would be picked
repopick -n 12345
查找变更编号
  1. 访问 https://review.lineageos.org
  2. 搜索变更
  3. 变更编号位于 URL 中或页面上

Vendor Blob

从设备提取
cd device/vendor/device
./extract-files.sh
从 OTA/Factory Image 提取
./extract-files.sh ~/Downloads/ota.zip
proprietary-files.txt 格式
# Audio HAL
vendor/lib64/hw/audio.primary.platform.so
vendor/etc/audio_policy_configuration.xml

# With destination path
vendor/lib64/lib.so:vendor/lib64/libfoo.so

# From another device
vendor/lib64/lib.so|other_device

LineageOS 功能

Trust 界面

显示设备完整性的安全仪表板:

# device.mk
PRODUCT_PACKAGES += \
    LineageTrust
LiveDisplay

硬件加速的显示调节:

PRODUCT_PACKAGES += \
    [email protected]
样式 / 主题

系统主题支持:

PRODUCT_PACKAGES += \
    ThemePicker

关键目录

路径用途
vendor/lineage/LineageOS 扩展
lineage-sdk/LineageOS SDK
device/<vendor>/<device>/设备树
kernel/<vendor>/<device>/内核源代码
vendor/<vendor>/专有 Blob

贡献

设置 Gerrit 访问权限
git config --global review.review.lineageos.org.username <username>
提交变更
# Create branch
repo start my-feature .

# Make changes
git add -A
git commit -m "subsystem: Short description

Detailed explanation.

Change-Id: <auto-generated>"

# Push for review
git push ssh://<username>@review.lineageos.org:29418/<project> HEAD:refs/for/<branch>
提交消息格式
subsystem: Short description

Longer explanation wrapped at 72 characters.
Explain why, not what.

Change-Id: I1234567890abcdef...

常见问题

Breakfast 失败 - 缺少仓库
# Re-sync device tree
repo sync device/vendor/device kernel/vendor/device vendor/device
构建失败 - SELinux
# Find denials
adb shell dmesg | grep "avc: denied"

# Generate policy (on host)
adb shell dmesg | audit2allow -p out/target/product/<device>/root/sepolicy
缺少 Blob

检查 logcat 中的:

E linker: cannot find symbol...
E ServiceManager: Could not find service...

将缺少的文件添加到 proprietary-files.txt 并重新提取。


快速参考

# Full workflow
source build/envsetup.sh
breakfast cheeseburger
brunch cheeseburger

# Just kernel
mka bootimage

# Cherry-pick fix
repopick 12345

# Sync everything
repo sync -c -j$(nproc)

# Sync one project
repo sync packages/apps/Settings

# Clean build
m clean && brunch <device>

评论

支持 Markdown