A_01.Aosp11源码下载

A_01.Aosp11源码下载

本节主要内容:

  • 下载Aosp 11源码

1.前期环境准备

2.源码下载

由于直接使用google官方下载源很难下载,以下使用清华源下载安卓源码。

(1).创建源码目录Aosp11

qiang@ubuntu:~$ mkdir Aosp11
qiang@ubuntu:~$ cd Aosp11/
qiang@ubuntu:~/Aosp11$ 
qiang@ubuntu:~/Aosp11$ 

(2).安装repo工具以及adb

qiang@ubuntu:~/Aosp11$ mkdir ~/bin
qiang@ubuntu:~/Aosp11$ export PATH=~/bin:$PATH
qiang@ubuntu:~/Aosp11$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo  > ~/bin/repo
qiang@ubuntu:~/Aosp11$ chmod a+x ~/bin/repo
qiang@ubuntu:~/Aosp11$ export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
qiang@ubuntu:~/Aosp11$ ln -s /usr/bin/python3 /usr/bin/python
qiang@ubuntu:~/Aosp11$ sudo apt install android-tools-adb
qiang@ubuntu:~/Aosp11$ sudo apt install android-tools-fastboot

为了以后开机启动之后安装的repo工具立即生效,将repo工具路径加入.bashrc文件中。如下所示:

iang@ubuntu:~/Aosp11$ vim ~/.bashrc 

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# ///ADD START
export PATH=~/bin:$PATH
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
# ///ADD END
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac
# 后面内容省略.....

qiang@ubuntu:~/Aosp11$ source  ~/.bashrc 
qiang@ubuntu:~/Aosp11$ 

(3).配置git邮件地址

以下配置邮件地址需要你个人的邮件地址。

qiang@ubuntu:~/Aosp11$ git config --global user.name  "test007"
qiang@ubuntu:~/Aosp11$ git config --global user.email  "test007@gmail.com"

(4).使用repo init初始化下载指定版本源码

qiang@ubuntu:~/Aosp11$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/
AOSP/platform/manifest -b android-11.0.0_r46

(5).使用repo sync下载源码

qiang@ubuntu:~/Aosp11$ repo sync -j4  -d --force-sync --no-clone-bundle

3.使用不死挂机脚本下载源码

由于下载源码需要很长时间。中途会难免意外终止退出的情况。为了防止这种情况,适应挂机下载的需求。可以使用如下download.sh脚本进行挂机下载。脚本如下:

qiang@ubuntu:~/Aosp11$ cat download.sh 
#!/bin/bash
echo "==========start repo sync==="
PATH=~/bin:$PATH
git config --global http.postBuffer 524288000
git config --global http.sslVerify false
git config --global http.sslverify false
git config --global url.https://mirrors.tuna.tsinghua.edu.cn/git/
AOSP/.insteadof https://android.googlesource.com

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/
manifest -b android-11.0.0_r46

repo sync -j4  -d --force-sync --no-clone-bundle

while [ $?!=0 ];
do
   echo "===resync==="      
   repo sync -j4  -d --force-sync --no-clone-bundle
done

在终端执行download.sh脚本,就可以挂机下载源码了。执行参考如下:

qiang@ubuntu:~/Aosp11$ pwd
/home/qiang/Aosp11
qiang@ubuntu:~/Aosp11$ ls -la download.sh 
-rwxrwxr-x 1 qiang qiang 564 Jul 24 08:47 download.sh
qiang@ubuntu:~/Aosp11$ ./download.sh 
==========start repo sync===

4.删除下载缓存释放更多空间

安卓源码repo工具下载过程中会在源码根目录下面生成.repo缓存目录。该目录占用空间很大。源码下载完成之后,可以将.repo删除释放更多空间处理。以下使用du命令查看.repo目录占用情况。如下所示:

qiang@ubuntu:~/Aosp11$ pwd
/home/qiang/Aosp11
qiang@ubuntu:~/Aosp11$ cd .repo/
qiang@ubuntu:~/Aosp11/.repo$ du -h --max-depth=1  ./
47G	./project-objects
6.4M	./repo
1011M	./projects
37M	./manifests.git
88K	./manifests
48G	.
qiang@ubuntu:~/Aosp11/.repo$ 
qiang@ubuntu:~/Aosp11/.repo$ 

以上命令显示.repo占用48G的空间,可以使用rm命令删除相应的目录。如下所示:

qiang@ubuntu:~/Aosp11$ 
qiang@ubuntu:~/Aosp11$ pwd
/home/qiang/Aosp11
qiang@ubuntu:~/Aosp11$ rm -rf .repo/
qiang@ubuntu:~/Aosp11$ 
qiang@ubuntu:~/Aosp11$ 
qiang@ubuntu:~/Aosp11$ 

视频观看地址:Aosp11源码下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xiaomaNo01

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值