拉取代码

方式一(推荐)

通过repo + ssh 下载(需注册公钥,请参考码云帮助中心)。

  • 从版本分支获取源码。可获取该版本分支的最新源码,包括版本发布后在该分支的合入。

    repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-6.0-Release --no-repo-verify
    repo sync -c
    repo forall -c 'git lfs pull'

拉取完成后编译打补丁

bash build/prebuilts_download.sh --skip-ssl

./build.sh --product-name mp_ohos --ccache --patch

第一条命令执行成功

第二条命令执行失败

[OHOS INFO] Start building...

arg:--product-name
arg:mp_ohos
arg:--ccache
arg:--patch
prebuilts_sdk_gn_args:
args_list:--product-name mp_ohos --ccache --patch

[OHOS ERROR]  Traceback (most recent call last):
[OHOS ERROR]    File "/home/guo/gjw/oh6.0/build/hb/containers/status.py", line 47, in wrapper
[OHOS ERROR]      return func(*args, **kwargs)
[OHOS ERROR]             ^^^^^^^^^^^^^^^^^^^^^
[OHOS ERROR]    File "/home/guo/gjw/oh6.0/build/hb/util/product_util.py", line 316, in get_product_info
[OHOS ERROR]      raise OHOSException(f'product {product_name}@{company} not found')
[OHOS ERROR]  exceptions.ohos_exception.OHOSException: product mp_ohos@None not found
[OHOS ERROR]  

[OHOS ERROR]  Code:        0
[OHOS ERROR]  
[OHOS ERROR]  Reason:      product mp_ohos@None not found
[OHOS ERROR]  
[OHOS ERROR]  Error Type:  UNKNOWN ERROR TYPE
[OHOS ERROR]  
[OHOS ERROR]  Description: NO DESCRIPTION
[OHOS ERROR]  
[OHOS ERROR]  Solution:    UNKNOWN REASON
[OHOS ERROR]  
=====build  error=====

 根据deepseek解释,找不到文件项目名称;

看起来你在编译鸿蒙OpenHarmony系统时遇到了产品配置找不到的问题。这个错误通常表示编译系统无法识别你指定的产品名称。我来帮你分析和解决这个问题。

🔍 问题原因分析

从错误信息 product mp_ohos@None not found 可以看出:

  • 产品名称问题:编译系统找不到名为 mp_ohos 的产品配置

  • 公司字段缺失@None 表示没有指定vendor(供应商)信息

  • 配置路径错误:产品配置文件可能不存在或路径不正确

🛠️ 解决方案

1. 确认产品名称是否正确

首先检查你的产品名称是否拼写正确。可以通过以下命令查看所有可用的产品:

bash

./build.sh --list

或者使用hb工具(如果可用):

bash

hb set -l
2. 检查产品配置文件存在性

产品配置文件通常位于 vendor/ 目录下。检查是否存在对应的配置:

bash

find . -name "*mp_ohos*" -type d

或者检查vendor目录:

bash

ls vendor/
3. 验证产品配置完整性

确保产品配置包含必要的文件:

  • config.json:产品配置文件

  • BUILD.gn:构建脚本

4. 检查依赖环境

确保你的编译环境配置正确:

  • Python环境正常

  • 必要的编译工具已安装

5. 清理和重新配置

如果之前有编译缓存,可以尝试清理后重新开始:

bash

./build.sh --clean
./build.sh --product-name mp_ohos --ccache --patch

编译产品v900

bash build/prebuilts_download.sh --skip-ssl
./build.sh --product-name mp_ohos --ccache --patch

./build.sh --product-name mp_ohos --ccache --patch

[OHOS INFO] Start building...

arg:--product-name
arg:mp_ohos
arg:--ccache
arg:--patch
prebuilts_sdk_gn_args:
args_list:--product-name mp_ohos --ccache --patch

