> 文档中心 > 一键配置Ubuntu的OpenHarmony基础编译环境

一键配置Ubuntu的OpenHarmony基础编译环境


一键配置Ubuntu的OpenHarmony基础编译环境

一、配置前说明

  • 该更新源仅适用于Ubuntu以下系列

    Ubuntu18.04

    Ubuntu20.04

    Ubuntu22.04

    强烈推荐Ubuntu20.04,本人使用的一直都是Ubuntu20.04

  • wsl的配置参见

    如果使用的window wsl安装,则关于wsl配置可参考: Win10电脑安装配置WSL方法

  • 如果是华为公司内网请慎重处理

二、一键自动化配置

一键自动化配置必须是root账号,自动化主要是配置以下功能:

  • apt源替换成国内的阿里云的源

  • 配置shbash

  • 配置usr/include/asm软连接

  • 安装UbuntuOpenHarmony的基础依赖包

  • git lfs安装

  • 配置repo工具

  • 安装vim

    这个是个人的vim配置,不需要可以安装完成后删除~/.vim~/.vimrc即可

apt-get -f -y install gitapt-get -f -y install dos2unixgit clone https://gitee.com/personal-summary/openharmony_env_init.gitcd openharmony_env_initbash root_init.sh

如果不使用自动化,可以按照如下手动安装

三、apt源替换

sudo sucd /etc/apt/mv sources.list sources.list_bakvim sources.list添加以下内容到sources.list中deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
apt-get updateapt-get upgrade

四、root权限安装的工具包

4.1 直接安装的程序和依赖包(必须一个一个安装)

apt-get -f -y install apt-utilsapt-get -f -y install vimapt-get -f -y install software-properties-commonapt-get -f -y install openssh-serverapt-get -f -y install iputils-pingapt-get -f -y install curlapt-get -f -y install net-toolsapt-get -f -y install bsdmainutilsapt-get -f -y install kmodapt-get -f -y install bcapt-get -f -y install rsyncapt-get -f -y install gawkapt-get -f -y install sshapt-get -f -y install ccacheapt-get -f -y install zipapt-get -f -y install python-devapt-get -f -y install makeapt-get -f -y install m4apt-get -f -y install gcc-multilibapt-get -f -y install ca-certificates-javaapt-get -f -y install unzipapt-get -f -y install python3-yamlapt-get -f -y install perlapt-get -f -y install opensslapt-get -f -y install libssl1.1apt-get -f -y install gnupgapt-get -f -y install xsltprocapt-get -f -y install x11proto-core-devapt-get -f -y install tclapt-get -f -y install python3-cryptoapt-get -f -y install python-cryptoapt-get -f -y install libxml2-utilsapt-get -f -y install libxml2-devapt-get -f -y install libx11-devapt-get -f -y install libssl-devapt-get -f -y install libgl1-mesa-devapt-get -f -y install lib32z1-devapt-get -f -y install lib32ncurses5-devapt-get -f -y install g++-multilibapt-get -f -y install flexapt-get -f -y install bisonapt-get -f -y install doxygenapt-get -f -y install gitapt-get -f -y install subversionapt-get -f -y install tofrodosapt-get -f -y install pigzapt-get -f -y install expectapt-get -f -y install python3-xlrd apt-get -f -y install git-coreapt-get -f -y install gperf apt-get -f -y install build-essentialapt-get -f -y install zlib1g-devapt-get -f -y install libc6-dev-i386apt-get -f -y install lib32z-devapt-get -f -y install openjdk-8-jdkapt-get -f -y install rubyapt-get -f -y install mtoolsapt-get -f -y install python3-pipapt-get -f -y install gcc-arm-linux-gnueabiapt-get -f -y install genext2fsapt-get -f -y install liblz4-toolapt-get -f -y install libssl-devapt-get -f -y install autoconfapt-get -f -y install pkg-configapt-get -f -y install zlib1g-devapt-get -f -y install libglib2.0-devapt-get -f -y install libmount-devapt-get -f -y install libpixman-1-devapt-get -f -y install libncurses5-devapt-get -f -y install exuberant-ctagsapt-get -f -y install silversearcher-agapt-get -f -y install libtinfo5apt-get -f -y install device-tree-compilerapt-get -f -y install libssl-devapt-get -f -y install libelf-devapt-get -f -y install dwarvesapt-get -f -y install gcc-arm-none-eabiapt-get -f -y install default-jdkapt-get -f -y install u-boot-toolsapt-get -f -y install mtd-utilsapt-get -f -y install sconsapt-get -f -y install automakeapt-get -f -y install libtinfo5apt-get -f -y install gcc-multilibapt-get -f -y install libtoolapt-get -f -y install libgmp-devapt-get -f -y install texinfoapt-get -f -y install mpcapt-get -f -y install autotools-devapt-get -f -y install libmpc-devapt-get -f -y install libmpfr-devapt-get -f -y install libgmp-devapt-get -f -y install patchutilsapt-get -f -y install libexpat-devapt-get -f -y install libfdt-devapt-get -f -y install libncursesw5-devapt-get -f -y install cmakeapt-get -f -y install wgetapt-get -f -y install libelf-devel

4.2 配置sh为bash

ls -l /bin/sh    #如果显示为“/bin/sh -> bash”则为正常,否则请按以下方式修改: sudo dpkg-reconfigure dash   #然后选择no

4.3 git lfs安装

curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bashapt-get install git-lfsapt install git-lfsgit lfs install

4.4 repo工具安装

curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > repochmod a+x repomv repo /usr/local/bin/

五、个人账号必须配置的工具

5.1 Git配置

git config --global user.name "yourname"git config --global user.email "your-email-address"git config --global core.editor vimgit config --global credential.helper store

5.2 安装hb命令

# 方法一:# 下载一套master分支的代码然后进入root目录下执行pip3 install build/litevim ~/.bashrcexport PATH=$PATH:~/.local/binsource ~/.bashrc# 方法二:python3 -m pip install --user ohos-buildvim ~/.bashrcexport PATH=$PATH:~/.local/binsource ~/.bashrc# 方法三:# 安装指定版本,君正使用的是0.4.3python3 -m pip install ohos-build==0.4.3vim ~/.bashrcexport PATH=$PATH:~/.local/binsource ~/.bashrc

5.3 卸载hb命令

pip3 uninstall ohos-build