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