[OHOS ERROR]  Traceback (most recent call last):
[OHOS ERROR]    File "/home/guo/gjw/oh6.0/build/hb/containers/status.py", line 47, in wrapper
[OHOS ERROR]      return func(*args, **kwargs)
[OHOS ERROR]             ^^^^^^^^^^^^^^^^^^^^^
[OHOS ERROR]    File "/home/guo/gjw/oh6.0/build/hb/util/product_util.py", line 316, in get_product_info
[OHOS ERROR]      raise OHOSException(f'product {product_name}@{company} not found')
[OHOS ERROR]  exceptions.ohos_exception.OHOSException: product mp_ohos@None not found
[OHOS ERROR]  

[OHOS ERROR]  Code:        0
[OHOS ERROR]  
[OHOS ERROR]  Reason:      product mp_ohos@None not found
[OHOS ERROR]  
[OHOS ERROR]  Error Type:  UNKNOWN ERROR TYPE
[OHOS ERROR]  
[OHOS ERROR]  Description: NO DESCRIPTION
[OHOS ERROR]  
[OHOS ERROR]  Solution:    UNKNOWN REASON
[OHOS ERROR]  
=====build  error=====

什么情况,怎么解决

嗯,用户在使用鸿蒙系统的编译命令时遇到了错误,具体是在执行./build.sh --product-name mp_ohos --ccache --patch后,系统提示找不到名为"mp_ohos"的产品配置。从错误信息来看,这是一个典型的鸿蒙OpenHarmony编译环境配置问题。

我考虑从几个方面来帮助用户解决这个问题。首先需要分析错误原因,然后提供具体的排查步骤和解决方案。根据搜索结果,提供了鸿蒙OpenHarmony编译异常处理的详细指导,虽然主要针对Python环境问题,但其排查思路很有参考价值。虽然主要讨论第三方库编译,但也涉及到鸿蒙编译框架的一些基础知识。

从错误信息"product mp_ohos@None not found"可以判断,编译系统在指定路径下找不到对应的产品配置文件。这可能有几个原因:产品名称拼写错误、产品配置确实不存在、或者是vendor公司字段缺失导致系统使用默认的"None"值。

我打算先让用户确认产品名称的正确性,建议检查build/build_scripts/build_common.json文件中的产品列表。如果确认名称正确,就需要检查产品配置文件是否存在,通常位于vendor目录下。如果配置文件存在但编译仍失败,可能需要检查依赖环境,比如Python版本和必要模块,这点可以参考中的相关建议。

另外,提到的官方编译构建文档也值得参考,建议用户查阅以获取更详细的指导。通过这些步骤,应该能帮助用户系统地排查和解决问题。

看起来你在编译鸿蒙OpenHarmony系统时遇到了产品配置找不到的问题。这个错误通常表示编译系统无法识别你指定的产品名称。我来帮你分析和解决这个问题。

编译产品3568

./build.sh --product-name rk3568 --ccache
 

编译失败

guo@gjw-master:~/gjw/oh6.0$ ./build.sh --clean

        *********Welcome to OpenHarmony!*********

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Your system shell isn't bash, we recommend you to use bash, because some commands may not be supported in other shells, such as pushd and shopt are not supported in dash. 
 You can follow these tips to modify the system shell to bash on Ubuntu: 
 [1]:Open the Terminal tool and execute the following command: sudo dpkg-reconfigure dash 
 [2]:Enter the password and select <no>  
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Current time: 2025-10-13 13:46:22
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Build args: --clean
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[OHOS INFO] Current Node.js version is v14.21.1
[OHOS INFO] Node.js version check passed!
[OHOS INFO] Ohpm initialization started...
[OHOS INFO] Current ohpm version is 5.0.8
ohpm WARN: Your "NodeJs" version is less than the recommended version "18.x.x", please upgrade it as soon as possible.
ohpm DEBUG: config set registry https://repo.harmonyos.com/ohpm/
ohpm DEBUG: start to write trace data
ohpm DEBUG: start to get key
ohpm DEBUG: start to get root key
ohpm DEBUG: start to get trace log dir
ohpm DEBUG: Audit failed, detail: the trace log file path is not exist! trace path: /home/guo/Library/Caches/Huawei/DevEcoStudio5.0/TraceLogData
ohpm WARN: Your "NodeJs" version is less than the recommended version "18.x.x", please upgrade it as soon as possible.
ohpm DEBUG: config set strict_ssl false
ohpm DEBUG: start to write trace data
ohpm DEBUG: start to get key
ohpm DEBUG: start to get root key
ohpm DEBUG: start to get trace log dir
ohpm DEBUG: Audit failed, detail: the trace log file path is not exist! trace path: /home/guo/Library/Caches/Huawei/DevEcoStudio5.0/TraceLogData
ohpm WARN: Your "NodeJs" version is less than the recommended version "18.x.x", please upgrade it as soon as possible.
ohpm DEBUG: config set log_level debug
ohpm DEBUG: start to write trace data
ohpm DEBUG: start to get key
ohpm DEBUG: start to get root key
ohpm DEBUG: start to get trace log dir
ohpm DEBUG: Audit failed, detail: the trace log file path is not exist! trace path: /home/guo/Library/Caches/Huawei/DevEcoStudio5.0/TraceLogData
[OHOS INFO] installing pnpm...
[OHOS INFO] installing hypium...
[OHOS INFO] ohpm initialization successful!
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[OHOS INFO] Start building...

