TA的每日心情 | 开心 2024-1-19 14:48 |
---|
签到天数: 17 天 [LV.4]偶尔看看III
管理员
- 积分
- 1007
|
楼主 |
发表于 2022-6-18 13:26:50
|
显示全部楼层
关键是这句话 [OHOS ERROR] FileNotFoundError: [Errno 2] No such file or directory: 'java' , 从日志看出是在 编译 ../../../build/lite/hap_pack.py 时出了问题, 看下这个文件中到底有啥
- root@turingkuang:/home/openharmony/code-v3.1.1-Release/OpenHarmony/build/lite# cat hap_pack.py
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Copyright (c) 2020 Huawei Device Co., Ltd.
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
- import sys
- import os
- import argparse
- import subprocess
- from utils import makedirs
- import shutil
- import zipfile
- def cmd_popen(cmd):
- proc = subprocess.Popen(cmd)
- proc.wait()
- ret_code = proc.returncode
- if ret_code != 0:
- print("hap warning: {} failed, return code is {}".format(
- cmd, ret_code))
- def parse_args():
- parser = argparse.ArgumentParser()
- parser.add_argument('--packing-tool-path', help='packing tool path ')
- parser.add_argument('--mode', help='package mode')
- parser.add_argument('--json-path', help='profile')
- parser.add_argument('--resources-path', help='resources')
- parser.add_argument('--assets-path', help='assets')
- parser.add_argument('--lib-path', help='lib')
- parser.add_argument('--shared-libs-path', help='shared-libs')
- parser.add_argument('--ability-so-path', help='ability so')
- parser.add_argument('--index-path', help='index')
- parser.add_argument('--unsignhap-path', help='unsignhap path')
- parser.add_argument('--force', help='force')
- parser.add_argument('--signtool-path', help='sign tool path')
- parser.add_argument('--signhap-path', help='sign hap path')
- parser.add_argument('--privatekey', help='privatekey')
- parser.add_argument('--sign-server', help='sign_server')
- parser.add_argument('--sign-algo', help='sign algo')
- parser.add_argument('--cert-profile', help='cert profile')
- parser.add_argument('--jks-path', help='jks path')
- parser.add_argument('--cert-path', help='cert path')
- parser.add_argument('--sign-by-server', help='sign mode')
- args = parser.parse_args()
- return args
- def hap_packing(args):
- if not args.packing_tool_path:
- print('hap warning: packing tool path empty')
- return
- packing_cmd = ['java', '-jar', args.packing_tool_path]
- cmd_dict = {
- '--mode': args.mode,
- '--json-path': args.json_path,
- '--resources-path': args.resources_path,
- '--assets-path': args.assets_path,
- '--lib-path': args.lib_path,
- '--shared-libs-path': args.shared_libs_path,
- '--ability-so-path': args.ability_so_path,
- '--index-path': args.index_path,
- '--out-path': args.unsignhap_path,
- '--force': args.force,
- '--sign-by-server': args.sign_by_server
- }
- for key, value in cmd_dict.items():
- if value:
- packing_cmd.extend([key, value])
- cmd_popen(packing_cmd)
- def hap_signing(args):
- user_name = ''
- password = ''
- if not args.signtool_path:
- print('hap warning: signing tool path empty')
- return
- # sign by server
- if args.sign_by_server == "True":
- if 'ONLINE_USERNAME' in os.environ:
- user_name = os.environ.get('ONLINE_USERNAME')
- else:
- print('hap warning: Environment variable ONLINE_USERNAME and ' +
- 'ONLINE_PASSWD are needed for app signning. ' +
- 'Please export it in bash.')
- return
- if 'ONLINE_PASSWD' in os.environ:
- password = os.environ.get('ONLINE_PASSWD')
- else:
- print('hap warning: Environment variable ONLINE_USERNAME and ' +
- 'ONLINE_PASSWD are needed for app signning. ' +
- 'Please export it in bash.')
- return
- signing_cmd = [
- 'java', '-jar', args.signtool_path, 'sign', '-mode', 'remote',
- '-profileSigned', '1'
- ]
- cmd_dict = {
- '-privatekey': args.privatekey,
- '-server': args.sign_server,
- '-inputFile': args.unsignhap_path,
- '-outputFile': args.signhap_path,
- '-username': user_name,
- '-password': password,
- '-signAlg': args.sign_algo,
- '-profile': args.cert_profile
- }
- # sign by software.
- else:
- signtool_path = args.signtool_path
- #The default password of the key is 123456.
- # You are advised to use a key and certificate management tool (
- # such as keytool) to change the default password.
- # For details, see section "Application Signature Verification
- # Development Guide" in the Security Subsystem Development Guide.
- signing_cmd = [
- 'java', '-jar', signtool_path, 'sign-app', '-mode', 'localsign',
- '-profileSigned', '1', '-keystorePwd', '123456',
- '-keyPwd', '123456','inForm','zip'
- ]
- cmd_dict = {
- '-keyAlias': args.privatekey,
- '-inFile': args.unsignhap_path,
- '-outFile': args.signhap_path,
- '-signAlg': args.sign_algo,
- '-profileFile': args.cert_profile,
- '-keystoreFile': args.jks_path,
- '-appCertFile': args.cert_path
- }
- for key, value in cmd_dict.items():
- if value:
- signing_cmd.extend([key, value])
- cmd_popen(signing_cmd)
- def main():
- args = parse_args()
- # Workaround: hap packing tools multi-thread contention issue.
- makedirs(os.path.dirname(args.unsignhap_path), exist_ok=True)
- hap_packing(args)
- if os.path.exists(args.unsignhap_path):
- hap_signing(args)
- os.remove(args.unsignhap_path)
- if __name__ == '__main__':
- sys.exit(main())
复制代码
发现了这句话,需要java 环境
packing_cmd = ['java', '-jar', args.packing_tool_path]
安装
apt install openjdk-11-jre-headless
再单独编译下这个模块发现可以了 .
- root@turingkuang:/home/openharmony/code-v3.1.1-Release/OpenHarmony/out/hispark_taurus/ipcamera_hispark_taurus# /usr/bin/python3 ../../../build/lite/hap_pack.py --packing-tool-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/developtools/packing_tool/jar/app_packing_tool.jar --mode hap --json-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/applications/sample/camera/cameraApp/cameraApp/src/main/config.json --resources-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/applications/sample/camera/cameraApp/cameraApp/src/main/resources --ability-so-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/out/hispark_taurus/ipcamera_hispark_taurus/libcameraApp.so --force true --signtool-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/developtools/hapsigner/dist/hap-sign-tool.jar --privatekey OpenHarmony\ Application\ Release --sign-algo SHA256withECDSA --unsignhap-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/out/hispark_taurus/ipcamera_hispark_taurus/system/internal/unsigned_cameraApp.hap --signhap-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/out/hispark_taurus/ipcamera_hispark_taurus/system/internal/cameraApp.hap --sign-server rnd-signserver.huawei.com --jks-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/developtools/hapsigner/dist/OpenHarmony.p12 --cert-path /home/openharmony/code-v3.1.1-Release/OpenHarmony/developtools/hapsigner/dist/OpenHarmonyApplication.pem --sign-by-server False --cert-profile /home/openharmony/code-v3.1.1-Release/OpenHarmony/applications/sample/camera/cameraApp/cert/camera_HarmonyAppProvision_Release.p7b
- 06-18 01:05:38 INFO - Start sign-app
- 06-18 01:05:39 INFO - certificate in profile: camera Release
- 06-18 01:05:39 INFO - /home/openharmony/code-v3.1.1-Release/OpenHarmony/developtools/hapsigner/dist/OpenHarmony.p12 is exist. Try to load it with given passwd
- 06-18 01:05:39 INFO - Add sign data in sign info list success.
- 06-18 01:05:39 INFO - Generate signing block success, begin write it to output file
- 06-18 01:05:39 INFO - Sign Hap success!
- 06-18 01:05:39 INFO - sign-app success
复制代码
---------------------------------
再执行下hb build 全部通过
- [OHOS INFO] [573/578] ACTION //build/ohos/packages:phone_parts_list(//build/lite/toolchain:linux_x86_64_ohos_clang)
- [OHOS INFO] [574/578] STAMP obj/build/ohos/packages/phone_parts_list.stamp
- [OHOS INFO] [575/578] ACTION //build/ohos/packages:gen_required_modules_phone(//build/lite/toolchain:linux_x86_64_ohos_clang)
- [OHOS INFO] [576/578] STAMP obj/build/ohos/packages/gen_required_modules_phone.stamp
- [OHOS INFO] [577/578] STAMP obj/build/ohos/packages/make_packages.stamp
- [OHOS INFO] [578/578] STAMP obj/build/core/gn/packages.stamp
- [OHOS INFO] 记录了53934+0 的读入
- [OHOS INFO] 记录了53934+0 的写出
- [OHOS INFO] 27614208字节(28 MB,26 MiB)已复制,0.0910722 s,303 MB/s
- [OHOS INFO] 记录了53918+0 的读入
- [OHOS INFO] 记录了53918+0 的写出
- [OHOS INFO] 27606016字节(28 MB,26 MiB)已复制,0.0907563 s,304 MB/s
- [OHOS INFO] 记录了102400+0 的读入
- [OHOS INFO] 记录了102400+0 的写出
- [OHOS INFO] 52428800字节(52 MB,50 MiB)已复制,0.167584 s,313 MB/s
- [OHOS INFO] c targets overlap rate statistics
- [OHOS INFO] subsystem files NO. percentage builds NO. percentage overlap rate
- [OHOS INFO] aafwk 60 0.9% 60 0.9% 1.00
- [OHOS INFO] ace 687 10.7% 687 10.7% 1.00
- [OHOS INFO] ai 76 1.2% 76 1.2% 1.00
- [OHOS INFO] appexecfwk 38 0.6% 38 0.6% 1.00
- [OHOS INFO] communication 214 3.3% 214 3.3% 1.00
- [OHOS INFO] distributedschedule 43 0.7% 43 0.7% 1.00
- [OHOS INFO] global 38 0.6% 38 0.6% 1.00
- [OHOS INFO] graphic 325 5.0% 325 5.0% 1.00
- [OHOS INFO] hdf 625 9.7% 625 9.7% 1.00
- [OHOS INFO] hiviewdfx 9 0.1% 9 0.1% 1.00
- [OHOS INFO] kernel 2408 37.4% 2408 37.4% 1.00
- [OHOS INFO] multimedia 120 1.9% 120 1.9% 1.00
- [OHOS INFO] powermgr 25 0.4% 25 0.4% 1.00
- [OHOS INFO] securec 117 1.8% 117 1.8% 1.00
- [OHOS INFO] security 285 4.4% 285 4.4% 1.00
- [OHOS INFO] sensors 7 0.1% 7 0.1% 1.00
- [OHOS INFO] startup 68 1.1% 68 1.1% 1.00
- [OHOS INFO] third_party 1316 20.4% 1316 20.4% 1.00
- [OHOS INFO] updater 4 0.1% 4 0.1% 1.00
- [OHOS INFO] utils 12 0.2% 12 0.2% 1.00
- [OHOS INFO]
- [OHOS INFO] c overall build overlap rate: 1.00
- [OHOS INFO]
- [OHOS INFO]
- [OHOS INFO] ipcamera_hispark_taurus build success
- [OHOS INFO] cost time: 0:01:49
复制代码 |
|