Skip to content

Commit

Permalink
优化编译op自动化脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
KtKID committed Oct 20, 2023
1 parent 61c1908 commit fa45996
Showing 1 changed file with 82 additions and 23 deletions.
105 changes: 82 additions & 23 deletions shell/update_op_brefore_compile.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fa45996

Please sign in to comment.