• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14set -e
15root_path=$1
16unpack_build_out_jar_path=$2
17unpack_build_out_path=$3
18big_version=$4
19toolchain=$5
20final_path=$(pwd)
21
22jar_dir="jar"
23unpack_jar_file="app_unpacking_tool.jar"
24fastjson_jar_file="fastjson-1.2.83.jar"
25jar_directory="${root_path}/${jar_dir}"
26unpack_jar_path="${root_path}/${jar_dir}/${unpack_jar_file}"
27fastjson_jar_path="${root_path}/jar/fastjson-1.2.83.jar"
28manifest_path="${root_path}/META-INF/unpacking_tool/MANIFEST.MF"
29out_dir="${root_path}/out/${toolchain}/unpacking_tool"
30if [ -d "${out_dir}/ohos" ]
31    then
32        echo "${out_dir}/ohos exist"
33    else
34        mkdir -p "${out_dir}/ohos"
35fi
36
37unpack_out_jar_path="${final_path}/${unpack_build_out_jar_path}"
38unpack_out_path="${final_path}/${unpack_build_out_path}"
39
40java_collection=""
41declare -a unpack_class=(
42            "BundleException.java"
43            "CommandParser.java"
44            "Log.java"
45            "PackFormatter.java"
46            "ShowHelp.java"
47            "UncompressEntrance.*"
48            "Uncompress.java"
49            "UncompressVerify.java"
50            "Utility.java"
51            "HapInfo.java"
52            "ReqPermission.java"
53            "Distro.java"
54            "AbilityInfo.java"
55            "MetaData.java"
56            "MetaDataInfo.java"
57            "SkillInfo.java"
58            "UsedScene.java"
59            "PackInfo.java"
60            "FormInfo.java"
61            "ProfileInfo.java"
62            "AppInfo.java"
63            "DefPermission.java"
64            "DefPermissionGroup.java"
65            "CustomizeData.java"
66            "UncompressResult.java"
67            "JsonUtil.java"
68            "JsInfo.java"
69            "DeviceConfig.java"
70            "CommonEvent.java"
71            "Shortcut.java"
72            "IntentInfo.java"
73            "ResourcesParser.java"
74            "DistroFilter.java"
75            "ApiVersion.java"
76            "ScreenShape.java"
77            "ScreenDensity.java"
78            "ScreenWindow.java"
79            "CountryCode.java"
80            "HapZipInfo.java"
81            "AbilityFormInfo.java"
82            "ModuleAbilityInfo.java"
83            "ModuleAppInfo.java"
84            "ModuleDeviceType.java"
85            "ModuleInfo.java"
86            "ModuleMetadataInfo.java"
87            "ModuleProfileInfo.java"
88            "ModuleResult.java"
89            "UriInfo.java"
90            "ExtensionAbilityInfo.java"
91            "ModuleAdaption.java"
92            "ModuleShortcut.java"
93            "Want.java"
94            "DefinePermission.java"
95            "ResourceIndexResult.java"
96            "FileUtils.java"
97            "HQFInfo.java"
98            "APPQFResult.java"
99            "ModuleAtomicService.java"
100            "PreloadItem.java"
101            "DependencyItem.java"
102            "AppModel.java"
103            )
104unpack_class_length=${#unpack_class[@]}
105for ((i=0; i<${unpack_class_length};++i))
106do
107  java_collection="${java_collection} ${root_path}/adapter/ohos/${unpack_class[$i]}"
108done
109
110if [ "$big_version" == "true" ]
111    then
112        compile_command="javac --release 8 -cp ${fastjson_jar_path}  -d ${out_dir} ${java_collection}"
113        eval ${compile_command}
114    else
115        compile_command="javac -source 1.8 -target 1.8 -cp ${fastjson_jar_path}  -d ${out_dir} ${java_collection}"
116        eval ${compile_command}
117fi
118
119cd $out_dir
120temp_unpack_jar_path="${root_path}/${jar_dir}/unpack_${toolchain}/${unpack_jar_file}"
121temp_unpack_jart_dir="${root_path}/${jar_dir}/unpack_${toolchain}"
122product_unpack_jar_command="jar -cvfm ${temp_unpack_jar_path} $manifest_path ./ohos"
123if [ -d "${temp_unpack_jart_dir}" ]
124    then
125        echo "${temp_unpack_jart_dir} exist"
126    else
127        mkdir -p "${temp_unpack_jart_dir}"
128fi
129eval ${product_unpack_jar_command}
130if [ -f "${unpack_jar_path}" ]
131    then
132        echo "${unpack_jar_path} exist"
133    else
134        cp ${temp_unpack_jar_path} ${unpack_jar_path}
135fi
136# make out dir
137if [ -d "$unpack_out_path" ]
138    then
139        echo "$unpack_out_path exist"
140    else
141        mkdir -p $unpack_out_path
142fi
143copy_command="cp ${temp_unpack_jar_path} ${unpack_out_jar_path}"
144eval ${copy_command}
145rm -rf ${temp_unpack_jart_dir}