替换华为源
bash
sudo sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list && sudo sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list
安装依赖工具
如果是ubuntu20.04系统请直接安装python3.9,如果是ubuntu18.04请改为安装python3.8
bash
sudo apt-get update && sudo apt-get install -y apt-utils binutils bison flex bc build-essential make mtd-utils gcc-arm-linux-gnueabi u-boot-tools python3.9 python3-pip git zip unzip curl wget gcc g++ ruby dosfstools mtools default-jre default-jdk scons python3-distutils perl openssl libssl-dev cpio git-lfs m4 ccache zlib1g-dev tar rsync liblz4-tool genext2fs binutils-dev device-tree-compiler e2fsprogs git-core gnupg gnutls-bin gperf lib32ncurses5-dev libffi-dev zlib* libelf-dev libx11-dev libgl1-mesa-dev lib32z1-dev xsltproc x11proto-core-dev libc6-dev-i386 libxml2-dev lib32z-dev libdwarf-dev rsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5 libncurses5-dev libncursesw5 libstdc++6 locales doxygen libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev
建立python软连接
bash
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
配置SSH公钥
bash
#生成本地ssh秘钥
ssh-keygen
bash
cat ~/.ssh/id_rsa.pub
将cat的所有内容拷贝添加到gitee等开源鸿蒙的代码托管网站
配置git信息
bash
#配置用户名和邮箱
git config --global user.name "yourname"(用户名)
git config --global user.email "your email address"(邮箱)
#设置全局帐号密码
git config --global credential.helper store
配置repo
在root用户下
bash
curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo
bash
#设置权限
chmod a+x /usr/local/bin/repo
bash
#安装码云repo工具
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
拉取代码
bash
repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
repo sync -c # 以后每天同步远程仓的修改,只需要执行这一条命令即可
编译前配置
bash
#安装hb
pip3 install --user ohos-build
bash
配置hb环境变量。
执行命令打开配置文件:vi ~/.bashrc ,
末尾添加:export PATH=~/.local/bin:$PATH
执行命令:source ~/.bashrc
源码根目录下执行命令:hb