【注】本文最后更新于 October 18, 2018,文中内容可能已经过时。
AUR 里的构建脚本常常需要从 github 拉取源代码,
然而没有加 --depth 1
的 git clone
把大量流量花在了下载对于构建毫无用处的提交记录等东西上面.
尤其是安装主题这种东西的时候, clone 下来几百 MB, 结果构建完得到一个几 MB 的包…
暴力的解决方案:
打开 /usr/share/makepkg/source/git.sh
, 其中有一段这样的代码
1
2
3
4
5
|
if ! git clone --mirror "$url" "$dir"; then
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
exit 1
fi
|
改成这样, 也就是在外面又加了一层 if. 不直接改在原来的基础上加是因为有些网站不支持 --depth
1
2
3
4
5
6
7
|
if ! git clone --depth=1 --mirror "$url" "$dir"; then
if ! git clone --mirror "$url" "$dir"; then
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
exit 1
fi
fi
|
同理, 还有如下代码
1
2
3
4
|
if ! git fetch --all -p; then
# only warn on failure to allow offline builds
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
fi
|
….改成
1
2
3
4
5
6
|
if ! git fetch --depth=1 -p; then
if ! git fetch --all -p; then
# only warn on failure to allow offline builds
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
fi
fi
|
这样速度就令人满意多了, 对于大部分构建脚本应该都没问题,
遇到问题再改吧 (
文章作者
aloxaf
上次更新
2018-10-18
许可协议
知识共享署名-非商业性使用 4.0 国际许可协议