国内 repo 拉取android源码

方法1:

修改hosts

sudo gedit /etc/hosts


在hosts文件中加入
203.208.49.187 googlesource.com
203.208.49.187 android.googlesource.com
203.208.49.187 gerrit.googlesource.com

注意,203.208.49.187只是我这里临时获取的ip,请替换成适合你的地区的ip,具体获取方法如下

ping ad.doubleclick.net


如果方法1出现问题可以使用方法2

方法2:

Shadowsocks代理

修改repo脚本使用代理  Shadowsocks账号和使用方法可以自行百度

import sys ##repo脚本的原有的代码
#add for google source 
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 1080)
socket.socket = socks.socksocket
#add end 

127.0.0.1 1080 为代理的ip和端口号


repo脚本仅供参保考


#!/bin/bash

in=0
sy=0

if [[ ! -d .repo ]]; then
#repo init
  echo "================ Start repo init ================="
  repo init -u git://github.com/CyanogenMod/android.git -b cm-12.0

  while [[ $? != 0 ]]
  ┊ do
  ┊ ┊ let "in++"
  ┊ ┊ echo "/============== repo init failed $in times Retry ============="
  ┊ ┊ repo init -u git://github.com/CyanogenMod/android.git -b cm-12.0
  ┊ ┊ sleep 1
  ┊ done

#repo sync

  echo "================ Start repo sync ================="
  repo sync
  while [[ $? != 0 ]]
  ┊ do
  ┊ ┊ let "sy++"
  ┊ ┊ echo "/============== repo sync failed $sy times with init $in times Retry ============="
  ┊ ┊ repo sync
  ┊ ┊ sleep 1
  ┊ done

#repo sync

else
  echo "================ Start repo sync ================="
  repo sync
  while [[ $? != 0 ]]
  ┊ do
  ┊ ┊ let "sy++"
  ┊ ┊ echo "/============== repo sync failed $sy times with init $in times Retry ============="
  ┊ ┊ repo sync
  ┊ ┊ sleep 1
  ┊ done
fi


发布了13 篇原创文章 · 获赞 13 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq410942197/article/details/42969731