[{"data":1,"prerenderedAt":441},["ShallowReactive",2],{"post-2021-06-06-download-openharmony-source-code-zh":3,"surround-2021-06-06-download-openharmony-source-code-zh":429,"randomIndex/2021/06/06/download-openharmony-source-code/":148,"language-switch-/2021/06/06/download-openharmony-source-code/-en":7},{"title":4,"date":5,"path":6,"tags":7,"body":8,"description":60},"下载一份openharmony的源码","2021-06-06 16:47:34","/2021/06/06/download-openharmony-source-code",null,{"type":9,"value":10,"toc":426},"minimark",[11,18,21,34,50,61,70,211,218,230,237,249,256,278,288,295,307,317,320,326,330,333,339,346,369,375,382,385,391,398,404,410,416,422],[12,13,14],"blockquote",{},[15,16,17],"p",{},"不知道为什么，总是有人告诉我鸿蒙已经开源了，不信可以自己去看源码balabala，其实鸿蒙的手机端目前为止依然没有开源，或者说没有完整完整开源。本文我将介绍如何拉取一份openharmony开源的源码。",[15,19,20],{},"首先需要准备以下东西",[22,23,24,28,31],"ul",{},[25,26,27],"li",{},"一台装有类unix环境的电脑（wsl大概也行）",[25,29,30],{},"6G磁盘剩余空间",[25,32,33],{},"互联网（如果使用手机流量的话大概是1.5G）",[35,36,38,45],"ol",{"start":37},0,[25,39,40,44],{},[41,42,43],"h4",{"id":43},"安装git","没什么好说的，不再赘述。",[25,46,47],{},[41,48,49],{"id":49},"设置git用户名和邮箱",[51,52,57],"pre",{"className":53,"code":55,"language":56},[54],"language-text","git config --global user.email \"you@example.com\"\ngit config --global user.name \"Your Name\"\n","text",[58,59,55],"code",{"__ignoreMap":60},"",[35,62,64],{"start":63},2,[25,65,66],{},[41,67,69],{"id":68},"下载repo这个大多数发行版自己都有打包但是都比较滞后不如直接下载最新版的二进制文件设置好path变量直接用","下载repo（这个大多数发行版自己都有打包，但是都比较滞后，不如直接下载最新版的二进制文件设置好path变量直接用）",[51,71,75],{"className":72,"code":73,"language":74,"meta":60,"style":60},"language-bash shiki shiki-themes one-light one-dark-pro","mkdir -p ~/bin\ncurl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo\nchmod a+x ~/bin/repo\n\ncat >> ~/.bashrc \u003C\u003CEOF\n\n# set PATH so it includes user's private bin if it exists\nif [ -d \"\\$HOME/bin\" ] ; then\n    PATH=\"\\$HOME/bin:\\$PATH\"\nfi\nEOF\n\nsource ~/.bashrc\n","bash",[58,76,77,94,109,121,128,146,151,157,170,186,192,197,202],{"__ignoreMap":60},[78,79,82,86,90],"span",{"class":80,"line":81},"line",1,[78,83,85],{"class":84},"sAdtL","mkdir",[78,87,89],{"class":88},"sAGMh"," -p",[78,91,93],{"class":92},"sDhpE"," ~/bin\n",[78,95,96,99,102,106],{"class":80,"line":63},[78,97,98],{"class":84},"curl",[78,100,101],{"class":92}," https://storage.googleapis.com/git-repo-downloads/repo",[78,103,105],{"class":104},"s5ixo"," > ",[78,107,108],{"class":92},"~/bin/repo\n",[78,110,112,115,118],{"class":80,"line":111},3,[78,113,114],{"class":84},"chmod",[78,116,117],{"class":92}," a+x",[78,119,120],{"class":92}," ~/bin/repo\n",[78,122,124],{"class":80,"line":123},4,[78,125,127],{"emptyLinePlaceholder":126},true,"\n",[78,129,131,134,137,140,143],{"class":80,"line":130},5,[78,132,133],{"class":84},"cat",[78,135,136],{"class":104}," >> ",[78,138,139],{"class":92},"~/.bashrc",[78,141,142],{"class":104}," \u003C\u003C",[78,144,145],{"class":104},"EOF\n",[78,147,149],{"class":80,"line":148},6,[78,150,127],{"emptyLinePlaceholder":126},[78,152,154],{"class":80,"line":153},7,[78,155,156],{"class":92},"# set PATH so it includes user's private bin if it exists\n",[78,158,160,163,167],{"class":80,"line":159},8,[78,161,162],{"class":92},"if [ -d \"",[78,164,166],{"class":165},"s_Sar","\\$",[78,168,169],{"class":92},"HOME/bin\" ] ; then\n",[78,171,173,176,178,181,183],{"class":80,"line":172},9,[78,174,175],{"class":92},"    PATH=\"",[78,177,166],{"class":165},[78,179,180],{"class":92},"HOME/bin:",[78,182,166],{"class":165},[78,184,185],{"class":92},"PATH\"\n",[78,187,189],{"class":80,"line":188},10,[78,190,191],{"class":92},"fi\n",[78,193,195],{"class":80,"line":194},11,[78,196,145],{"class":104},[78,198,200],{"class":80,"line":199},12,[78,201,127],{"emptyLinePlaceholder":126},[78,203,205,208],{"class":80,"line":204},13,[78,206,207],{"class":165},"source",[78,209,210],{"class":92}," ~/.bashrc\n",[35,212,213],{"start":111},[25,214,215],{},[41,216,217],{"id":217},"新建一个文件夹以同步源码",[51,219,221],{"className":72,"code":220,"language":74,"meta":60,"style":60},"mkdir openharmony\n",[58,222,223],{"__ignoreMap":60},[78,224,225,227],{"class":80,"line":81},[78,226,85],{"class":84},[78,228,229],{"class":92}," openharmony\n",[35,231,232],{"start":123},[25,233,234],{},[41,235,236],{"id":236},"进入这个文件夹",[51,238,240],{"className":72,"code":239,"language":74,"meta":60,"style":60},"cd openharmony\n",[58,241,242],{"__ignoreMap":60},[78,243,244,247],{"class":80,"line":81},[78,245,246],{"class":165},"cd",[78,248,229],{"class":92},[35,250,251],{"start":130},[25,252,253],{},[41,254,255],{"id":255},"初始化repo",[51,257,259],{"className":72,"code":258,"language":74,"meta":60,"style":60},"repo init -u https://gitee.com/openharmony/manifest.git --depth=1\n",[58,260,261],{"__ignoreMap":60},[78,262,263,266,269,272,275],{"class":80,"line":81},[78,264,265],{"class":84},"repo",[78,267,268],{"class":92}," init",[78,270,271],{"class":88}," -u",[78,273,274],{"class":92}," https://gitee.com/openharmony/manifest.git",[78,276,277],{"class":88}," --depth=1\n",[15,279,280,281,284,285,287],{},"​\t注:  ",[58,282,283],{},"--depth=1","是为了仅保留一层commit记录，防止过多的历史commit占用空间，如果你想保留历\t史commit，那可以把这里的",[58,286,283],{},"去掉。",[35,289,290],{"start":148},[25,291,292],{},[41,293,294],{"id":294},"使用repo正式开始同步源码",[51,296,298],{"className":72,"code":297,"language":74,"meta":60,"style":60},"repo sync\n",[58,299,300],{"__ignoreMap":60},[78,301,302,304],{"class":80,"line":81},[78,303,265],{"class":84},[78,305,306],{"class":92}," sync\n",[15,308,309,310,313,314],{},"repo在sync的时候其实可以加很多选项，可以通过",[58,311,312],{},"repo help","自行研究，我自己常用的是",[58,315,316],{},"repo sync  --force-sync --current-branch --no-tags --no-clone-bundle --optimized-fetch --prune -j$(nproc --all) -f1",[15,318,319],{},"看到以下提示代表同步成功",[51,321,324],{"className":322,"code":323,"language":56},[54],"repo sync has finished successfully.\n",[58,325,323],{"__ignoreMap":60},[327,328,329],"h3",{"id":329},"后话",[15,331,332],{},"结果就当源码下载好并开始checkout后，出现了以下错误",[51,334,337],{"className":335,"code":336,"language":56},[54],"Garbage collecting: 100% (220/220), done in 1.204s\nUpdating files: 100% (35/35), done.\nUpdating files: 100% (27/27), done.\ngit-lfs filter-process --skip: line 1: git-lfs: command not found\nfatal: the remote end hung up unexpectedly\nerror.GitError: Cannot checkout device_hisilicon_modules: Cannot initialize work tree for device_hisilicon_modules\nerror: Cannot checkout device_hisilicon_modules\n",[58,338,336],{"__ignoreMap":60},[15,340,341,342,345],{},"看着error很容易可以发现是我的系统没有",[58,343,344],{},"git-lfs","的原因，看样子openharmony使用了git-lfs来储存了某个大文件。",[51,347,349],{"className":72,"code":348,"language":74,"meta":60,"style":60},"sudo pacman -S git-lfs  #别的发行版请自行查找相关安装方法\n",[58,350,351],{"__ignoreMap":60},[78,352,353,356,359,362,365],{"class":80,"line":81},[78,354,355],{"class":84},"sudo",[78,357,358],{"class":92}," pacman",[78,360,361],{"class":88}," -S",[78,363,364],{"class":92}," git-lfs",[78,366,368],{"class":367},"sW2Sy","  #别的发行版请自行查找相关安装方法\n",[15,370,371,372,374],{},"于是乎，安装好",[58,373,344],{},"重新sync源码",[15,376,377,378,381],{},"oepnharmony目录下，",[58,379,380],{},".repo","文件夹内是你从git服务器上下载下来的原始数据，repo将在所有数据下载完成以后将他们自动checkout成代码。",[15,383,384],{},"源码结构是下面这个样子",[51,386,389],{"className":387,"code":388,"language":56},[54],".\n├── applications\n├── base\n├── build\n├── build.py -> build/lite/build.py\n├── build.sh -> build/build_scripts/build.sh\n├── developtools\n├── device\n├── docs\n├── domains\n├── drivers\n├── foundation\n├── .gn -> build/core/gn/dotfile.gn\n├── interface\n├── kernel\n├── prebuilts\n├── productdefine\n├── .repo\n├── test\n├── third_party\n├── utils\n└── vendor\n\n18 directories, 3 files\n",[58,390,388],{"__ignoreMap":60},[15,392,393],{},[394,395],"img",{"alt":396,"src":397},"这里是OpenHarmony包含.repo原始数据的全部大小","https://static.031130.xyz/uploads/2024/08/12/62f3cb1057a22.webp",[15,399,400],{},[394,401],{"alt":402,"src":403},"这里是OpenHarmony的.repo原始数据的大小","https://static.031130.xyz/uploads/2024/08/12/62f3cb13027fb.webp",[15,405,406],{},[407,408,409],"strong",{},"我提供个参考数据，AOSP源码不含.repo原始数据的大小是40G，就openharmony这个代码量，恐怕很难让我相信这是一个兼容安卓应用的系统的完整代码。",[15,411,412],{},[394,413],{"alt":414,"src":415},"这里是AOSP的.repo原始数据大小","https://static.031130.xyz/uploads/2024/08/12/62f3cb15ccbf1.webp",[15,417,418],{},[394,419],{"alt":420,"src":421},"这里是AOSP包含.repo原始数据的大小","https://static.031130.xyz/uploads/2024/08/12/62f3cb182333b.webp",[423,424,425],"style",{},"html pre.shiki code .sAdtL, html code.shiki .sAdtL{--shiki-default:#4078F2;--shiki-dark:#61AFEF}html pre.shiki code .sAGMh, html code.shiki .sAGMh{--shiki-default:#986801;--shiki-dark:#D19A66}html pre.shiki code .sDhpE, html code.shiki .sDhpE{--shiki-default:#50A14F;--shiki-dark:#98C379}html pre.shiki code .s5ixo, html code.shiki .s5ixo{--shiki-default:#383A42;--shiki-dark:#ABB2BF}html pre.shiki code .s_Sar, html code.shiki .s_Sar{--shiki-default:#0184BC;--shiki-dark:#56B6C2}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sW2Sy, html code.shiki .sW2Sy{--shiki-default:#A0A1A7;--shiki-default-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic}",{"title":60,"searchDepth":63,"depth":63,"links":427},[428],{"id":329,"depth":111,"text":329},[430,436],{"title":431,"path":432,"stem":433,"date":434,"lang":435,"children":-1},"来，从AUR给Fedora偷个包","/2021/07/23/build-a-rpm-package-from-aur-with-archlinux","posts/zh/build-a-rpm-package-from-aur-with-archlinux","2021-07-23 01:50:09","zh-CN",{"title":437,"path":438,"stem":439,"date":440,"lang":435,"children":-1},"在Windows与Linux双系统下共享蓝牙鼠标","/2021/05/30/share-xiaomi-bluetooth-mouse-on-both-windows-and-linux","posts/zh/share-xiaomi-bluetooth-mouse-on-both-windows-and-linux","2021-05-30",1777565052699]