1e41f4b71Sopenharmony_ci# Obtaining Source Code
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ciIn the Ubuntu environment, perform the following steps to obtain the OpenHarmony source code:
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci## Preparations
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci1. Register your account with Gitee.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci2. Register an SSH public key for access to Gitee.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci3. (Skip this step if the tools have been installed.) Install the git client and git-lfs.
14e41f4b71Sopenharmony_ci   
15e41f4b71Sopenharmony_ci   Update the software source:
16e41f4b71Sopenharmony_ci   
17e41f4b71Sopenharmony_ci   ```
18e41f4b71Sopenharmony_ci   sudo apt-get update
19e41f4b71Sopenharmony_ci   ```
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci   Run the following command to install the tools:
22e41f4b71Sopenharmony_ci   
23e41f4b71Sopenharmony_ci   ```
24e41f4b71Sopenharmony_ci   sudo apt-get install git git-lfs
25e41f4b71Sopenharmony_ci   ```
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci4. Configure user information.
28e41f4b71Sopenharmony_ci   
29e41f4b71Sopenharmony_ci   ```
30e41f4b71Sopenharmony_ci   git config --global user.name "yourname"
31e41f4b71Sopenharmony_ci   git config --global user.email "your-email-address"
32e41f4b71Sopenharmony_ci   git config --global credential.helper store
33e41f4b71Sopenharmony_ci   ```
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci5. Run the following commands to install the **repo** tool:
36e41f4b71Sopenharmony_ci   
37e41f4b71Sopenharmony_ci   In this example, **~/bin** is used as an example installation directory. You can change the directory as needed.
38e41f4b71Sopenharmony_ci   
39e41f4b71Sopenharmony_ci   ```
40e41f4b71Sopenharmony_ci   mkdir ~/bin
41e41f4b71Sopenharmony_ci   curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo 
42e41f4b71Sopenharmony_ci   chmod a+x ~/bin/repo
43e41f4b71Sopenharmony_ci   pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
44e41f4b71Sopenharmony_ci   ```
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci6. Add the path of the **repo** tool to environment variables.
47e41f4b71Sopenharmony_ci   
48e41f4b71Sopenharmony_ci   ```
49e41f4b71Sopenharmony_ci   vim ~/.bashrc               # Edit environment variables.
50e41f4b71Sopenharmony_ci   export PATH=~/bin:$PATH     # Add the path of the **repo** tool to the end of environment variables.
51e41f4b71Sopenharmony_ci   source ~/.bashrc            # Apply environment variables.
52e41f4b71Sopenharmony_ci   ```
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci## How to Obtain
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
58e41f4b71Sopenharmony_ci>
59e41f4b71Sopenharmony_ci> Download the release code, which is more stable, if you want to develop commercial functionalities. Download the master code if you want to get quick access to the latest features for your development.
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci- **Obtaining OpenHarmony release code**
62e41f4b71Sopenharmony_ci  
63e41f4b71Sopenharmony_ci   For details about how to obtain the source code of an OpenHarmony release, see [OpenHarmony Release Notes](../../release-notes/Readme.md).
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci- **Obtaining OpenHarmony master code**
67e41f4b71Sopenharmony_ci  
68e41f4b71Sopenharmony_ci   Method 1 (recommended): Use the **repo** tool to download the source code over SSH. (You must have registered an SSH public key for access to Gitee.)
69e41f4b71Sopenharmony_ci   
70e41f4b71Sopenharmony_ci  ```
71e41f4b71Sopenharmony_ci  repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
72e41f4b71Sopenharmony_ci  repo sync -c
73e41f4b71Sopenharmony_ci  repo forall -c 'git lfs pull'
74e41f4b71Sopenharmony_ci  ```
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci  Method 2: Use the **repo** tool to download the source code over HTTPS.
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci  
79e41f4b71Sopenharmony_ci  ```
80e41f4b71Sopenharmony_ci  repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
81e41f4b71Sopenharmony_ci  repo sync -c
82e41f4b71Sopenharmony_ci  repo forall -c 'git lfs pull'
83e41f4b71Sopenharmony_ci  ```
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci## Running prebuilts
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ciGo to the root directory of the source code and run the following script to install the compiler and binary tool:
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci```
91e41f4b71Sopenharmony_cibash build/prebuilts_download.sh
92e41f4b71Sopenharmony_ci```
93