arg:--clean
prebuilts_sdk_gn_args:
args_list:--clean

[OHOS ERROR]  Traceback (most recent call last):
[OHOS ERROR]    File "/home/guo/gjw/oh6.0/build/hb/containers/status.py", line 47, in wrapper
[OHOS ERROR]      return func(*args, **kwargs)
[OHOS ERROR]             ^^^^^^^^^^^^^^^^^^^^^
[OHOS ERROR]    File "/home/guo/gjw/oh6.0/build/hb/resolver/interface/args_resolver_interface.py", line 40, in resolve_arg
[OHOS ERROR]      return resolve_function(target_arg, module)
[OHOS ERROR]             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[OHOS ERROR]    File "/home/guo/gjw/oh6.0/build/hb/resolver/build_args_resolver.py", line 68, in resolve_product
[OHOS ERROR]      target_generator.regist_arg('product_name', config.product)
[OHOS ERROR]                                                  ^^^^^^^^^^^^^^
[OHOS ERROR]    File "/home/guo/gjw/oh6.0/build/hb/resources/config.py", line 178, in product
[OHOS ERROR]      raise OHOSException('Failed to init compile config', '0019')
[OHOS ERROR]  exceptions.ohos_exception.OHOSException: Failed to init compile config
[OHOS ERROR]  

[OHOS ERROR]  Code:        0019
[OHOS ERROR]  
[OHOS ERROR]  Reason:      Failed to init compile config
[OHOS ERROR]  
[OHOS ERROR]  Error Type:  UNKNOWN ERROR TYPE
[OHOS ERROR]  
[OHOS ERROR]  Description: NO DESCRIPTION
[OHOS ERROR]  
[OHOS ERROR]  Solution:    Please run command 'hb set' to init OHOS development environment
[OHOS ERROR]  
=====build  error=====

什么原因?怎么解决

  1. 查看详细错误日志
    错误信息提示你查看 /home/guo/gjw/oh6.0/out/rk3568/error.log 和 build.log这里很可能记录了脚本失败的具体原因,请优先检查这两个文件。你可以使用 cat 或 less 命令查看:

    bash

    cat /home/guo/gjw/oh6.0/out/rk3568/error.log

检查的错误日志如下

guo@gjw-master:~/gjw/oh6.0$ cat /home/guo/gjw/oh6.0/out/rk3568/error.log
ERROR at //third_party/libnl/BUILD.gn:13:1: Script returned non-zero exit code.

exec_script("install.sh", [ "$libnl_path" ])

^----------

Current dir: /home/guo/gjw/oh6.0/out/rk3568/

Command: /usr/bin/env /home/guo/gjw/oh6.0/third_party/libnl/install.sh /home/guo/gjw/oh6.0/third_party/libnl

Returned 100 and printed out:

libnl-libnl3_11_0/

libnl-libnl3_11_0/.clang-format

libnl-libnl3_11_0/.flake8

