From fb2409383f80f474507d568d281b188d71b018fd Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Thu, 23 Oct 2025 10:47:47 +0800 Subject: [PATCH 01/10] Update 02-rockchip_target_only.sh --- scripts/02-rockchip_target_only.sh | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/scripts/02-rockchip_target_only.sh b/scripts/02-rockchip_target_only.sh index 047d560..68b2b1b 100644 --- a/scripts/02-rockchip_target_only.sh +++ b/scripts/02-rockchip_target_only.sh @@ -8,31 +8,3 @@ sed -i 's,kmod-r8168,kmod-r8169,g' target/linux/rockchip/image/armv8.mk wget https://downloads.openwrt.org/releases/${latest_version}/targets/rockchip/armv8/profiles.json jq -r '.linux_kernel.vermagic' profiles.json >.vermagic sed -i -e 's/^\(.\).*vermagic$/\1cp $(TOPDIR)\/.vermagic $(LINUX_DIR)\/.vermagic/' include/kernel-defaults.mk - -# Distfeeds.conf -mkdir -p files/etc/opkg -cat > files/etc/opkg/distfeeds.conf < files/usr/bin/AdGuardHome -chmod +x files/usr/bin/AdGuardHome - -# mihomo -mkdir -p files/etc/openclash/core -CLASH_META_URL="https://raw.githubusercontent.com/vernesong/OpenClash/core/master/meta/clash-linux-arm64.tar.gz" -GEOIP_URL="https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" -GEOSITE_URL="https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" -wget -qO- $CLASH_META_URL | tar xOvz > files/etc/openclash/core/clash_meta -wget -qO- $GEOIP_URL > files/etc/openclash/GeoIP.dat -wget -qO- $GEOSITE_URL > files/etc/openclash/GeoSite.dat -chmod +x files/etc/openclash/core/clash* - From 9d5a738a0ada6cfaa6d00f9aee0c45440d13514e Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Thu, 23 Oct 2025 10:48:03 +0800 Subject: [PATCH 02/10] Update 02-x86_64_target_only.sh --- scripts/02-x86_64_target_only.sh | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/scripts/02-x86_64_target_only.sh b/scripts/02-x86_64_target_only.sh index 6b445da..ee8ad5d 100644 --- a/scripts/02-x86_64_target_only.sh +++ b/scripts/02-x86_64_target_only.sh @@ -28,30 +28,3 @@ exit 0 wget https://downloads.openwrt.org/releases/${latest_version}/targets/x86/64/profiles.json jq -r '.linux_kernel.vermagic' profiles.json >.vermagic sed -i -e 's/^\(.\).*vermagic$/\1cp $(TOPDIR)\/.vermagic $(LINUX_DIR)\/.vermagic/' include/kernel-defaults.mk - -# Distfeeds.conf -mkdir -p files/etc/opkg -cat > files/etc/opkg/distfeeds.conf < files/usr/bin/AdGuardHome -chmod +x files/usr/bin/AdGuardHome - -# mihomo -mkdir -p files/etc/openclash/core -CLASH_META_URL="https://raw.githubusercontent.com/vernesong/OpenClash/core/master/meta/clash-linux-amd64.tar.gz" -GEOIP_URL="https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" -GEOSITE_URL="https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" -wget -qO- $CLASH_META_URL | tar xOvz > files/etc/openclash/core/clash_meta -wget -qO- $GEOIP_URL > files/etc/openclash/GeoIP.dat -wget -qO- $GEOSITE_URL > files/etc/openclash/GeoSite.dat -chmod +x files/etc/openclash/core/clash* From a62cc1307a3bd23e910378dac5b1388c93e17063 Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Thu, 23 Oct 2025 10:52:05 +0800 Subject: [PATCH 03/10] Update build.sh --- build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.sh b/build.sh index e80044c..c31a9a4 100644 --- a/build.sh +++ b/build.sh @@ -479,6 +479,10 @@ compile_toolchain() { compile_openwrt() { print_info "开始编译 OpenWRT..." local starttime=$(date +'%Y-%m-%d %H:%M:%S') + + echo -e "${BLUE_COLOR}├─ 更新 os-release 构建日期...${RESET}" + sed -i "/BUILD_DATE/d" package/base-files/files/usr/lib/os-release + sed -i "/BUILD_ID/aBUILD_DATE=\"$CURRENT_DATE\"" package/base-files/files/usr/lib/os-release echo -e "${BLUE_COLOR}├─ 执行 make 编译...${RESET}" if make -j"$CPU_CORES" IGNORE_ERRORS="n m"; then From f99efbdbfb39f9071416434e4278e608b139b4aa Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Thu, 23 Oct 2025 10:55:50 +0800 Subject: [PATCH 04/10] Update build.sh --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index c31a9a4..369fac2 100644 --- a/build.sh +++ b/build.sh @@ -33,6 +33,7 @@ START_TIME=$(date +%s) CPU_CORES=$(nproc) BUILD_MODE="normal" TOOLCHAIN_ARCH="" +CURRENT_DATE=$(date +%s) # ============================================================================= # 函数定义 From 2b19d7adcfb349fea9eb03f8ab3bdf1fbd538ce8 Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Thu, 23 Oct 2025 20:19:15 +0800 Subject: [PATCH 05/10] Update build.sh --- build.sh | 397 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 397 insertions(+) diff --git a/build.sh b/build.sh index 369fac2..bd00783 100644 --- a/build.sh +++ b/build.sh @@ -510,6 +510,398 @@ compile_openwrt() { echo -e "${BLUE_COLOR}└─ 编译耗时: $(( SEC / 3600 ))h,$(( (SEC % 3600) / 60 ))m,$(( (SEC % 3600) % 60 ))s${RESET}" } +# 编译 OpenWRT +compile_openwrt() { + print_info "开始编译 OpenWRT..." + local starttime=$(date +'%Y-%m-%d %H:%M:%S') + + echo -e "${BLUE_COLOR}├─ 更新 os-release 构建日期...${RESET}" + sed -i "/BUILD_DATE/d" package/base-files/files/usr/lib/os-release + sed -i "/BUILD_ID/aBUILD_DATE=\"$CURRENT_DATE\"" package/base-files/files/usr/lib/os-release + + echo -e "${BLUE_COLOR}├─ 执行 make 编译...${RESET}" + if make -j"$CPU_CORES" IGNORE_ERRORS="n m"; then + echo -e "${GREEN_COLOR}│ ✓ 编译过程完成${RESET}" + else + error_exit "OpenWrt 编译失败" + fi + + # 计算编译时间 + local endtime=$(date +'%Y-%m-%d %H:%M:%S') + local start_seconds=$(date --date="$starttime" +%s) + local end_seconds=$(date --date="$endtime" +%s) + local SEC=$((end_seconds-start_seconds)) + + echo -e "${BLUE_COLOR}├─ 检查编译结果...${RESET}" + if [ -f bin/targets/*/*/sha256sums ]; then + echo -e "${GREEN_COLOR}│ ✓ Build success! ${RESET}" + else + echo -e "${RED_COLOR}│ ✗ Build error... ${RESET}" + echo -e "${BLUE_COLOR}└─ 编译耗时: $(( SEC / 3600 ))h,$(( (SEC % 3600) / 60 ))m,$(( (SEC % 3600) % 60 ))s${RESET}" + exit 1 + fi + + echo -e "${BLUE_COLOR}└─ 编译耗时: $(( SEC / 3600 ))h,$(( (SEC % 3600) / 60 ))m,$(( (SEC % 3600) % 60 ))s${RESET}" +} + +# 获取内核版本并设置 kmod 包名 +setup_kmod_package_name() { + print_info "设置 KMOD 包名..." + + # 检查本地内核版本文件是否存在 + if [ ! -f "/include/kernel-6.6" ]; then + error_exit "内核版本文件 /include/kernel-6.6 不存在" + fi + + echo -e "${BLUE_COLOR}├─ 读取内核版本信息...${RESET}" + get_kernel_version=$(cat /include/kernel-6.6) + + if [ -z "$get_kernel_version" ]; then + error_exit "无法读取内核版本信息" + fi + + echo -e "${BLUE_COLOR}├─ 计算 KMOD 哈希值...${RESET}" + kmod_hash=$(echo -e "$get_kernel_version" | awk -F'HASH-' '{print $2}' | awk '{print $1}' | tail -1 | md5sum | awk '{print $1}') + + if [ -z "$kmod_hash" ]; then + error_exit "KMOD 哈希值计算失败" + fi + + kmodpkg_name=$(echo $(echo -e "$get_kernel_version" | awk -F'HASH-' '{print $2}' | awk '{print $1}')~$(echo $kmod_hash)-r1) + + if [ -z "$kmodpkg_name" ]; then + error_exit "KMOD 包名生成失败" + fi + + echo -e "${GREEN_COLOR}└─ ✓ KMOD 包名设置为: $kmodpkg_name${RESET}" + print_success "KMOD 包配置完成" +} + +# 打包和生成OTA文件 +package_and_generate_ota() { + print_info "开始打包和生成OTA文件..." + + if [ "$ARCHITECTURE" = "x86_64" ]; then + process_x86_64 "$VERSION" + elif [ "$ARCHITECTURE" = "rockchip" ]; then + process_rockchip "$VERSION" + else + print_warning "未知架构: $ARCHITECTURE,跳过打包和OTA生成" + fi + + print_success "打包和OTA生成完成" +} + +# 处理 x86_64 架构 +process_x86_64() { + local version="$1" + + print_info "处理 x86_64 架构的打包..." + + # KMOD 包处理 + echo -e "${BLUE_COLOR}├─ 准备 KMOD 包...${RESET}" + if cp -a bin/targets/x86/*/packages $kmodpkg_name/ && \ + rm -f $kmodpkg_name/Packages* && \ + cp -a bin/packages/x86_64/base/rtl88*a-firmware*.ipk $kmodpkg_name/ && \ + cp -a bin/packages/x86_64/base/natflow*.ipk $kmodpkg_name/; then + echo -e "${GREEN_COLOR}│ ✓ KMOD 文件复制完成${RESET}" + else + print_warning "KMOD 文件复制过程中出现警告" + fi + + echo -e "${BLUE_COLOR}├─ 签名 KMOD 包...${RESET}" + if [ -f "kmod-sign" ] && bash kmod-sign $kmodpkg_name; then + echo -e "${GREEN_COLOR}│ ✓ KMOD 包签名完成${RESET}" + else + print_warning "跳过 KMOD 签名(未找到 kmod-sign 脚本)" + fi + + echo -e "${BLUE_COLOR}├─ 打包 KMOD...${RESET}" + if tar zcf x86_64-$kmodpkg_name.tar.gz $kmodpkg_name; then + echo -e "${GREEN_COLOR}│ ✓ KMOD 打包完成${RESET}" + else + error_exit "KMOD 打包失败" + fi + + echo -e "${BLUE_COLOR}├─ 清理临时文件...${RESET}" + rm -rf $kmodpkg_name + echo -e "${GREEN_COLOR}└─ ✓ 临时文件清理完成${RESET}" + + # 生成 OTA JSON + generate_x86_64_ota_json "$version" +} + +# 生成 x86_64 OTA JSON +generate_x86_64_ota_json() { + local version="$1" + + print_info "生成 x86_64 OTA JSON 文件..." + + echo -e "${BLUE_COLOR}├─ 创建 OTA 目录...${RESET}" + mkdir -p ota + + echo -e "${BLUE_COLOR}├─ 计算 SHA256 校验和...${RESET}" + local OTA_URL="https://github.com/QuickWrt/ZeroWrt/releases/download" + local VERSION_NUMBER=$(echo "$VERSION" | sed 's/v//g') + local SHA256=$(sha256sum bin/targets/x86/64*/*-generic-squashfs-combined-efi.img.gz | awk '{print $1}') + + echo -e "${BLUE_COLOR}├─ 生成 JSON 文件...${RESET}" + cat > ota/x86_64.json < ota/rockchip.json < Date: Thu, 23 Oct 2025 20:20:10 +0800 Subject: [PATCH 06/10] Update build.sh --- build.sh | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/build.sh b/build.sh index bd00783..f938265 100644 --- a/build.sh +++ b/build.sh @@ -510,40 +510,6 @@ compile_openwrt() { echo -e "${BLUE_COLOR}└─ 编译耗时: $(( SEC / 3600 ))h,$(( (SEC % 3600) / 60 ))m,$(( (SEC % 3600) % 60 ))s${RESET}" } -# 编译 OpenWRT -compile_openwrt() { - print_info "开始编译 OpenWRT..." - local starttime=$(date +'%Y-%m-%d %H:%M:%S') - - echo -e "${BLUE_COLOR}├─ 更新 os-release 构建日期...${RESET}" - sed -i "/BUILD_DATE/d" package/base-files/files/usr/lib/os-release - sed -i "/BUILD_ID/aBUILD_DATE=\"$CURRENT_DATE\"" package/base-files/files/usr/lib/os-release - - echo -e "${BLUE_COLOR}├─ 执行 make 编译...${RESET}" - if make -j"$CPU_CORES" IGNORE_ERRORS="n m"; then - echo -e "${GREEN_COLOR}│ ✓ 编译过程完成${RESET}" - else - error_exit "OpenWrt 编译失败" - fi - - # 计算编译时间 - local endtime=$(date +'%Y-%m-%d %H:%M:%S') - local start_seconds=$(date --date="$starttime" +%s) - local end_seconds=$(date --date="$endtime" +%s) - local SEC=$((end_seconds-start_seconds)) - - echo -e "${BLUE_COLOR}├─ 检查编译结果...${RESET}" - if [ -f bin/targets/*/*/sha256sums ]; then - echo -e "${GREEN_COLOR}│ ✓ Build success! ${RESET}" - else - echo -e "${RED_COLOR}│ ✗ Build error... ${RESET}" - echo -e "${BLUE_COLOR}└─ 编译耗时: $(( SEC / 3600 ))h,$(( (SEC % 3600) / 60 ))m,$(( (SEC % 3600) % 60 ))s${RESET}" - exit 1 - fi - - echo -e "${BLUE_COLOR}└─ 编译耗时: $(( SEC / 3600 ))h,$(( (SEC % 3600) / 60 ))m,$(( (SEC % 3600) % 60 ))s${RESET}" -} - # 获取内核版本并设置 kmod 包名 setup_kmod_package_name() { print_info "设置 KMOD 包名..." From f1fc32ba1deec53befc6dbbfe30ccad3952a2606 Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Thu, 23 Oct 2025 21:38:37 +0800 Subject: [PATCH 07/10] Update build.sh --- build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index f938265..2875596 100644 --- a/build.sh +++ b/build.sh @@ -515,12 +515,12 @@ setup_kmod_package_name() { print_info "设置 KMOD 包名..." # 检查本地内核版本文件是否存在 - if [ ! -f "/include/kernel-6.6" ]; then - error_exit "内核版本文件 /include/kernel-6.6 不存在" + if [ ! -f "include/kernel-6.6" ]; then + error_exit "内核版本文件 include/kernel-6.6 不存在" fi echo -e "${BLUE_COLOR}├─ 读取内核版本信息...${RESET}" - get_kernel_version=$(cat /include/kernel-6.6) + get_kernel_version=$(cat include/kernel-6.6) if [ -z "$get_kernel_version" ]; then error_exit "无法读取内核版本信息" From 9189df6dccbc608fc248063a449b9877e065a71c Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Thu, 23 Oct 2025 23:49:54 +0800 Subject: [PATCH 08/10] Update 00-prepare_base.sh --- scripts/00-prepare_base.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/00-prepare_base.sh b/scripts/00-prepare_base.sh index 8d6b154..5b80254 100644 --- a/scripts/00-prepare_base.sh +++ b/scripts/00-prepare_base.sh @@ -4,9 +4,6 @@ # 使用 O2 级别的优化 sed -i 's/Os/O2/g' include/target.mk -# 固件版本号设置 -git describe --abbrev=0 --tags > version.txt - # 内核版本设置 cp -rf ../OpenBox/kernel-6.6/kernel/0001-linux-module-video.patch ./package/0001-linux-module-video.patch git apply package/0001-linux-module-video.patch From 3c2134ea8ce39b2e088392fc5627cfc308d502db Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Fri, 24 Oct 2025 01:12:55 +0800 Subject: [PATCH 09/10] Update build.sh --- build.sh | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/build.sh b/build.sh index 2875596..5b68035 100644 --- a/build.sh +++ b/build.sh @@ -337,24 +337,39 @@ execute_build_scripts() { # 加载配置文件 load_configuration() { local arch="$1" - + local config_file="" + print_info "加载配置文件..." - if [[ "$arch" == "rockchip" ]]; then - echo -e "${BLUE_COLOR}├─ 选择 Rockchip 架构配置${RESET}" - if cp -rf ../OpenBox/config/config-rockchip ./.config; then - echo -e "${GREEN_COLOR}└─ ✓ Rockchip 配置文件加载完成${RESET}" - print_success "Rockchip 架构配置文件已加载" - else - error_exit "Rockchip 配置文件加载失败" - fi - elif [[ "$arch" == "x86_64" ]]; then - echo -e "${BLUE_COLOR}├─ 选择 x86_64 架构配置${RESET}" - if cp -rf ../OpenBox/config/config-x86_64 ./.config; then - echo -e "${GREEN_COLOR}└─ ✓ x86_64 配置文件加载完成${RESET}" - print_success "x86_64 架构配置文件已加载" - else - error_exit "x86_64 配置文件加载失败" - fi + + # 根据架构选择配置文件 + case "$arch" in + rockchip) + config_file="../OpenBox/config/config-rockchip" + echo -e "${BLUE_COLOR}├─ 选择 Rockchip 架构配置${RESET}" + ;; + x86_64) + config_file="../OpenBox/config/config-x86_64" + echo -e "${BLUE_COLOR}├─ 选择 x86_64 架构配置${RESET}" + ;; + *) + error_exit "未知架构: $arch" + ;; + esac + + # 复制配置文件 + if cp -rf "$config_file" ./.config; then + echo -e "${GREEN_COLOR}└─ ✓ 配置文件加载完成${RESET}" + print_success "$arch 架构配置文件已加载" + else + error_exit "$arch 架构配置文件加载失败" + fi + + # 更新版本号 + if [[ -n "$tag_version" ]]; then + echo -e "${BLUE_COLOR}├─ 更新版本信息...${RESET}" + sed -i "s|^CONFIG_VERSION_NUMBER=\".*\"|CONFIG_VERSION_NUMBER=\"$tag_version\"|" .config + sed -i "s|^CONFIG_VERSION_REPO=\".*\"|CONFIG_VERSION_REPO=\"https://downloads.openwrt.org/releases/$tag_version\"|" .config + echo -e "${GREEN_COLOR}└─ ✓ 已更新版本号为:$tag_version${RESET}" fi } From 62a6ebf469198ce1228732ab7ab9aecd64a0b312 Mon Sep 17 00:00:00 2001 From: OPPEN321 Date: Fri, 24 Oct 2025 01:13:56 +0800 Subject: [PATCH 10/10] Update build.sh --- build.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 5b68035..c9bc7f1 100644 --- a/build.sh +++ b/build.sh @@ -351,17 +351,12 @@ load_configuration() { config_file="../OpenBox/config/config-x86_64" echo -e "${BLUE_COLOR}├─ 选择 x86_64 架构配置${RESET}" ;; - *) - error_exit "未知架构: $arch" - ;; esac # 复制配置文件 - if cp -rf "$config_file" ./.config; then + if [[ -n "$config_file" ]] && cp -rf "$config_file" ./.config; then echo -e "${GREEN_COLOR}└─ ✓ 配置文件加载完成${RESET}" print_success "$arch 架构配置文件已加载" - else - error_exit "$arch 架构配置文件加载失败" fi # 更新版本号