Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
3c7fad8a
提交
3c7fad8a
authored
4月 27, 2016
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
address some CR feedback
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
上级
06a8a5bd
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
21 行删除
+23
-21
dist_get
bin/dist_get
+23
-21
没有找到文件。
bin/dist_get
浏览文件 @
3c7fad8a
#!/bin/
ba
sh
#!/bin/sh
die
()
{
echo
"
$@
"
>
&2
...
...
@@ -14,46 +14,48 @@ check_writeable() {
}
download
()
{
local
url
=
"
$1
"
local
output
=
"
$2
"
dl_
url
=
"
$1
"
dl_
output
=
"
$2
"
if
[
-z
"
$url
"
]
||
[
-z
"
$output
"
]
;
then
die
"download takes exactly two arguments. was given '
$@
'"
fi
test
"$#"
-eq
"2"
||
die
"download requires exactly two arguments, was given
$@
"
if
!
check_writeable
"
$output
"
;
then
die
"download error: cannot write to
$output
"
fi
if
have_binary wget
;
then
printf
'Using wget to download "%s" to "%s"\n'
"
$url
"
"
$output
"
printf
'
==>
Using wget to download "%s" to "%s"\n'
"
$url
"
"
$output
"
wget
"
$url
"
-O
"
$output
"
elif
have_binary curl
;
then
printf
'Using curl to download "%s" to "%s"\n'
"
$url
"
"
$output
"
printf
'
==>
Using curl to download "%s" to "%s"\n'
"
$url
"
"
$output
"
curl
--silent
"
$url
"
>
"
$output
"
elif
have_binary fetch
;
then
printf
'Using fetch to download "%s" to "%s"\n'
"
$url
"
"
$output
"
printf
'
==>
Using fetch to download "%s" to "%s"\n'
"
$url
"
"
$output
"
fetch
"
$url
"
-o
"
$output
"
else
die
"no binary found to download
$url
. exiting."
fi
if
[
"
$?
"
-ne
0
]
;
then
return
$?
fi
echo
"==> download complete!"
}
unarchive
()
{
local
archivetype
=
"
$1
"
local
infile
=
"
$2
"
local
outfile
=
"
$3
"
local
distname
=
"
$4
"
ua_
archivetype
=
"
$1
"
ua_
infile
=
"
$2
"
ua_
outfile
=
"
$3
"
ua_
distname
=
"
$4
"
if
!
check_writeable
"
$outfile
"
;
then
die
"unarchive error: cannot write to
$outfile
"
if
!
check_writeable
"
$
ua_
outfile
"
;
then
die
"unarchive error: cannot write to
$
ua_
outfile
"
fi
case
$archivetype
in
case
"
$ua_archivetype
"
in
tar.gz
)
if
have_binary
tar
;
then
echo
"==> using 'tar' to extract binary from archive"
cat
"
$
infile
"
|
tar
-O
-z
-x
"
$distname
/
$distname
"
>
"
$
outfile
"
cat
"
$
ua_infile
"
|
tar
-O
-z
-x
"
$ua_distname
/
$ua_distname
"
>
"
$ua_
outfile
"
else
die
"no binary on system for extracting tar files"
fi
...
...
@@ -61,16 +63,16 @@ unarchive() {
zip
)
if
have_binary unzip
;
then
echo
"==> using 'unzip' to extract binary from archive"
unzip
-p
"
$
infile
"
"
$distname
/
$distname
"
>
"
$
outfile
"
unzip
-p
"
$
ua_infile
"
"
$ua_distname
/
$ua_distname
"
>
"
$ua_
outfile
"
else
die
"no installed method for extracting .zip archives"
fi
;;
*
)
die
"unrecognized archive type '
$archivetype
'"
die
"unrecognized archive type '
$
ua_
archivetype
'"
esac
chmod +x
"
$outfile
"
chmod +x
"
$
ua_
outfile
"
}
get_go_vars
()
{
...
...
@@ -142,5 +144,5 @@ fi
unarchive
"
$archive
"
"
$tmpfi
"
"
$outpath
"
"
$distname
"
if
[
$?
-ne
0
]
;
then
die
"failed to exract archive
$tmpfi
"
die
"failed to ex
t
ract archive
$tmpfi
"
fi
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论