• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 搭建Ubuntu环境\(获取源码及编译,安装包方式\)<a name="ZH-CN_TOPIC_0000001119804790"></a>
2
3-   [安装依赖工具](#section18431165519244)
4-   [获取标准系统源码](#section113751052102517)
5    -   [前提条件](#section102871547153314)
6    -   [操作步骤](#section429012478331)
7
8-   [执行prebuilts](#section0495320152619)
9-   [编译](#section1664835963517)
10
11## 安装依赖工具<a name="section18431165519244"></a>
12
13安装命令如下:
14
15```
16sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby
17```
18
19>![](../public_sys-resources/icon-note.gif) **说明:**
20>以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中Python要求安装Python 3.7及以上版本,此处以Python 3.8为例。
21
22## 获取标准系统源码<a name="section113751052102517"></a>
23
24### 前提条件<a name="section102871547153314"></a>
25
261.  注册码云gitee账号。
272.  注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)283.  安装[git客户端](http://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)和[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。
29
30    ```
31    git config --global user.name "yourname"
32    git config --global user.email "your-email-address"
33    git config --global credential.helper store
34    ```
35
364.  安装码云repo工具,可以执行如下命令。
37
38    ```
39    curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo  #如果没有权限,可下载至其他目录,并将其配置到环境变量中
40    chmod a+x /usr/local/bin/repo
41    pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
42    ```
43
44
45### 操作步骤<a name="section429012478331"></a>
46
47方式一(推荐):通过repo + ssh 下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。
48
49```
50repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
51repo sync -c
52repo forall -c 'git lfs pull'
53```
54
55方式二:通过repo + https 下载。
56
57```
58repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
59repo sync -c
60repo forall -c 'git lfs pull'
61```
62
63## 执行prebuilts<a name="section0495320152619"></a>
64
65在源码根目录下执行脚本,安装编译器及二进制工具。
66
67```
68bash build/prebuilts_download.sh
69```
70
71下载的prebuilts二进制默认存放在与OpenHarmony同目录下的OpenHarmony\_2.0\_canary\_prebuilts下。
72
73## 编译<a name="section1664835963517"></a>
74
75在Linux环境进行如下操作:
76
771.  进入源码根目录,执行如下命令进行版本编译。
78
79    ```
80    ./build.sh --product-name {product_name}
81    ```
82
83    \{product\_name\}为当前版本支持的平台,比如:Hi3516DV300
84
852.  检查编译结果。编译完成后,log中显示如下:
86
87    ```
88     build system image successful.
89    =====build Hi3516DV300 successful.
90    ```
91
92    编译所生成的文件都归档在out/ohos-arm-release/目录下,结果镜像输出在 out/ohos-arm-release/packages/phone/images/ 目录下。
93
94    >![](../public_sys-resources/icon-note.gif) **说明:**
95    >其他模块化编译操作,可参见[编译构建指导](../subsystems/subsys-build-standard-large.md)。
96
973.  编译源码完成,请进行镜像烧录,具体请参见[镜像烧录](quickstart-standard-burn.md)。
98
99