本文介紹了如何下載開源鴻蒙(OpenHarmony)操作系統(tǒng)源碼,該方法可以用于下載OpenHarmony最新開發(fā)版本(master分支)或者4.0 Release、3.2 Release等發(fā)布版本。
本文基于Ubuntu 22.04進(jìn)行操作,Ubuntu其他版本也同樣可行,包括 20.04, 18.04。
OpenHarmony架構(gòu)圖:
一、準(zhǔn)備命令工具
本節(jié)介紹如何準(zhǔn)備命令行工具,具體包括git/repo/python。
OpenHarmony代碼托管在碼云服務(wù)器上,下載單個(gè)代碼倉通常使用git命令行工具,下載所有代碼倉需要使用repo命令行工具。repo命令行工具是由Python開發(fā)的,因此開始之前,需要線安裝git/git-lfs/python等命令行工具。
安裝git/git-lfs/python/curl,執(zhí)行如下命令:
sudo apt install git git-lfs python3-pip curl
安裝repo命令,執(zhí)行如下命令:
mkdir ~/bin
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > ~/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
二、配置git和SSH公鑰
本節(jié)介紹如何配置本地git用戶名和郵箱,以及碼云SSH公鑰(使用ssh協(xié)議下載必須配置):
-
注冊(cè)碼云gitee帳號(hào)。
-
注冊(cè)碼云SSH公鑰,請(qǐng)參考碼云幫助中心。
-
配置git用戶信息,執(zhí)行如下命令:
git config --global user.name "yourname" git config --global user.email "your-email-address" git config --global credential.helper store
-
創(chuàng)建目錄,用于存放OpenHarmony源碼,執(zhí)行如下命令:
mkdir -p ~/ohos/openharmony cd ~/ohos/openharmony
三、下載OpenHarmony源碼
3.1 使用ssh協(xié)議下載(推薦)
通過repo + ssh 下載(需注冊(cè)公鑰,請(qǐng)參考碼云幫助中心)。
-
從版本分支獲取源碼??色@取該版本分支的最新源碼,包括版本發(fā)布后在該分支的合入。
repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-4.0-Release --no-repo-verify repo sync -c repo forall -c 'git lfs pull'
-
從版本發(fā)布Tag節(jié)點(diǎn)獲取源碼??色@取與版本發(fā)布時(shí)完全一致的源碼。
repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v4.0-Release --no-repo-verify repo sync -c repo forall -c 'git lfs pull'
3.2 使用https協(xié)議下載
通過repo + https 下載。
-
從版本分支獲取源碼。可獲取該版本分支的最新源碼,包括版本發(fā)布后在該分支的合入。
repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-4.0-Release --no-repo-verify repo sync -c repo forall -c 'git lfs pull'
-
從版本發(fā)布Tag節(jié)點(diǎn)獲取源碼??色@取與版本發(fā)布時(shí)完全一致的源碼。
repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v4.0-Release --no-repo-verify repo sync -c repo forall -c 'git lfs pull'
四、下載編譯工具鏈
代碼下載完成后,還需要執(zhí)行prebuilts_download.sh腳本,下載編譯工具鏈,執(zhí)行如下命令:
bash build/prebuilts_download.sh
這個(gè)腳本會(huì)創(chuàng)建prebuilts目錄,并將邊回憶工具鏈下載、解壓到這個(gè)目錄下。
以上全部完成后,磁盤空間占用50G:
文章來源:http://www.zghlxwxcb.cn/news/detail-849368.html
五、參考鏈接
本文主要參考了OpenHarmony文檔倉,里面由其他版本的發(fā)布說明(Release Note),根據(jù)其他版本的發(fā)布說明,也可以下載其他版本的源代碼。文章來源地址http://www.zghlxwxcb.cn/news/detail-849368.html
- zh-cn/release-notes · OpenHarmony/docs - 碼云 - 開源中國(guó) (gitee.com)
- zh-cn/release-notes/OpenHarmony-v4.0-release.md · OpenHarmony/docs - Gitee.com
到了這里,關(guān)于【開源鴻蒙】下載 OpenHarmony 4.0 源代碼和工具鏈的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!