From ea2f098443d7e92f8682eff729dcb17ea3cb9fb8 Mon Sep 17 00:00:00 2001 From: z30034863 Date: Mon, 31 Mar 2025 22:10:50 +0800 Subject: [PATCH 1/9] fix ohos_packing_tool loge Signed-off-by: z30034863 --- .../frameworks/src/json/hap_verify_utils.cpp | 10 +++++----- packing_tool/frameworks/src/json/module_json.cpp | 2 +- packing_tool/frameworks/src/multiapp_packager.cpp | 6 ++++-- packing_tool/frameworks/src/packager.cpp | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/packing_tool/frameworks/src/json/hap_verify_utils.cpp b/packing_tool/frameworks/src/json/hap_verify_utils.cpp index 67529c05..d0d9fd6a 100644 --- a/packing_tool/frameworks/src/json/hap_verify_utils.cpp +++ b/packing_tool/frameworks/src/json/hap_verify_utils.cpp @@ -520,7 +520,7 @@ bool HapVerifyUtils::CheckApiVersionCovered(const ApiVersion& apiVersion, const std::set excludeSet; for (auto& hapVerifyInfo : entryHaps) { if (hapVerifyInfo.GetDistroFilter().IsEmpty() || hapVerifyInfo.GetDistroFilter().apiVersion.IsEmpty()) { - LOGE("distro filter is empty or apiVersion is empty."); + LOGW("distro filter is empty or apiVersion is empty."); return true; } if (hapVerifyInfo.GetDistroFilter().apiVersion.policy.empty()) { @@ -550,7 +550,7 @@ bool HapVerifyUtils::CheckScreenShapeCovered(const ScreenShape& screenShape, con std::set excludeSet; for (HapVerifyInfo hapVerifyInfo : entryHaps) { if (hapVerifyInfo.GetDistroFilter().IsEmpty() || hapVerifyInfo.GetDistroFilter().screenShape.IsEmpty()) { - LOGE("distro filter is empty or screenShape is empty."); + LOGW("distro filter is empty or screenShape is empty."); return true; } if (hapVerifyInfo.GetDistroFilter().screenShape.policy.empty()) { @@ -581,7 +581,7 @@ bool HapVerifyUtils::CheckScreenWindowCovered(const ScreenWindow& screenWindow, std::set excludeSet; for (HapVerifyInfo hapVerifyInfo : entryHaps) { if (hapVerifyInfo.GetDistroFilter().IsEmpty() || hapVerifyInfo.GetDistroFilter().screenWindow.IsEmpty()) { - LOGE("distro filter is empty or screenWindow is empty."); + LOGW("distro filter is empty or screenWindow is empty."); return true; } if (hapVerifyInfo.GetDistroFilter().screenWindow.policy.empty()) { @@ -612,7 +612,7 @@ bool HapVerifyUtils::CheckScreenDensityCovered(const ScreenDensity& screenDensit std::set excludeSet; for (HapVerifyInfo hapVerifyInfo : entryHaps) { if (hapVerifyInfo.GetDistroFilter().IsEmpty() || hapVerifyInfo.GetDistroFilter().screenDensity.IsEmpty()) { - LOGE("distro filter is empty or screenDensity is empty."); + LOGW("distro filter is empty or screenDensity is empty."); return true; } if (hapVerifyInfo.GetDistroFilter().screenDensity.policy.empty()) { @@ -642,7 +642,7 @@ bool HapVerifyUtils::CheckCountryCodeCovered(const CountryCode& countryCode, con std::set excludeSet; for (HapVerifyInfo hapVerifyInfo : entryHaps) { if (hapVerifyInfo.GetDistroFilter().IsEmpty() || hapVerifyInfo.GetDistroFilter().countryCode.IsEmpty()) { - LOGE("distro filter is empty or countryCode is empty."); + LOGW("distro filter is empty or countryCode is empty."); return true; } if (hapVerifyInfo.GetDistroFilter().countryCode.policy.empty()) { diff --git a/packing_tool/frameworks/src/json/module_json.cpp b/packing_tool/frameworks/src/json/module_json.cpp index bc3065f2..ce994d91 100644 --- a/packing_tool/frameworks/src/json/module_json.cpp +++ b/packing_tool/frameworks/src/json/module_json.cpp @@ -1099,7 +1099,7 @@ bool ModuleJson::IsModuleAtomicServiceValid() return false; } if (!moduleObj->Contains(ATOMIC_SERVICE.c_str())) { - LOGE("Module node has no %s node!", ATOMIC_SERVICE.c_str()); + LOGW("Module node has no %s node!", ATOMIC_SERVICE.c_str()); return true; } std::unique_ptr appObj; diff --git a/packing_tool/frameworks/src/multiapp_packager.cpp b/packing_tool/frameworks/src/multiapp_packager.cpp index e5052651..22c1e342 100644 --- a/packing_tool/frameworks/src/multiapp_packager.cpp +++ b/packing_tool/frameworks/src/multiapp_packager.cpp @@ -151,15 +151,17 @@ bool MultiAppPackager::IsVerifyValidInMultiAppMode() return false; } + std::string force; auto it = parameterMap_.find(Constants::PARAM_FORCE); if (it != parameterMap_.end() && !it->second.empty()) { - if (Utils::IsFileExists(outPath) && it->second == "false") { + force = it->second; + if (Utils::IsFileExists(outPath) && force == "false") { LOGE("out-path file already existed."); return false; } } - return true; + return IsOutPathValid(outPath, force, Constants::MODE_MULTIAPP); } bool MultiAppPackager::CopyHapAndHspFromApp(const std::string &appPath, std::list &selectedHapsInApp, diff --git a/packing_tool/frameworks/src/packager.cpp b/packing_tool/frameworks/src/packager.cpp index a55d72d2..7401829c 100644 --- a/packing_tool/frameworks/src/packager.cpp +++ b/packing_tool/frameworks/src/packager.cpp @@ -212,6 +212,19 @@ bool Packager::IsOutPathValid(const std::string &outPath, const std::string &for LOGE("Packager::isOutPathValid out file already existed."); return false; } + + try { + if (!std::filesystem::exists(filePath.parent_path())) { + std::error_code ec; + if (!std::filesystem::create_directories(filePath.parent_path(), ec)) { + LOGE("Packager::Failed to create directory: [%s]", ec.message().c_str()); + return false; + } + } + } catch (const std::filesystem::filesystem_err& e) { + LOGE("Packager::Failed to create directory,catch error: [%s]", e.what()); + return false; + } if (suffix == Constants::HAP_SUFFIX) { if (!Utils::EndsWith(filePath.filename().string(), Constants::HAP_SUFFIX)) { @@ -248,6 +261,8 @@ bool Packager::IsOutPathValid(const std::string &outPath, const std::string &for } else { return true; } + } else if (suffix == Constants::MODE_MULTIAPP) { + return true; } return false; } -- Gitee From 0397e62687866f8ad0da79c6e03d15a21daa025f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B8=B0=E5=A3=AE?= Date: Mon, 31 Mar 2025 14:32:50 +0000 Subject: [PATCH 2/9] update packing_tool/frameworks/src/packager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张丰壮 --- packing_tool/frameworks/src/packager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packing_tool/frameworks/src/packager.cpp b/packing_tool/frameworks/src/packager.cpp index 7401829c..84fa3291 100644 --- a/packing_tool/frameworks/src/packager.cpp +++ b/packing_tool/frameworks/src/packager.cpp @@ -221,7 +221,7 @@ bool Packager::IsOutPathValid(const std::string &outPath, const std::string &for return false; } } - } catch (const std::filesystem::filesystem_err& e) { + } catch (const std::filesystem::filesystem_error& e) { LOGE("Packager::Failed to create directory,catch error: [%s]", e.what()); return false; } -- Gitee From 8b473080a04959838fe0cb82655eb95ced5c4464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B8=B0=E5=A3=AE?= Date: Mon, 31 Mar 2025 14:34:10 +0000 Subject: [PATCH 3/9] update packing_tool/frameworks/src/multiapp_packager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张丰壮 --- packing_tool/frameworks/src/multiapp_packager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packing_tool/frameworks/src/multiapp_packager.cpp b/packing_tool/frameworks/src/multiapp_packager.cpp index 22c1e342..a3014d69 100644 --- a/packing_tool/frameworks/src/multiapp_packager.cpp +++ b/packing_tool/frameworks/src/multiapp_packager.cpp @@ -151,10 +151,10 @@ bool MultiAppPackager::IsVerifyValidInMultiAppMode() return false; } - std::string force; + std::string force; auto it = parameterMap_.find(Constants::PARAM_FORCE); if (it != parameterMap_.end() && !it->second.empty()) { - force = it->second; + force = it->second; if (Utils::IsFileExists(outPath) && force == "false") { LOGE("out-path file already existed."); return false; -- Gitee From ac223ca38d905973fcd527363f889a3add43e129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B8=B0=E5=A3=AE?= Date: Mon, 31 Mar 2025 14:37:50 +0000 Subject: [PATCH 4/9] update packing_tool/frameworks/src/packager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张丰壮 --- packing_tool/frameworks/src/packager.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packing_tool/frameworks/src/packager.cpp b/packing_tool/frameworks/src/packager.cpp index 84fa3291..77baf96e 100644 --- a/packing_tool/frameworks/src/packager.cpp +++ b/packing_tool/frameworks/src/packager.cpp @@ -213,18 +213,18 @@ bool Packager::IsOutPathValid(const std::string &outPath, const std::string &for return false; } - try { - if (!std::filesystem::exists(filePath.parent_path())) { - std::error_code ec; - if (!std::filesystem::create_directories(filePath.parent_path(), ec)) { - LOGE("Packager::Failed to create directory: [%s]", ec.message().c_str()); + try { + if (!std::filesystem::exists(filePath.parent_path())) { + std::error_code ec; + if (!std::filesystem::create_directories(filePath.parent_path(), ec)) { + LOGE("Packager::Failed to create directory: [%s]", ec.message().c_str()); return false; } } - } catch (const std::filesystem::filesystem_error& e) { - LOGE("Packager::Failed to create directory,catch error: [%s]", e.what()); - return false; - } + } catch (const std::filesystem::filesystem_error& e) { + LOGE("Packager::Failed to create directory,catch error: [%s]", e.what()); + return false; + } if (suffix == Constants::HAP_SUFFIX) { if (!Utils::EndsWith(filePath.filename().string(), Constants::HAP_SUFFIX)) { -- Gitee From 0c73d80ec5f99e91f45090badbb5c3b1293bb23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B8=B0=E5=A3=AE?= Date: Mon, 31 Mar 2025 14:55:45 +0000 Subject: [PATCH 5/9] update packing_tool/frameworks/src/packager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张丰壮 --- packing_tool/frameworks/src/packager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packing_tool/frameworks/src/packager.cpp b/packing_tool/frameworks/src/packager.cpp index 77baf96e..1adcb440 100644 --- a/packing_tool/frameworks/src/packager.cpp +++ b/packing_tool/frameworks/src/packager.cpp @@ -218,9 +218,9 @@ bool Packager::IsOutPathValid(const std::string &outPath, const std::string &for std::error_code ec; if (!std::filesystem::create_directories(filePath.parent_path(), ec)) { LOGE("Packager::Failed to create directory: [%s]", ec.message().c_str()); - return false; + return false; } - } + } } catch (const std::filesystem::filesystem_error& e) { LOGE("Packager::Failed to create directory,catch error: [%s]", e.what()); return false; -- Gitee From 6cdf212b4876ab0dab88e11df5133b1aaf8961b1 Mon Sep 17 00:00:00 2001 From: z30034863 Date: Mon, 31 Mar 2025 23:12:27 +0800 Subject: [PATCH 6/9] fix loge Signed-off-by: z30034863 --- packing_tool/frameworks/src/packager.cpp | 33 +++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/packing_tool/frameworks/src/packager.cpp b/packing_tool/frameworks/src/packager.cpp index 1adcb440..e41dfcb6 100644 --- a/packing_tool/frameworks/src/packager.cpp +++ b/packing_tool/frameworks/src/packager.cpp @@ -204,27 +204,36 @@ bool Packager::CompatibleProcess(const std::string &inputPath, std::list Date: Mon, 31 Mar 2025 15:19:33 +0000 Subject: [PATCH 7/9] update packing_tool/frameworks/src/packager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张丰壮 --- packing_tool/frameworks/src/packager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packing_tool/frameworks/src/packager.cpp b/packing_tool/frameworks/src/packager.cpp index e41dfcb6..ea395db0 100644 --- a/packing_tool/frameworks/src/packager.cpp +++ b/packing_tool/frameworks/src/packager.cpp @@ -233,7 +233,7 @@ bool Packager::IsOutPathValid(const std::string &outPath, const std::string &for if (!EnsureParentDirectoryExists(filePath) { return false; - } + } if (suffix == Constants::HAP_SUFFIX) { if (!Utils::EndsWith(filePath.filename().string(), Constants::HAP_SUFFIX)) { -- Gitee From 6b866af9f1dbcb44253bfc87298560c61696ae32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B8=B0=E5=A3=AE?= Date: Tue, 1 Apr 2025 01:18:52 +0000 Subject: [PATCH 8/9] update packing_tool/frameworks/src/packager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张丰壮 --- packing_tool/frameworks/src/packager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/packing_tool/frameworks/src/packager.cpp b/packing_tool/frameworks/src/packager.cpp index ea395db0..ed5a3d7d 100644 --- a/packing_tool/frameworks/src/packager.cpp +++ b/packing_tool/frameworks/src/packager.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "json/json_utils.h" #include "log.h" -- Gitee From 722636d0f3155080e4a0875fa154f05817682e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B8=B0=E5=A3=AE?= Date: Tue, 1 Apr 2025 01:31:31 +0000 Subject: [PATCH 9/9] update packing_tool/frameworks/src/packager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张丰壮 --- packing_tool/frameworks/src/packager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packing_tool/frameworks/src/packager.cpp b/packing_tool/frameworks/src/packager.cpp index ed5a3d7d..238085d5 100644 --- a/packing_tool/frameworks/src/packager.cpp +++ b/packing_tool/frameworks/src/packager.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include "json/json_utils.h" #include "log.h" @@ -205,7 +204,7 @@ bool Packager::CompatibleProcess(const std::string &inputPath, std::list