libnl-libnl3_11_0/.git-blame-ignore-revs

libnl-libnl3_11_0/.github/

libnl-libnl3_11_0/.github/workflows/

libnl-libnl3_11_0/.github/workflows/ci.yml

libnl-libnl3_11_0/.gitignore

libnl-libnl3_11_0/.indent.pro

libnl-libnl3_11_0/COPYING

libnl-libnl3_11_0/ChangeLog

libnl-libnl3_11_0/Makefile.am

libnl-libnl3_11_0/autogen.sh

libnl-libnl3_11_0/configure.ac

libnl-libnl3_11_0/doc/

libnl-libnl3_11_0/doc/AUTHORS

libnl-libnl3_11_0/doc/COPYING

libnl-libnl3_11_0/doc/Doxyfile.in

libnl-libnl3_11_0/doc/DoxygenLayout.xml

libnl-libnl3_11_0/doc/Makefile.am

libnl-libnl3_11_0/doc/README

libnl-libnl3_11_0/doc/api/

libnl-libnl3_11_0/doc/api/.gitignore

libnl-libnl3_11_0/doc/autogen.sh

libnl-libnl3_11_0/doc/configure.ac

libnl-libnl3_11_0/doc/core.txt

libnl-libnl3_11_0/doc/doxygen-link.py

libnl-libnl3_11_0/doc/gen-tags.sh

libnl-libnl3_11_0/doc/images/

libnl-libnl3_11_0/doc/images/addressing.png

libnl-libnl3_11_0/doc/images/attribute_hdr.png

libnl-libnl3_11_0/doc/images/classful_qdisc.png

libnl-libnl3_11_0/doc/images/classless_qdisc.png

libnl-libnl3_11_0/doc/images/classless_qdisc_nbands.png

libnl-libnl3_11_0/doc/images/icons/

libnl-libnl3_11_0/doc/images/icons/README

libnl-libnl3_11_0/doc/images/icons/callouts/

libnl-libnl3_11_0/doc/images/icons/callouts/1.png

libnl-libnl3_11_0/doc/images/icons/callouts/10.png

libnl-libnl3_11_0/doc/images/icons/callouts/11.png

libnl-libnl3_11_0/doc/images/icons/callouts/12.png

libnl-libnl3_11_0/doc/images/icons/callouts/13.png

libnl-libnl3_11_0/doc/images/icons/callouts/14.png
检查结果如上

从 error.log 可以看到,install.sh 脚本执行时打印了 libnl-libnl3_11_0 目录下的文件列表,但返回了错误码 100。这说明脚本可能在 **“遍历文件后执行后续步骤(如解压、配置、移动文件)时失败”**,核心原因大概率是脚本逻辑依赖某个操作未完成(如未找到指定子目录、权限不足或缺少解压工具)。

关键解决步骤:分析 install.sh 脚本逻辑并修复

首先需要查看 third_party/libnl/install.sh 的内容,明确它要执行的操作(比如解压源码、生成配置文件等),再针对性解决。

1. 查看 install.sh 脚本内容

执行以下命令查看脚本逻辑:

bash

# 进入 libnl 目录
cd /home/guo/gjw/oh6.0/third_party/libnl

# 查看 install.sh 前 100 行(核心逻辑通常在开头)
head -n 100 install.sh

# 或查看完整脚本(若脚本较长,用 less 分页查看)
less install.sh

前100行如下

guo@gjw-master:~/gjw/oh6.0/third_party/libnl$ head -n 100 install.sh

#!/bin/bash

# This library is free software; you can redistribute it and/or

# modify it under the terms of the GNU Lesser General Public

# License as published by the Free Software Foundation version 2.1

# of the License.

#

# Copyright(c) 2023 Huawei Device Co., Ltd.

set -e

cd $1

if [ -d "libnl" ];then

    rm -rf libnl

fi

tar xvf libnl-libnl3_11_0.tar.gz

mv libnl-libnl3_11_0 libnl

cd $1/libnl

apt-get update

apt-get install autoconf automake libtool -y

./autogen.sh

./configure

