安裝依賴的庫,順便把vim 也安裝一下
sudo apt-get install vim
sudo apt-get install git gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
找不到libncurses5,可以使用本機更高版本替代
sudo ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6.4 /usr/lib/x86_64-linux-gnu/libncurses.so.5
sudo ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6.4 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
注意下邊的命令下載的不是repo的python代碼,而是網站的錯誤信息html
curl -L https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
手動在瀏覽器中輸入 https://mirrors.tuna.tsinghua.edu.cn/git/git-repo ,然后保存以下,修改名字為repo
mkdir ~/bin
cp ~/Downloads/git-repo ~/bin/repo
cd ~/bin
chmod +x repo
在 ~/.bashrc 文件尾部增加如下內容
export PATH=~/bin/:$PATH
export REPO_URL='http://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
注意一下,這里的清華源的都是http,而不是https,主要是https下載比較慢,都是源代碼,也沒啥不安全的。
配置一下git信息
git config --global user.email “you@example.com”
git config --global user.name “Your Name”
repo init -u http://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b master
source build/envsetup.sh
lunch aosp_cf_x86_64_phone-trunk_staging-userdebug
find ./ -name “index.lock” -exec rm -f {} ;
find ./ -name “index.lock” -exec rm -i {} ;
sudo find ./ -name “index.lock” -exec rm -f {} ;
repo sync -j8 --force-sync --no-clone-bundle
參數說明:-j8:多線程加速(根據網絡調整)。--force-sync:強制覆蓋本地文件。--no-clone-bundle:繞過 Git 分發包(避免因分發包損壞導致失敗)。
repo forall -c ‘git clean -dfx; git reset --hard’
repo sync -c --no-tags -j8
定期校驗源碼完整性
repo forall -c ‘git fsck --full’
單獨同步問題模塊
repo sync -j4 device/google/gs-common
清理殘留文件
repo forall -c ‘git reset --hard HEAD; git clean -fdx’
rm -rf .repo/project-objects
進入問題項目的目錄(如 cd frameworks/base
)
rm -rf .git/index.lock # 確保鎖文件已清除
git clean -dfx # 刪除所有未跟蹤文件(慎用!先備份)
git reset --hard # 強制重置到遠程分支狀態
git fetch --all # 重新拉取遠程數據
git checkout -f # 強制切換分支(如當前分支)
git clean -dfx; git reset --hard