Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

157 Commits

Folders and files

Repository files navigation

Build OpenWrt

用 GitHub Actions 编译 x86_64 OpenWrt 固件。每个"产品"是一套独立的源码 + 定制 + 配置,编译完成后自动发布到 Releases。

产品

产品 源码 定制内容 触发方式
PCDN-gateway openwrt/openwrt@main SONiC 全锥形 NAT、Argon 主题、EasyTier(每次构建取最新版本) 每天 08:00、推送相关文件、手动
PCDN openwrt/openwrt@main Turbo ACC、Argon 主题、sysctl 调优 手动
PCDN-fw3 openwrt/openwrt@main Turbo ACC、Argon 主题、sysctl 调优 手动
PCDN-mwan openwrt/openwrt@main Turbo ACC、Argon 主题 手动
turboacc openwrt/openwrt@main Turbo ACC、Argon 主题 手动
gateway openwrt/openwrt@main Turbo ACC、Argon 主题 手动
proxy openwrt/openwrt@main — 手动
home-clash openwrt/openwrt@main — 手动
BE openwrt/openwrt@main Argon 主题 手动
Fullcone openwrt/openwrt@main Turbo ACC(chenmozhijin 版,不含 SFE)、Argon 主题、wrtbwmon 手动
LEDE coolsnowwolf/lede@master sysctl 调优 手动

手动构建:在 Actions 页面选择对应的 Build OpenWrt <产品>,点击 Run workflow。

目录结构

.github/workflows/
  build.yml                    # 通用构建流程(可复用 workflow)
  Build_OpenWrt_<产品>.yml      # 各产品入口:触发条件 + 调用 build.yml
products/<产品>/
  config                       # 配置(diffconfig 格式)
  product.env                  # 源码仓库、分支、CI 额外安装的主机软件包,以及传给编译过程的环境变量
  customize.sh                 # 可选:添加第三方软件包、打补丁等
  files/                       # 可选:直接放进固件的文件,如 etc/sysctl.d/99-custom.conf
scripts/
  product-env.sh               # 读取 product.env
  latest-release.sh            # 取 GitHub 仓库版本号最高的 release(含 pre-release)
  prepare-tree.sh              # 应用产品定制并生成 .config
  cache-keys.sh                # 计算 tools 和工具链缓存的 key
  build-toolchain.sh           # 编译 tools 和工具链,跳过已缓存的部分
  collect-firmware.sh          # 整理固件、生成 release 说明
  prune-releases.sh            # 清理旧 release
patches/r8168/                 # 备用补丁,目前没有产品使用(见下文)

构建流程

  1. 按 product.env 检出源码,执行 feeds update / feeds install
  2. scripts/prepare-tree.sh:复制 files/,运行 customize.sh,用 config 执行 make defconfig,再检查 config 里选中的软件包都还在(上游删除或改名的包会被 defconfig 静默丢掉,这时直接让构建失败)
  3. 恢复 tools 和工具链缓存,make download,编译 tools 和工具链(命中缓存时跳过,未命中时编译完保存缓存)
  4. make 编译内核、软件包和固件
  5. 上传 bin 目录为 artifact(保留 7 天)
  6. 创建 release,tag 为 OpenWrt-<产品>_<平台>_<日期>,说明中包含 OpenWrt 和第三方仓库实际用到的 commit、内核版本和镜像的 SHA256
  7. 只保留该产品最近 10 个 release,更早的连同 tag 一起删除(在产品入口 workflow 中用 keep-releases 调整,0 表示不清理)

构建缓存

tools(主机工具)和工具链约占编译时间的一半,而且大多数日子与前一天完全相同,因此缓存在 GitHub Actions cache 中:

  • tools:所有产品共用,上游 tools/ 的内容或按配置启用的工具变化时重建
  • 工具链:每个产品单独缓存,上游 toolchain/ 的内容、工具链相关配置、内核大版本或产品对内核补丁的改动变化时重建;另外每月重建一次

缓存 7 天未使用会被 GitHub 清除,所以偶尔手动构建的产品通常需要从头编译。怀疑缓存有问题时,在 Actions → Caches 页面删除对应缓存即可。

修改配置

config 采用 diffconfig 格式,只记录与默认值不同的选项;上游默认值变化时会自动跟随。修改步骤:

# 源码仓库和分支与 product.env 一致;需要一个全新的源码树
git clone https://github.com/openwrt/openwrt.git && cd openwrt
./scripts/feeds update -a && ./scripts/feeds install -a

# 应用产品定制并加载当前配置
bash ../OpenWrt-Build/scripts/prepare-tree.sh PCDN-gateway .

make menuconfig
./scripts/diffconfig.sh > ../OpenWrt-Build/products/PCDN-gateway/config

直接放入完整的 .config 也可以编译,但不推荐。

新增产品

  1. 新建 products/<产品>/,放入 config,按需添加 product.env、customize.sh、files/
  2. 复制一个 .github/workflows/Build_OpenWrt_<产品>.yml,修改 name 和 product

customize.sh 里的第三方仓库请 clone 到 package/(软件包)或 tmp/sources/(只用其中的脚本),release 说明会自动记录它们这次用到的提交。

备用补丁

patches/r8168/010-enable_TX_RSS_disable_ASPM.patch:r8168 驱动关闭 ASPM,开启多队列 TX 和 RSS。需要时在产品的 customize.sh 中加入:

cp "$REPO_ROOT"/patches/r8168/*.patch package/kernel/r8168/patches/

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages