环境准备:
- 阿里云服务器16核32G 地区:美西
- 数据盘300G
- 服务器类型ubuntu
挂载数据盘:
#查看磁盘挂载情况
df
#新建一个dir并且把磁盘挂载到该目录
mkdir /aosp
mount /dev/vdb /aosp
环境搭建
#update apt
apt-get update
apt-get dist-upgrade -y
apt-get install build-essential python-dev python-setuptools python-smbus -y
apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev -y
apt-get install zlib1g-dev libsqlite3-dev tk-dev -y
apt-get install libssl-dev openssl -y
apt-get install libffi-dev -y
# download openssl
if [ ! -d openssl ] ;
then
mkdir openssl && cd openssl
wget -c https://www.openssl.org/source/openssl-1.1.1d.tar.gz --no-check-certificate
tar -zxf openssl-1.1.1d.tar.gz
cd openssl-1.1.1d
./config --prefix=/usr/local --openssldir=/usr/local/openssl
make -j4 && make install
ln -s /usr/local/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1
ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1
fi
# download python
if [ ! -d python ] ;
then
mkdir python && cd python
wget -c https://www.python.org/ftp/python/3.7.15/Python-3.7.15.tgz
tar -xzf Python-3.7.15.tgz
#cd Python-3.7.15
fi
#modify python moudles setup.dist
SETUP_DIST_PATH=/root/python/Python-3.7.15/Modules/Setup.dist
sed -i 's/#SSL=\/usr\/local\/ssl/SSL=\/usr\/local _ssl _ssl.c -DUSE_SSL -I$(SSL)\/include -I$(SSL)\/include\/openssl -L$(SSL)\/lib -lssl -lcrypto/g' $SETUP_DIST_PATH
#compile python3.7
PYTHON_37_PATH=/root/python/Python-3.7.15
cd $PYTHON_37_PATH
./configure
make -j8
make install
#modified python3->python
which python
rm -rf /usr/bin/python
ln -s /usr/local/bin/python3.7 /usr/bin/python
#check python version
python --version
#install git
apt-get install git -y
#config git
git config --global user.name "ololee"
git config --global user.email "ololeecn@gmail.com"
#download repo
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
#setup repo
echo 'export PATH=/root/bin:$PATH'>>/root/.bashrc
source /root/.bashrc
测试环境
-
python 版本
python --version
-
import ssl
出现这样的原因是因为没有_ssl这个module,那么只好重新编译python,然后修改
Modules/Setup.dist将以下内容修改后保存,重新编译#SSL=/usr/local/ssl #_ssl _ssl.c \ # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ # -L$(SSL)/lib -lssl -lcrypto将修改为:
SSL=/usr/local _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto -
repo init
有可能是因为网络无法访问google,那么可以找到合适的网络环境或者使用清华源 mirrors.tuna.tsinghua.edu.cn/help/AOSP/因为SSL:
CERTIFICATE_VERIFY_FAILED问题,可以修改/root/bin/repo(新增如下内容)import ssl ssl._create_default_https_context = ssl._create_unverified_context
下载AOSP源码
因为我想下载android11的源码,所以我需要删除/aosp/.repo,然后重新执行
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r48
版本号可以在source.android.com/docs/setup/…找到
- repo 版本过旧
cp /aosp/.repo/repo/repo /root/bin/repo