大多數(shù)博客和書籍提到獲取linux kernel 往往就是提供一條命令:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
或是
git clone https://github.com/torvalds/linux.git
甚至是直接從github上下載對應(yīng)releases的zip包爽冕。
在實際操作過程中我遇到了如下問題:
問題一、
git clone 到一半出現(xiàn)error:
error: RPC failed; result=18, HTTP code = 200B | 1 KiB/s
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: recursion detected in die handler
查找原因:curl 的默認(rèn)postBuffer值過小
解決方案:
git config http.postBuffer 524288000
問題二嫩码、
git clone 到一半出現(xiàn)另一個error:
error: RPC failed objects: 4851777, done.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
查找原因:國內(nèi)到github服務(wù)器或kernel.org服務(wù)器網(wǎng)速過慢(也許是我這網(wǎng)速太慢)呻拌,導(dǎo)致連接中斷。
解決方案:
方案1、到國內(nèi)代碼托管平臺搜索對應(yīng)的linux kernel source缀磕,git clone 后將origin地址更改成github即可。國內(nèi)的osc可以搜索到現(xiàn)成的linux kernel代碼劣光。
方案2袜蚕、需求git版本1.9以上
git clone https://github.com/torvalds/linux.git --depth=1
git fetch --unshallow
這個方法相當(dāng)于先下載source tree 中的一個版本然后補(bǔ)全,因為是階段式的所以中斷的概率較小绢涡,我下載其中一個版本一次就成了牲剃,補(bǔ)全試了兩次成了,還是有運(yùn)氣成分雄可。