Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
codefast
toolchain_2021
提交
a025f4cb
T
toolchain_2021
项目概览
codefast
/
toolchain_2021
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
toolchain_2021
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a025f4cb
编写于
6月 09, 2021
作者:
W
wenliang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updata download_toolchain.sh
上级
ff8f9d52
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
137 addition
and
121 deletion
+137
-121
download_toolchain.sh
download_toolchain.sh
+137
-121
未找到文件。
download_toolchain.sh
100755 → 100644
浏览文件 @
a025f4cb
#!/bin/bash
# ----------------------------------------------------------------------------------------------------
# lanch_name : download_toolchain
# lanch_id :
...
...
@@ -10,33 +11,41 @@
SCRIPT_NAME
=
${
BASH_SOURCE
[0]##*/
}
SCRIPT_PATH
=
$(
if
[
-n
"
${
BASH_SOURCE
[0]%
${
SCRIPT_NAME
}}
"
]
;
then
cd
${
BASH_SOURCE
[0]%
${
SCRIPT_NAME
}}
;
fi
;
pwd
)
echo
"[Git Branch Auto Download]"
# ----------------------------------------------------------------------------------------------------
# git@codechina.csdn.net:codefast/toolchain.git
# https://codechina.csdn.net/codefast/toolchain.git
git_address
=
codechina.csdn.net
git_group
=
codefast
git_project
=
toolchain
# --------- --------- --------- --------- --------- --------- --------- --------- --------- ---------
git_access_use_https
=
1
git_branch_common
=
script
OPTIONS_GIT_URL
=
"https://codechina.csdn.net/codefast/toolchain.git"
OPTIONS_COMMON_BRANCH
=
script
# ----------------------------------------------------------------------------------------------------
function
echo_title
()
{
echo
-e
"
\0
33[0;33m
$*
\0
33[0m"
;
}
function
echo_tag
()
{
echo
-e
"
\0
33[0;33m
$*
\0
33[0m"
;
}
function
echo_debug
()
{
echo
-e
"
\0
33[1;30m[DEBUG]
$*
\0
33[0m"
>
/dev/null
;
}
function
echo_error
()
{
echo
-e
"
\0
33[1;31m[ERROR]
$*
\0
33[0m"
;
}
# ----------------------------------------------------------------------------------------------------
# Automatic generation
git_repository_git
=
"git@
${
git_address
}
:
${
git_group
}
/
${
git_project
}
.git"
git_repository_https
=
"https://
${
git_address
}
/
${
git_group
}
/
${
git_project
}
.git"
if
[
"1"
==
"
${
git_access_use_https
}
"
]
;
then
git_repository_address
=
${
git_repository_https
}
else
git_repository_address
=
${
git_repository_git
}
fi
function
SCRIPT_ARGV_PARSER
(){
echo_debug
"AGRV:
$*
"
if
[
-z
"
$1
"
]
;
then
OPTIONS_HELP_INFO
=
1
;
return
fi
for
argv
in
$*
;
do
if
[
"
$argv
"
==
"-h"
]
||
[
"
$argv
"
==
"-help"
]
;
then
OPTIONS_HELP_INFO
=
1
;
echo_debug
"OPTIONS_HELP_INFO=
${
OPTIONS_HELP_INFO
}
"
fi
if
[
"
$argv
"
==
"-l"
]
||
[
"
$argv
"
==
"-list"
]
;
then
OPTIONS_LIST_INFO
=
1
echo_debug
"OPTIONS_LIST_INFO=
${
OPTIONS_LIST_INFO
}
"
fi
done
}
# ----------------------------------------------------------------------------------------------------
function
SHELL_FUNCTION_HELP
(){
function
FUNCTION_HELP
(){
echo
"
${
SCRIPT_NAME
}
"
echo
" OPTIONS: [-h] [-help] 帮助信息"
echo
" [-l] [-list] 显示可以的下载列表"
...
...
@@ -49,129 +58,136 @@ function SHELL_FUNCTION_HELP(){
echo
" ./
${
SCRIPT_NAME
}
gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu ;#下载gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu的编译器"
echo
" ./
${
SCRIPT_NAME
}
gcc-arm-5.4-2017.02-x86_64-aarch64-qnx7.0.0-gnu ;#下载gcc-arm-5.4-2017.02-x86_64-aarch64-qnx7.0.0-gnu的编译器"
}
function
SHELL_FUNCTION_PASER
(){
unset
SHELL_OPTIONS_HELP
unset
SHELL_OPTIONS_LIST
if
[
-z
"
$1
"
]
;
then
SHELL_OPTIONS_HELP
=
1
;
return
fi
for
argv
in
$*
;
do
if
[
"
$argv
"
==
"-h"
]
||
[
"
$argv
"
==
"-help"
]
;
then
SHELL_OPTIONS_HELP
=
1
;
fi
if
[
"
$argv
"
==
"-l"
]
||
[
"
$argv
"
==
"-list"
]
;
then
SHELL_OPTIONS_LIST
=
1
fi
done
}
function
SHELL_FUNCTION_KERNAL_WGET
(){
#echo "git_repository (git) : ${git_repository_git}"
echo
"git_repository (https) :
${
git_repository_https
}
"
git init 1>log.txt 2>&1
git remote add origin
${
git_repository_address
}
1>log.txt 2>&1
git remote show origin
>
git_remote.log.txt
function
GIT_URL_ANALYSIS
()
{
local
GIT_URL
=
"
$1
"
cat
git_remote.log.txt |
grep
"gcc"
|
sed
-e
's/^[ ]*//g'
|
cut
-d
' '
-f
1
>
git_branch.log.txt
if
[
-f
"
${
SCRIPT_PATH
}
/.git_url.cfg"
]
;
then
GIT_URL
=
$(
cat
"
${
SCRIPT_PATH
}
/.git_url.cfg"
)
echo_debug
"GIT_URL file loading (
${
GIT_URL
}
)"
fi
if
[
${
SHELL_OPTIONS_LIST
}
]
;
then
echo
"[git branch list]"
cat
-n
git_branch.log.txt
if
[[
"
${
GIT_URL
}
"
=
~
"git@"
]]
;
then
echo_debug
"GIT_URL is git mode (
${
GIT_URL
}
)"
local
GIT_URL_TEMP1
=
${
GIT_URL
/git@/
}
local
GIT_URL_TEMP2
=
${
GIT_URL_TEMP1
#*
:
}
local
GIT_URL_TEMP3
=
${
GIT_URL_TEMP2
##*/
}
GIT_ADDRESS
=
${
GIT_URL_TEMP1
%%
:
*
}
GIT_GROUP
=
${
GIT_URL_TEMP2
%/*
}
GIT_PROJECT
=
${
GIT_URL_TEMP3
%.*
}
elif
[[
"
${
GIT_URL
}
"
=
~
"https://"
]]
;
then
echo_debug
"GIT_URL is https mode (
${
GIT_URL
}
)"
local
GIT_URL_TEMP1
=
${
GIT_URL
/https
:
\/\//
}
local
GIT_URL_TEMP2
=
${
GIT_URL_TEMP1
#*/
}
local
GIT_URL_TEMP3
=
${
GIT_URL_TEMP2
##*/
}
GIT_ADDRESS
=
${
GIT_URL_TEMP1
%%/*
}
GIT_GROUP
=
${
GIT_URL_TEMP2
%/*
}
GIT_PROJECT
=
${
GIT_URL_TEMP3
%.*
}
else
echo_error
"GIT_URL can not parser (
${
GIT_URL
}
)"
return
fi
for
argv
in
$*
;
do
cat
git_branch.log.txt |
grep
"
${
argv
}
"
>
git_branch.log.txt.next
if
[[
!
-s
git_branch.log.txt.next
]]
;
then
cat
git_branch.log.txt |
grep
"
${
argv
}
"
>
git_branch.log.txt.next
fi
mv
git_branch.log.txt.next git_branch.log.txt
done
echo_debug
"GIT_ADDRESS=
${
GIT_ADDRESS
}
"
echo_debug
"GIT_GROUP=
${
GIT_GROUP
}
"
echo_debug
"GIT_PROJECT=
${
GIT_PROJECT
}
"
}
git_branch
=
$(
cat
git_branch.log.txt |
head
-n
1
)
git_branch
=
`
echo
${
git_branch
}
`
git_branch
=
${
git_branch
%% *
}
echo
"git_branch :
${
git_branch
}
"
echo
"wget_cmd : wget https://
${
git_address
}
/
${
git_group
}
/
${
git_project
}
/-/archive/
${
git_branch
}
/
${
git_project
}
-
${
git_branch
}
.tar.gz"
function
GIT_DOWNLOAD_USE_CLONE
(){
rm
${
git_project
}
-
${
git_branch
}
.tar.gz 1>log.txt 2>&1
wget https://
${
git_address
}
/
${
git_group
}
/
${
git_project
}
/-/archive/
${
git_branch
}
/
${
git_project
}
-
${
git_branch
}
.tar.gz
-q
--show-progress
tar
zxf
${
git_project
}
-
${
git_branch
}
.tar.gz
local
PWD_CURR
=
$(
pwd
)
local
TEMP_DIRNAME
=
$(
date
"+%Y.%m.%d.%H.%M.%S"
)
wget https://
${
git_address
}
/
${
git_group
}
/
${
git_project
}
/-/archive/
${
git_branch_common
}
/
${
git_project
}
-
${
git_branch_common
}
.tar.gz
-q
--show-progress
tar
zxf
${
git_project
}
-
${
git_branch_common
}
.tar.gz
rm
toolchain-
${
git_branch_common
}
/README.md
local
git_repository_git
=
"git@
${
GIT_ADDRESS
}
:
${
GIT_GROUP
}
/
${
GIT_PROJECT
}
.git"
local
git_repository_https
=
"https://
${
GIT_ADDRESS
}
/
${
GIT_GROUP
}
/
${
GIT_PROJECT
}
.git"
local
git_repository_address
=
${
git_repository_https
}
rm
-rf
../
${
git_branch
}
mkdir
-p
../
${
git_branch
}
mv
toolchain-
${
git_branch
}
/
*
../
${
git_branch
}
/
mv
toolchain-
${
git_branch_common
}
/
*
../
${
git_branch
}
/
echo_debug
"git_repository (git) :
${
git_repository_git
}
"
echo_debug
"git_repository (https) :
${
git_repository_https
}
"
echo_debug
"git_repository_address :
${
git_repository_address
}
"
return
}
function
SHELL_FUNCTION_KERNAL_GIT_CLONE
(){
#echo "git_repository (git) : ${git_repository_git}"
echo
"git_repository (https) :
${
git_repository_https
}
"
git init 1>log.txt 2>&1
git remote add origin
${
git_repository_address
}
1>log.txt 2>&1
git remote show origin
>
git_remote.log.txt
mkdir
-p
TEMP_
${
TEMP_DIRNAME
}
cd
TEMP_
${
TEMP_DIRNAME
}
git init 1>log.txt 2>&1
git remote add origin
${
git_repository_address
}
1>log.txt 2>&1
git remote show origin
>
git_remote.log.txt
cat
git_remote.log.txt |
grep
"gcc"
|
sed
-e
's/^[ ]*//g'
|
cut
-d
' '
-f
1
>
git_branch
.log.txt
cat
git_remote.log.txt |
grep
"gcc"
|
sed
-e
's/^[ ]*//g'
|
cut
-d
' '
-f
1
>
GIT_BRANCH
.log.txt
if
[
${
SHELL_OPTIONS_LIST
}
]
;
then
echo
"[git branch list]"
cat
-n
git_branch.log.txt
return
fi
for
argv
in
$*
;
do
cat
git_branch.log.txt |
grep
"
${
argv
}
"
>
git_branch.log.txt.next
if
[[
!
-s
git_branch.log.txt.next
]]
;
then
cat
git_branch.log.txt |
grep
"
${
argv
}
"
>
git_branch.log.txt.next
fi
if
[
"
${
OPTIONS_LIST_INFO
}
"
==
"1"
]
;
then
echo
"[git branch list]"
cat
-n
GIT_BRANCH.log.txt
cd
${
PWD_CURR
}
rm
-rf
TEMP_
${
TEMP_DIRNAME
}
return
fi
mv
git_branch.log.txt.next git_branch.log.txt
done
for
argv
in
$*
;
do
cat
GIT_BRANCH.log.txt |
grep
"
${
argv
}
"
>
GIT_BRANCH.log.txt.next
if
[[
!
-s
GIT_BRANCH.log.txt.next
]]
;
then
cat
GIT_BRANCH.log.txt |
grep
"
${
argv
}
"
>
GIT_BRANCH.log.txt.next
fi
mv
GIT_BRANCH.log.txt.next GIT_BRANCH.log.txt
done
GIT_BRANCH
=
$(
cat
GIT_BRANCH.log.txt |
head
-n
1
)
GIT_BRANCH
=
`
echo
${
GIT_BRANCH
}
`
GIT_BRANCH
=
${
GIT_BRANCH
%% *
}
echo
"GIT_BRANCH :
${
GIT_BRANCH
}
"
echo
"git_cmd : git clone
${
git_repository_https
}
--depth 1 -b
${
GIT_BRANCH
}
"
git clone
${
git_repository_https
}
--quiet
--depth
1
-b
${
GIT_BRANCH
}
mv
${
GIT_PROJECT
}
${
GIT_PROJECT
}
-
${
GIT_BRANCH
}
git_branch
=
$(
cat
git_branch.log.txt |
head
-n
1
)
git_branch
=
`
echo
${
git_branch
}
`
git_branch
=
${
git_branch
%% *
}
echo
"git_branch :
${
git_branch
}
"
echo
"git_cmd : git clone
${
git_repository_https
}
--depth 1 -b
${
git_branch
}
"
cd
${
PWD_CURR
}
git clone
${
git_repository_https
}
--quiet
--depth
1
-b
${
git_branch
}
mv
${
git_project
}
toolchain-
${
git_branch
}
git clone
${
git_repository_https
}
--quiet
--depth
1
-b
${
git_branch_common
}
mv
${
git_project
}
toolchain-
${
git_branch_common
}
mkdir
-p
TEMP_
${
TEMP_DIRNAME
}
cd
TEMP_
${
TEMP_DIRNAME
}
rm
-rf
../
${
git_branch
}
mkdir
-p
../
${
git_branch
}
mv
toolchain-
${
git_branch
}
/
*
../
${
git_branch
}
/
mv
toolchain-
${
git_branch_common
}
/
*
../
${
git_branch
}
/
git clone
${
git_repository_https
}
--quiet
--depth
1
-b
${
OPTIONS_COMMON_BRANCH
}
mv
${
GIT_PROJECT
}
${
GIT_PROJECT
}
-
${
OPTIONS_COMMON_BRANCH
}
cd
${
PWD_CURR
}
if
[
-d
"
${
PWD_CURR
}
/
${
GIT_BRANCH
}
"
]
;
then
echo_debug
"Folder exists. (
${
PWD_CURR
}
/
${
GIT_BRANCH
}
)"
if
[[
${
GIT_BRANCH
##*/
}
}
=
~
"gcc"
]]
;
then
echo_debug
"Folder name. (
${
GIT_BRANCH
##*/
}
})"
rm
-rf
${
PWD_CURR
}
/
${
GIT_BRANCH
}
/
*
fi
fi
mkdir
-p
${
PWD_CURR
}
/
${
GIT_BRANCH
}
mv
TEMP_
${
TEMP_DIRNAME
}
/
${
GIT_PROJECT
}
-
${
OPTIONS_COMMON_BRANCH
}
/
*
${
PWD_CURR
}
/
${
GIT_BRANCH
}
mv
TEMP_
${
TEMP_DIRNAME
}
/
${
GIT_PROJECT
}
-
${
GIT_BRANCH
}
/
*
${
PWD_CURR
}
/
${
GIT_BRANCH
}
rm
-rf
TEMP_
${
TEMP_DIRNAME
}
return
}
SHELL_FUNCTION_PASER
$*
if
[
${
SHELL_OPTIONS_HELP
}
]
;
then
SHELL_FUNCTION_HELP
else
TEMP_DIR
=
TEMP_
$(
date
"+%Y.%m.%d.%H.%M.%S"
)
mkdir
-p
${
TEMP_DIR
}
cd
${
TEMP_DIR
}
SHELL_FUNCTION_KERNAL_GIT_CLONE
$*
cd
..
rm
-rf
./
${
TEMP_DIR
}
fi
\ No newline at end of file
function
SCRIPT_CODE_ALL
()
{
echo_title
"[Git Branch Auto Download]"
SCRIPT_ARGV_PARSER
$*
if
[
"
${
OPTIONS_HELP_INFO
}
"
==
"1"
]
;
then
FUNCTION_HELP
return
fi
GIT_URL_ANALYSIS
"
${
OPTIONS_GIT_URL
}
"
GIT_DOWNLOAD_USE_CLONE
"
${
PWD_CURR
}
"
"
$*
"
}
SCRIPT_CODE_ALL
$*
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录