#!/bin/bash -e # 定义一个函数,用来克隆指定的仓库和分支 clone_repo() { # 参数1是仓库地址,参数2是分支名,参数3是目标目录 repo_url=$1 branch_name=$2 target_dir=$3 # 克隆仓库到目标目录,并指定分支名和深度为1 git clone -b $branch_name --depth 1 $repo_url $target_dir } # 定义一些变量,存储仓库地址和分支名 immortalwrt_repo="https://github.com/immortalwrt/immortalwrt" openwrt_repo="https://github.com/openwrt/openwrt.git" # 开始克隆仓库,并行执行 clone_repo $immortalwrt_repo openwrt-24.10 immortalwrt & clone_repo $openwrt_repo openwrt-24.10 openwrt & # 等待所有后台任务完成 wait # Enter source code cd openwrt # Init feeds ./scripts/feeds update -a ./scripts/feeds install -a # make olddefconfig wget -qO - https://raw.githubusercontent.com/oppen321/ZeroWrt-Action/refs/heads/master/patch/linux/0003-include-kernel-defaults.mk.patch | patch -p1 # 更换为 ImmortalWrt Uboot 以及 Target rm -rf ./target/linux/rockchip cp -rf ../immortalwrt/target/linux/rockchip ./target/linux/rockchip rm -rf package/boot/{rkbin,uboot-rockchip,arm-trusted-firmware-rockchip} cp -rf ../immortalwrt/package/boot/uboot-rockchip ./package/boot/uboot-rockchip cp -rf ../immortalwrt/package/boot/arm-trusted-firmware-rockchip ./package/boot/arm-trusted-firmware-rockchip sed -i '/REQUIRE_IMAGE_METADATA/d' target/linux/rockchip/armv8/base-files/lib/upgrade/platform.sh curl -L -o include/kernel-6.6 https://raw.githubusercontent.com/immortalwrt/immortalwrt/refs/heads/openwrt-24.10/include/kernel-6.6 # Load devices Config if [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then curl -s https://git.kejizero.online/zhao/files/raw/branch/main/toolchain/Configs/immortalwrt_rockchip.config > .config elif [ "$model" = "OpenWrt_X86_64_v24.10" ]; then curl -s https://git.kejizero.online/zhao/files/raw/branch/main/toolchain/Configs/immortalwrt_x86_64.config > .config fi # gcc14 & 15 if [ "$USE_GCC13" = y ]; then export USE_GCC13=y gcc_version=13 elif [ "$USE_GCC14" = y ]; then export USE_GCC14=y gcc_version=14 fi # gcc config echo -e "\n# gcc ${gcc_version}" >> .config echo -e "CONFIG_DEVEL=y" >> .config echo -e "CONFIG_TOOLCHAINOPTS=y" >> .config echo -e "CONFIG_GCC_USE_VERSION_${gcc_version}=y\n" >> .config # Compile make defconfig make -j$cores toolchain/compile || make -j$cores toolchain/compile V=s || exit 1 # Create folder mkdir toolchain-cache # Compression toolchain case "$model" in "OpenWrt_Rockchip_v24.10" | "OpenWrt_X86_64_v24.10") if [ -z "$gcc_version" ]; then echo "Error: GCC version not set!" exit 1 fi if [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then output_file="toolchain_musl_openwrt_rockchip_gcc-${gcc_version}.tar.zst" elif [ "$model" = "OpenWrt_X86_64_v24.10" ]; then output_file="toolchain_musl_openwrt_X86_64_gcc-${gcc_version}.tar.zst" fi tar -I zstd -cvf "toolchain-cache/${output_file}" build_dir dl tmp staging_dir ;; *) echo "Error: Unknown model '$model'!" exit 1 ;; esac