一、安装mac版docker,地址:https://www.docker.com/

二、docker run -td --name m8 --privileged=true -v 源路径:挂载路径 -p2210:22 ubuntu:20.04
(直接启动ubuntu:20.04容器,没有下载会自动下载,将主机内的android源码路径映射到容器内部路径下面)

三、进入容器的bash环境 docker exec -it aosp /bin/bash

四、修改ubuntu源

docker cp 容器名:/etc/apt/sources.list 宿主机路径(拷贝出来配置文件)

修改成以下内容:
deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse

docker cp 宿主机路径 容器名:/etc/apt/sources.list (拷贝回去)

五、执行 sudo apt-get update 更新源

六、sudo apt-get install curl python python3 git wget vim (为了使用repo,源码已在宿主机上拉取,但是docker容器也需要拉取更新,这样针对android源码操作完全可由容器操作)

curl https://storage.googleapis.com/git-repo-downloads/repo -o /bin/repo 安装repo

chmod 777 /bin/repo

七、在容器内更新源码repo sync -j8

八、安装必须得依赖:
//谷歌官网推荐
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig bc libssl-dev

九、mac版docker开启virtiofs需要 更新sed版本
wget https://ftp.gnu.org/gnu/sed/sed-4.9.tar.gz
tar xzvf ./sed-4.9.tar.gz
cd ./sed-4.9
./configure
make install

十、有些项目还会依赖rsync cpio dpmod工具,可自行安装

sudo apt-get install rsync cpio kmod

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注