patch -p1 < $1/solve-oh-compile-problem3_11_0.patch --fuzz=0 --no-backup-if-mismatch

exit 0

解决如下

从 install.sh 前 100 行的逻辑来看,脚本的核心操作是解压压缩包、安装依赖、执行配置和打补丁,但存在两个关键问题导致执行失败(返回码 100):

  1. apt-get 命令需要管理员权限(脚本中直接执行 apt-get install,无 sudo 会权限不足);
  2. 可能存在压缩包解压失败补丁文件缺失的情况。

以下是针对性的解决步骤:

第一步:修复 apt-get 权限问题(核心失败原因)

脚本中 apt-get update 和 apt-get install 命令需要 root 权限,直接执行会报错 “Permission denied”,导致脚本中断。需修改脚本,添加 sudo 并处理权限交互:

  1. 编辑 install.sh 脚本:

    bash

    cd /home/guo/gjw/oh6.0/third_party/libnl
    nano install.sh
    
  2. 找到以下两行,在开头添加 sudo

    bash

    # 原内容
    apt-get update
    apt-get install autoconf automake libtool -y
    
    # 修改后
    sudo apt-get update
    sudo apt-get install autoconf automake libtool -y
    
  3. 保存并退出(Ctrl+O → 回车 → Ctrl+X)。

第二步:检查并确保压缩包与补丁文件存在

脚本依赖两个关键文件,缺失会导致解压 / 打补丁失败:

  1. 检查压缩包 libnl-libnl3_11_0.tar.gz

    bash

    # 查看当前目录是否有该压缩包
    ls -l /home/guo/gjw/oh6.0/third_party/libnl/libnl-libnl3_11_0.tar.gz
    
    • 若输出 “No such file or directory”:说明压缩包缺失,需重新同步源码:

      bash

      # 回到项目根目录,强制同步 libnl 子模块
      cd /home/guo/gjw/oh6.0
      git submodule deinit -f third_party/libnl
      git submodule update --init --force third_party/libnl
      
  2. 检查补丁文件 solve-oh-compile-problem3_11_0.patch

    bash

    # 查看补丁文件是否存在
    ls -l /home/guo/gjw/oh6.0/third_party/libnl/solve-oh-compile-problem3_11_0.patch
    
    • 若缺失:需从 OpenHarmony 源码仓库补全该补丁文件(可参考同版本源码的 third_party/libnl 目录,或联系源码提供方获取)。

第三步:手动测试修改后的脚本

修改后先手动执行脚本,确认无错误后再重新编译:

bash

# 进入 libnl 目录
cd /home/guo/gjw/oh6.0/third_party/libnl

# 赋予脚本执行权限(确保生效)
chmod +x install.sh

# 手动执行脚本(传入正确路径参数)
./install.sh /home/guo/gjw/oh6.0/third_party/libnl
手动执行时的预期输出(无错误):
  • 提示输入 sudo 密码(用于安装依赖);
  • 成功解压 libnl-libnl3_11_0.tar.gz 并生成 libnl 目录;
  • 成功执行 ./autogen.sh 和 ./configure
  • 成功打补丁(无 “patch: ****: No such file or directory” 错误);
  • 脚本正常退出(无报错,返回码为 0,可通过 echo $? 查看,输出 0 即正常)。

第四步:清理构建缓存并重新编译

若手动执行脚本无错误,清理之前的构建缓存,避免旧错误残留:

bash

# 回到项目根目录
cd /home/guo/gjw/oh6.0

# 删除 out 目录下的 rk3568 构建缓存
rm -rf out/rk3568

# 重新执行编译命令
./build.sh --product-name rk3568 --ccache

检查补丁文件存在

guo@gjw-master:~/gjw/oh6.0/third_party/libnl$ ls -l /home/guo/gjw/oh6.0/third_party/libnl/libnl-libnl3_11_0.tar.gz

-rw-rw-r-- 1 guo guo 1182091 10月 13 10:07 /home/guo/gjw/oh6.0/third_party/libnl/libnl-libnl3_11_0.tar.gz

guo@gjw-master:~/gjw/oh6.0/third_party/libnl$

