mirror of
https://github.com/Dichgrem/Dwrt-build.git
synced 2025-12-16 13:41:59 -05:00
feat:check_packages
This commit is contained in:
117
.github/workflows/build.yml
vendored
Normal file
117
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
name: Build ImmortalWrt
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version_type:
|
||||||
|
description: "版本类型"
|
||||||
|
required: true
|
||||||
|
default: "stable"
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- "snapshot"
|
||||||
|
- "stable"
|
||||||
|
branch:
|
||||||
|
description: "snapshot-branch"
|
||||||
|
required: false
|
||||||
|
default: "openwrt-24.10"
|
||||||
|
type: string
|
||||||
|
tag:
|
||||||
|
description: "stable-tag"
|
||||||
|
required: false
|
||||||
|
default: "v24.10.2"
|
||||||
|
type: string
|
||||||
|
config_path:
|
||||||
|
description: "Config 路径"
|
||||||
|
required: true
|
||||||
|
default: "config/myconfig"
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout current repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Determine Git ref
|
||||||
|
id: refinfo
|
||||||
|
run: |
|
||||||
|
if [ "${{ inputs.version_type }}" = "snapshot" ]; then
|
||||||
|
echo "Using branch '${{ inputs.branch }}'"
|
||||||
|
echo "ref=${{ inputs.branch }}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Using tag '${{ inputs.tag }}'"
|
||||||
|
echo "ref=${{ inputs.tag }}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Clone ImmortalWrt source
|
||||||
|
run: |
|
||||||
|
echo "📥 克隆 immortalwrt 仓库,ref=${{ steps.refinfo.outputs.ref }}"
|
||||||
|
git clone --branch "${{ steps.refinfo.outputs.ref }}" \
|
||||||
|
https://github.com/immortalwrt/immortalwrt.git immortalwrt
|
||||||
|
|
||||||
|
- name: Install build dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y \
|
||||||
|
build-essential clang flex bison g++ gawk gettext git \
|
||||||
|
libncurses-dev libssl-dev python3 python3-dev python3-setuptools \
|
||||||
|
rsync unzip zlib1g-dev file wget curl \
|
||||||
|
gzip tar zip xz-utils bzip2 zstd \
|
||||||
|
make cmake autoconf automake libtool patch diffutils \
|
||||||
|
findutils grep sed help2man texinfo \
|
||||||
|
libelf-dev libfuse-dev liblzma-dev libxml2-dev libyaml-dev \
|
||||||
|
uuid-dev device-tree-compiler antlr3 gperf \
|
||||||
|
time bc jq xxd swig upx-ucl ccache ecj fastjar imagemagick
|
||||||
|
|
||||||
|
- name: Update and install feeds
|
||||||
|
working-directory: immortalwrt
|
||||||
|
run: |
|
||||||
|
echo "📦 更新 feeds"
|
||||||
|
./scripts/feeds update -a
|
||||||
|
echo "📦 安装 feeds"
|
||||||
|
./scripts/feeds install -a
|
||||||
|
|
||||||
|
- name: Setup configuration
|
||||||
|
run: |
|
||||||
|
echo "📋 校验并复制配置:${{ inputs.config_path }} → immortalwrt/.config"
|
||||||
|
if [ ! -f "${{ inputs.config_path }}" ]; then
|
||||||
|
echo "❌ 找不到配置文件:${{ inputs.config_path }}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cp "${{ inputs.config_path }}" immortalwrt/.config
|
||||||
|
cd immortalwrt
|
||||||
|
echo "🔄 运行 make oldconfig"
|
||||||
|
make oldconfig
|
||||||
|
|
||||||
|
- name: Download source packages
|
||||||
|
working-directory: immortalwrt
|
||||||
|
run: |
|
||||||
|
echo "⬇️ 下载所有源码包"
|
||||||
|
make download -j8
|
||||||
|
|
||||||
|
- name: Build ImmortalWrt
|
||||||
|
working-directory: immortalwrt
|
||||||
|
run: |
|
||||||
|
JOBS=$(nproc)
|
||||||
|
echo "🚀 开始全量编译(并行 ${JOBS})"
|
||||||
|
START=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
|
echo "⏱️ 编译开始于: ${START}"
|
||||||
|
if ! time make world -j${JOBS} 2>&1 | tee build.log; then
|
||||||
|
echo "❌ 编译失败,输出最后 100 行日志:"
|
||||||
|
tail -n 100 build.log | sed 's/^/ /'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
END=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
|
echo "✅ 编译成功"
|
||||||
|
echo "⏱️ 开始: ${START}"
|
||||||
|
echo "⏱️ 结束: ${END}"
|
||||||
|
|
||||||
|
- name: Upload firmware artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: immortalwrt-output
|
||||||
|
path: |
|
||||||
|
immortalwrt/bin/targets/**/*.{img,bin,tar.gz,zip}
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Dichgrem
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
14
README.md
14
README.md
@@ -1 +1,13 @@
|
|||||||
# Dwrt-build
|
# Dwrt-build
|
||||||
|
|
||||||
|
This is a Openwrt build workflows.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
| 名称 | URL | SHORT |
|
||||||
|
|--------------|------------------------------------------------------------|--------------------------|
|
||||||
|
| x-wrt | https://github.com/x-wrt/x-wrt.git | x-wrt/x-wrt |
|
||||||
|
| openwrt | https://git.openwrt.org/openwrt/openwrt.git | openwrt/openwrt |
|
||||||
|
| lienol | https://github.com/Lienol/openwrt.git | Lienol/openwrt |
|
||||||
|
| lede | https://github.com/coolsnowwolf/lede.git | coolsnowwolf/lede |
|
||||||
|
| immortalwrt | https://github.com/immortalwrt/immortalwrt.git | immortalwrt/immortalwrt |
|
||||||
|
|||||||
117
check_packages.py
Normal file
117
check_packages.py
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
import subprocess
|
||||||
|
|
||||||
|
# 要检查和安装的软件包列表
|
||||||
|
packages = [
|
||||||
|
"build-essential", # 基础构建工具包
|
||||||
|
"clang", # LLVM C/C++ 编译器
|
||||||
|
"flex", # 词法分析器生成器
|
||||||
|
"bison", # 语法分析器生成器
|
||||||
|
"g++", # GNU C++ 编译器
|
||||||
|
"gawk", # GNU AWK 文本处理工具
|
||||||
|
"gettext", # 国际化支持工具
|
||||||
|
"git", # 版本控制系统
|
||||||
|
"libncurses-dev", # ncurses 开发库(新版)
|
||||||
|
"libssl-dev", # OpenSSL 开发库
|
||||||
|
"python3", # Python 3 解释器
|
||||||
|
"python3-dev", # Python 3 开发库
|
||||||
|
"python3-setuptools", # Python 3 setuptools
|
||||||
|
"rsync", # 文件同步工具
|
||||||
|
"unzip", # 解压缩工具
|
||||||
|
"zlib1g-dev", # zlib 压缩库开发包
|
||||||
|
"file", # 文件类型识别工具
|
||||||
|
"wget", # 网络下载工具
|
||||||
|
"curl", # 网络传输工具
|
||||||
|
# 压缩和解压工具
|
||||||
|
"gzip", # Gzip 压缩工具
|
||||||
|
"tar", # Tar 打包工具
|
||||||
|
"zip", # Zip 压缩工具
|
||||||
|
"xz-utils", # XZ 压缩工具
|
||||||
|
"bzip2", # Bzip2 压缩工具
|
||||||
|
"zstd", # Zstandard 压缩工具
|
||||||
|
# 构建相关工具
|
||||||
|
"make", # Make 构建工具
|
||||||
|
"cmake", # CMake 构建系统
|
||||||
|
"autoconf", # Autoconf 自动配置工具
|
||||||
|
"automake", # Automake 构建工具
|
||||||
|
"libtool", # Libtool 库工具
|
||||||
|
"patch", # 补丁应用工具
|
||||||
|
"diffutils", # 文件差异工具
|
||||||
|
"findutils", # 文件查找工具
|
||||||
|
"grep", # 文本搜索工具
|
||||||
|
"sed", # 流编辑器
|
||||||
|
# 文档和帮助工具
|
||||||
|
"help2man", # 手册页生成工具
|
||||||
|
"texinfo", # Texinfo 文档系统
|
||||||
|
# 开发库
|
||||||
|
"libelf-dev", # ELF 处理库
|
||||||
|
"libfuse-dev", # FUSE 文件系统开发库
|
||||||
|
"liblzma-dev", # LZMA 开发库
|
||||||
|
"libxml2-dev", # XML2 开发库
|
||||||
|
"libyaml-dev", # YAML 开发库
|
||||||
|
"uuid-dev", # UUID 开发库
|
||||||
|
"device-tree-compiler", # 设备树编译器
|
||||||
|
"antlr3", # ANTLR3 解析器生成器
|
||||||
|
"gperf", # GNU 完美哈希函数生成器
|
||||||
|
# 网络和系统工具
|
||||||
|
"time", # 时间测量工具
|
||||||
|
"bc", # 任意精度计算器,内核 Makefile 中常用于数学计算
|
||||||
|
"jq", # JSON 处理器
|
||||||
|
"xxd", # 十六进制查看器
|
||||||
|
"swig", # SWIG 接口生成器
|
||||||
|
"upx-ucl", # UPX 压缩工具
|
||||||
|
"ccache", # 编译缓存工具
|
||||||
|
"ecj", # Eclipse Java 编译器
|
||||||
|
"fastjar", # Fast JAR 工具
|
||||||
|
"imagemagick", # ImageMagick 图像处理
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def is_installed(pkg_name):
|
||||||
|
"""检查软件包是否已安装"""
|
||||||
|
try:
|
||||||
|
subprocess.run(
|
||||||
|
["dpkg", "-s", pkg_name],
|
||||||
|
check=True,
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("检查并安装缺失的软件包...")
|
||||||
|
missing_packages = []
|
||||||
|
|
||||||
|
for pkg in packages:
|
||||||
|
if is_installed(pkg):
|
||||||
|
print(f"✅ 已安装:{pkg}")
|
||||||
|
else:
|
||||||
|
print(f"❌ 未安装:{pkg}")
|
||||||
|
missing_packages.append(pkg)
|
||||||
|
|
||||||
|
if missing_packages:
|
||||||
|
print("\n🔄 正在执行 apt-get update ...")
|
||||||
|
try:
|
||||||
|
subprocess.run(["sudo", "apt-get", "update"], check=True)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("❌ apt-get update 失败,请检查网络连接或源设置。")
|
||||||
|
return
|
||||||
|
|
||||||
|
print("\n⬇️ 开始安装以下缺失的软件包:")
|
||||||
|
print(" ".join(missing_packages))
|
||||||
|
try:
|
||||||
|
subprocess.run(
|
||||||
|
["sudo", "apt-get", "install", "-y"] + missing_packages, check=True
|
||||||
|
)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("❌ 安装部分软件包失败,请手动检查。")
|
||||||
|
else:
|
||||||
|
print("\n✅ 所有软件包已安装,无需操作。")
|
||||||
|
|
||||||
|
print("✅ 所有软件包检查完毕。")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
7971
config/myconfig
Normal file
7971
config/myconfig
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user