• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright (c) 2022-2025 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 -eux
15set -o pipefail
16root_path=$1
17unpack_build_out_jar_path=$2
18unpack_build_out_path=$3
19big_version=$4
20toolchain=$5
21compile_java=$6
22fastjson_jar=$7
23fastjson2_jar=$8
24fastjson2ext_jar=$9
25final_path=$(pwd)
26
27jar_dir="jar"
28unpack_jar_file="app_unpacking_tool.jar"
29jar_directory="${root_path}/${jar_dir}"
30unpack_jar_path="${root_path}/${jar_dir}/${unpack_jar_file}"
31manifest_path="${root_path}/META-INF/unpacking_tool/MANIFEST.MF"
32out_dir="${root_path}/out/${toolchain}/unpacking_tool"
33if [ -d "${out_dir}/ohos" ]
34    then
35        echo "${out_dir}/ohos exist"
36    else
37        mkdir -p "${out_dir}/ohos"
38fi
39
40unpack_out_jar_path="${final_path}/${unpack_build_out_jar_path}"
41unpack_out_path="${final_path}/${unpack_build_out_path}"
42
43if [ "$big_version" == "true" ]
44    then
45        compile_command="javac --release 8 -cp ${fastjson_jar}:${fastjson2_jar}:${fastjson2ext_jar} \
46        -d ${out_dir} ${compile_java}"
47        eval ${compile_command}
48    else
49        compile_command="javac -source 1.8 -target 1.8 -cp ${fastjson_jar}:${fastjson2_jar}:${fastjson2ext_jar} \
50        -d ${out_dir} ${compile_java}"
51        eval ${compile_command}
52fi
53
54cd $out_dir
55temp_unpack_jar_path="${root_path}/${jar_dir}/unpack_${toolchain}/${unpack_jar_file}"
56temp_unpack_jart_dir="${root_path}/${jar_dir}/unpack_${toolchain}"
57product_unpack_jar_command="jar -cvfm ${temp_unpack_jar_path} $manifest_path ./ohos"
58if [ -d "${temp_unpack_jart_dir}" ]
59    then
60        echo "${temp_unpack_jart_dir} exist"
61    else
62        mkdir -p "${temp_unpack_jart_dir}"
63fi
64eval ${product_unpack_jar_command}
65if [ -f "${unpack_jar_path}" ]
66    then
67        echo "${unpack_jar_path} exist"
68    else
69        cp ${temp_unpack_jar_path} ${unpack_jar_path}
70fi
71# make out dir
72if [ -d "$unpack_out_path" ]
73    then
74        echo "$unpack_out_path exist"
75    else
76        mkdir -p $unpack_out_path
77fi
78copy_command="cp ${temp_unpack_jar_path} ${unpack_out_jar_path}"
79eval ${copy_command}
80rm -rf ${temp_unpack_jart_dir}