检查结果如上

从检查结果来看,压缩包 libnl-libnl3_11_0.tar.gz 存在且权限正常rw-rw-r-- 表示当前用户 guo 有读写权限),排除了压缩包缺失或权限不足的问题。结合之前修改的 install.sh 脚本(已添加 sudo 处理 apt-get 权限),接下来只需重点确认补丁文件存在性脚本手动执行结果,即可解决编译报错。

第一步:确认补丁文件 solve-oh-compile-problem3_11_0.patch 存在

脚本最后一步会执行 patch -p1 < $1/solve-oh-compile-problem3_11_0.patch,若该补丁文件缺失,会直接导致脚本执行失败(返回非零码)。执行以下命令检查:

bash

# 检查补丁文件是否存在
ls -l /home/guo/gjw/oh6.0/third_party/libnl/solve-oh-compile-problem3_11_0.patch
情况 1:补丁文件存在(输出类似如下)

若显示类似以下内容,说明补丁文件正常,可跳过此步直接执行脚本:

plaintext

-rw-rw-r-- 1 guo guo 1234 10月 13 10:07 /home/guo/gjw/oh6.0/third_party/libnl/solve-oh-compile-problem3_11_0.patch
情况 2:补丁文件缺失(输出 “No such file or directory”)

若缺失,需按以下方式补全:

  1. 从 OpenHarmony 源码仓库获取:访问 OpenHarmony 官方源码仓库的 third_party/libnl 目录(如 OpenHarmony 6.0 分支),下载对应版本的 solve-oh-compile-problem3_11_0.patch 文件,放入 /home/guo/gjw/oh6.0/third_party/libnl 目录。
  2. 临时注释补丁步骤(仅测试用):若暂时无法获取补丁,可先注释脚本中的补丁命令,测试是否是补丁导致的失败(注:后续编译可能因缺少补丁出现其他错误,仅用于定位问题):

    bash

    # 编辑 install.sh
    nano /home/guo/gjw/oh6.0/third_party/libnl/install.sh
    # 找到补丁行,在开头加 # 注释
    # patch -p1 < $1/solve-oh-compile-problem3_11_0.patch --fuzz=0 --no-backup-if-mismatch
    

第二步:手动执行修改后的 install.sh 脚本

补丁文件确认正常后,手动执行脚本,验证是否能完整运行(这是关键步骤,避免编译时再次失败):

bash

# 进入 libnl 目录
cd /home/guo/gjw/oh6.0/third_party/libnl

# 确保脚本有执行权限
chmod +x install.sh

# 手动执行脚本(传入正确路径参数)
./install.sh /home/guo/gjw/oh6.0/third_party/libnl
执行过程中需注意的关键点:
  1. 输入 sudo 密码:脚本执行到 sudo apt-get update 时,会提示输入当前用户(guo)的密码,输入后按回车继续(密码输入时不显示,正常输入即可)。

  2. 观察是否有报错

    • 若出现 tar: Error opening archive: Failed to open 'libnl-libnl3_11_0.tar.gz':检查压缩包是否损坏,可重新下载压缩包替换。
    • 若出现 autogen.sh: error: no autoconf found:说明 apt-get install 未成功安装依赖,可手动重新安装:sudo apt install autoconf automake libtool -y
    • 若出现 patch: ****: patch does not apply:补丁与源码不匹配,需确认补丁版本与 libnl 版本一致(如 libnl3_11_0 对应补丁是否正确)。
  3. 确认脚本正常退出:脚本执行完成后,输入 echo $? 查看返回码,若输出 0,说明脚本执行成功;若输出非 0(如 1、100),则需根据当前报错信息进一步处理。

第三步:清理构建缓存并重新编译

若手动执行脚本无错误(返回码 0),清理之前的构建缓存,避免旧的错误状态影响编译:

bash

# 回到项目根目录
cd /home/guo/gjw/oh6.0

# 删除 rk3568 的构建输出目录(彻底清理缓存)
rm -rf out/rk3568

# 重新执行编译命令
./build.sh --product-name rk3568 --ccache

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