添加 Mediatek.sh
Signed-off-by: zhao <zj18139624826@gmail.com>
This commit is contained in:
commit
b27433e0f5
92
Mediatek.sh
Normal file
92
Mediatek.sh
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
# 颜色变量定义
|
||||||
|
export RED_COLOR='\e[1;31m'
|
||||||
|
export GREEN_COLOR='\e[1;32m'
|
||||||
|
export YELLOW_COLOR='\e[1;33m'
|
||||||
|
export BLUE_COLOR='\e[1;34m'
|
||||||
|
export PINK_COLOR='\e[1;35m'
|
||||||
|
export SHAN='\e[1;33;5m'
|
||||||
|
export RES='\e[0m'
|
||||||
|
|
||||||
|
# GitHub 变量
|
||||||
|
export github="github.com"
|
||||||
|
|
||||||
|
# Gitea 变量
|
||||||
|
export gitea=https://git.kejizero.online/zhao
|
||||||
|
|
||||||
|
# 分组函数(GitHub Actions 支持)
|
||||||
|
GROUP=
|
||||||
|
group() {
|
||||||
|
endgroup
|
||||||
|
echo "::group:: $1"
|
||||||
|
GROUP=1
|
||||||
|
}
|
||||||
|
endgroup() {
|
||||||
|
if [ -n "$GROUP" ]; then
|
||||||
|
echo "::endgroup::"
|
||||||
|
fi
|
||||||
|
GROUP=
|
||||||
|
}
|
||||||
|
|
||||||
|
# 开始时间
|
||||||
|
starttime=$(date +'%Y-%m-%d %H:%M:%S')
|
||||||
|
startsec=$(date +%s)
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
# Mediatek OpenWrt Build Script #
|
||||||
|
#####################################
|
||||||
|
|
||||||
|
# 设置平台变量
|
||||||
|
group "设置平台变量"
|
||||||
|
if [ "$1" = "Mediatek_mt7981" ]; then
|
||||||
|
export platform="Mediatek_mt7981"
|
||||||
|
elif [ "$1" = "Mediatek_mt7986" ]; then
|
||||||
|
export platform="Mediatek_mt7986"
|
||||||
|
else
|
||||||
|
echo -e "${RED_COLOR}错误:未指定正确的平台参数(Mediatek_mt7981 或 Mediatek_mt7986)${RES}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
endgroup
|
||||||
|
|
||||||
|
# 克隆源码
|
||||||
|
group "克隆源码"
|
||||||
|
git clone --depth=1 https://$github/zhiern/immortalwrt-mt798x -b openwrt-21.02
|
||||||
|
cd immortalwrt-mt798x || { echo -e "${RED_COLOR}进入源码目录失败${RES}"; exit 1; }
|
||||||
|
endgroup
|
||||||
|
|
||||||
|
# 更新 feeds
|
||||||
|
group "更新和安装 feeds"
|
||||||
|
./scripts/feeds update -a
|
||||||
|
./scripts/feeds install -a
|
||||||
|
endgroup
|
||||||
|
|
||||||
|
# 加载 .config 配置文件
|
||||||
|
group "加载对应配置文件"
|
||||||
|
if [ "$platform" = "Mediatek_mt7981" ]; then
|
||||||
|
curl -s $gitea/scripts/Mediatek/21-config-mediatek_mt7981 > .config
|
||||||
|
elif [ "$platform" = "Mediatek_mt7986" ]; then
|
||||||
|
curl -s $gitea/scripts/Mediatek/21-config-mediatek_mt7986 > .config
|
||||||
|
fi
|
||||||
|
endgroup
|
||||||
|
|
||||||
|
# 生成默认配置
|
||||||
|
group "生成默认配置"
|
||||||
|
make defconfig
|
||||||
|
endgroup
|
||||||
|
|
||||||
|
# 开始编译
|
||||||
|
group "开始编译固件"
|
||||||
|
echo -e "${GREEN_COLOR}使用 $(nproc) 线程进行编译...${RES}"
|
||||||
|
make -j$(nproc) || make -j1 || make -j1 V=s
|
||||||
|
endgroup
|
||||||
|
|
||||||
|
# 显示耗时
|
||||||
|
endtime=$(date +'%Y-%m-%d %H:%M:%S')
|
||||||
|
endsec=$(date +%s)
|
||||||
|
duration=$((endsec - startsec))
|
||||||
|
echo -e "${BLUE_COLOR}构建开始时间: $starttime${RES}"
|
||||||
|
echo -e "${BLUE_COLOR}构建结束时间: $endtime${RES}"
|
||||||
|
echo -e "${GREEN_COLOR}总共耗时: ${duration} 秒${RES}"
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user