From fa45996d4c0f770c80648f3bdd9bf5f8ca9de207 Mon Sep 17 00:00:00 2001 From: KtKID <649693008@qq.com> Date: Sat, 21 Oct 2023 01:34:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=AF=91op=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/update_op_brefore_compile.sh | 105 ++++++++++++++++++++++------- 1 file changed, 82 insertions(+), 23 deletions(-) diff --git a/shell/update_op_brefore_compile.sh b/shell/update_op_brefore_compile.sh index 1528b86..84550ca 100644 --- a/shell/update_op_brefore_compile.sh +++ b/shell/update_op_brefore_compile.sh @@ -1,31 +1,90 @@ #!/bin/bash # 编译op前准备 -echo "Running update and install feed..." -# update -./scripts/feeds update -a -./scripts/feeds install -a - - -if [[ $1 == "-y" ]]; then - # 自动执行 - echo "make defconfig" - make defconfig - echo "make download -j8" - make download -j8 -else - # 手动询问是否执行update2 - read -n 1 -r -p "make defconfig now? (y/n) " answer - echo - if [[ $answer == [Yy] ]]; then + +# 更新feeds文件 +function update_feeds() { + echo "Running update and install feed..." + ./scripts/feeds update -a + ./scripts/feeds install -a +} + +# 执行make defconfig +function make_defconfig() { echo "make defconfig" make defconfig - fi +} - # 手动询问是否执行update3 - read -n 1 -r -p "make download -j8 now? (y/n) " answer - echo - if [[ $answer == [Yy] ]]; then +function make_download() { echo "make download -j8" make download -j8 - fi +} +# 根据参数执行相应操作 +# 1. -u|--update 更新feeds文件 +# 2. -d|--defconfig 执行make defconfig +# 3. -m|--download 执行make download -j8 +# shift 命令用于对参数的移动(左移) +all=false +update=false +defconfig=false +download=false + +while [[ $# -gt 0 ]]; do + case $1 in + -u|--update) + update=true + shift + ;; + -d|--defconfig) + defconfig=true + shift + ;; + -m|--download) + download=true + shift + ;; + -a) + all=true + shift + ;; + *) + echo "无效的选项: $1" + shift + ;; + esac +done + +if $all || $update; then + update_feeds +fi + +if $all || $defconfig; then + make_defconfig +fi + +if $all || $download; then + make_download fi + +# if [[ $1 == "-y" ]]; then +# # 自动执行 +# echo "make defconfig" +# make defconfig +# echo "make download -j8" +# make download -j8 +# else +# # 手动询问是否执行update2 +# read -n 1 -r -p "make defconfig now? (y/n) " answer +# echo +# if [[ $answer == [Yy] ]]; then +# echo "make defconfig" +# make defconfig +# fi + +# # 手动询问是否执行update3 +# read -n 1 -r -p "make download -j8 now? (y/n) " answer +# echo +# if [[ $answer == [Yy] ]]; then +# echo "make download -j8" +# make download -j8 +# fi +# fi