• 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$ 
    
    • 1
    • 2
    • 3
    • 4

    (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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    为了以后开机启动之后安装的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$ 
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    (3).配置git邮件地址

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

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

    (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
    
    • 1
    • 2

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

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

    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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    在终端执行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===
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    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$ 
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    以上命令显示.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$ 
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

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

  • 相关阅读:
    RabbitMQ-死信队列
    HarmonyOS应用开发
    工业物联网解决方案:PLC数据上云
    小伙伴面经分享京东+面试八股文整套面试真题(含答案)
    如何从0到1设计积分系统?
    Vue3中使用provide和inject依赖注入完成父组件和孙子组件之间参数传递
    ctrl+k,ctrl+l无法切换到时限文件
    【HBZ分享】云数据库如何定位慢查询
    【应用统计学】描述数据分布集中趋势
    网络原理必知会
  • 原文地址:https://blog.csdn.net/xiaomaNo01/article/details/126242471