1/*
2 * Copyright (c) 2019-2021 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.
14 */
15
16use commands for package hap or app.
17
18CONSTRAINT:
191.When the app depends on a hap, you need to wait the hap has been packaged,
20 It can be controlled according to the return value of the command execution.
212.If the same command appears many times in a command, take the last value that appears.
22 For example: --mode hap --mode app
23 the mode value is app.
243.If there are several parameters in the same command, take the first value.
25 For example: --mode hap app
26 the mode value is hap.
274.Path cannot start with '--', to avoid conflict with the instruction.
285.Command must be lowercase(such as:--mode), and file's suffix is case insensitive,
29 but json's filename must be config.json and index's filename must be resources.index.
306.Absolute paths is recommended.
317.After package a hap, files under resources/ will put into assets/entry/resources/ directory,
32 files under lib/ will be putted into libs/ directory,
33 files under maple-so/ will be putted into maple/ directory,
34 file of resources.index will be putted into assets/entry/ directory.
358.maple so input method have a tentative plan which can support two input methods.
36 If "maple-so-path" is valid, "maple-so-dir" will not be used.
37 The input method of "maple-so-path" will be discarded later.
389.In app package mode, signature and certificate may be resource files later,
39 so parameters are reserved now.
40
41HAP USAGE:
42java -jar hmos_app_packing_tool.jar --mode <option> --json-path <option> --maple-so-path [option]
43--profile-path [option] --maple-so-dir [option] --dex-path [option] --lib-path [option] --assets-path [option]
44--resources-path [option] --shell-apk-path [option] --index-path [option] --out-path <option> --force [option]
45
46HAP MODE OPTIONS:
47 --mode not null must be hap.
48 --json-path not null config.json path.
49 --profile-path CAPABILITY.profile path.
50 --maple-so-path maple-so/ path.
51 --maple-so-dir maple so path must end with .so, if has more than one so,
52 use comma(,) to separate.
53 --dex-path 1.dex path must end with .dex, if has more than one dex,
54 use comma(,) to separate.
55 2.dex path also can be directory path.
56 --abc-path 1.abc path must end with .abc, if has more than one abc,
57 use comma(,) to separate.
58 2.abc path also can be directory path.
59 --lib-path lib/ path.
60 --assets-path assets/ path.
61 --resources-path resources path.
62 --shell-apk-path 1.shell apk path can end with .apk, if has more than one apk,
63 use comma(,) to separate.
64 2.shell apk path also can be directory path.
65 --index-path resources.index path.
66 --out-path not null target hap binary path,must end with .hap.
67 --force default false; if true, force delete destination
68 out file if exists.
69
70HAR USAGE:
71java -jar hmos_app_packing_tool.jar --mode <options> --json-path <option>
72--jar-path <option> --lib-path [option] --assets-path [option]
73--resources-path [option] --out-path <option> --force [option]
74OPTIONS:
75 --mode not null must be har.
76 --json-path not null config.json path.
77 --jar-path not null 1.jar path must end with .jar,
78 if has more than one jar, use comma(,) to separate;
79 2.jar path also can be directory path.
80 --lib-path lib/ path.
81 --resources-path not null resources/ path.
82 --txt-path not null 1.txt path must end with .txt,
83 if has more than one txt, use comma(,) to separate;
84 2.txt path also can be directory path.
85 --out-path not null target har binary path, must end with .har.
86 --force default false; if true, force delete destination
87 out file if exists.
88
89APP USAGE:
90java -jar hmos_app_packing_tool.jar --mode <option> --hap-path <option> --out-path <option>
91--pack-info-path <option> --signature-path [option] --certificate-path [option] --force [option]
92
93APP MODE OPTIONS:
94 --mode not null must be app.
95 --hap-path not null 1.hap path can end with .hap, if has more than one hap,
96 use comma(,) to separate.
97 2.hap path also can be directory path.
98 --pack-info-path not null pack.info path.
99 --out-path not null target app binary path,must end with .app.
100 --force default false; if true, force delete destination
101 out file if exists.
102 --signature-path signature file path.
103 --certificate-path certificate file path.
104
105RETURN VALUE:
106In both modes, if package success return 0, fail return 1.
107
108EXAMPLES:
109package module1.hap
110 java -jar hmos_app_packing_tool.jar --mode hap --json-path example/config.json
111 --index-path example/resources.index --maple-so-path example/maple-so
112 --dex-path example/test1.dex,example/test2.dex --shell-apk-path example/test1.apk,example/test2.apk
113 --resources-path example/resources/ --lib-path example/lib/ --out-path example/out/module1.hap --force true
114
115 example/out/module1.hap
116 | config.json,test1.dex,test2.dex,test1.apk,test2.apk
117 |----libs
118 | | test1.xml
119 | |----lib
120 | | | test2.xml
121 |----assets
122 | |----entry
123 | | | resources.index
124 | | |----resources
125 | | | | test3.xml
126 |----maple
127 | |----arm64
128 | | | test1.so,test2.so
129
130package module2.hap
131 java -jar hmos_app_packing_tool.jar --mode hap --json-path example/config.json
132 --out-path example/out/module2.hap --force true
133
134 example/out/module2.hap
135 | config.json
136
137package demo.app
138 java -jar hmos_app_packing_tool.jar --mode app --hap-path example/out/module1.hap,example/out/module2.hap
139 --signature-path example/signature --certificate-path example/certificate
140 --pack-info-path example/pack.info --out-path example/out/demo.app --force true
141
142 example/out/demo.app
143 | module1.hap
144 | module2.hap
145 | pack.info
146 | signature
147 | certificate
148
149
150-----------------------------------------------------------------------------------------------
151
152use commands for unpackage hap or app.
153
154CONSTRANIT:
1551.When the hap depends on a app, you need to wait the app has been unpackaged,
156 It can be controlled according to the return value of the command execution.
1572.If the same command appears many times in a command, take the last value that appears.
158 For example: --mode hap --mode app
159 the mode value is app.
1603.If there are several parameters in the same command, take the first value.
161 For example: --mode hap app
162 the mode value is hap.
1634.Path cannot start with '--', to avoid conflict with the instruction.
1645.Command must be lowercase(such as:--mode), and file's suffix is case insensitive.
1656.Absolute paths is recommended.
1667.Output path can be specified. The default output path is the path where the app or hap is located.
1678.After unpackage a hap, json file will be unzipped to the output path.
168 And after unpackage an app, all hap file will be unzipped to the output path.
169
170HAP USAGE:
171java -jar hmos_app_unpacking_tool.jar --mode <options> --hap-path <option>
172--out-path [option] --force [option] --unpackapk [option]
173
174HAP MODE OPTIONS:
175 --mode not null must be hap.
176 --hap-path not null hap path.
177 --out-path target hap unpackage path.
178 --force default false; if true, force delete destination
179 out file if exists.
180 --unpack-cut_entry default false; if true, unpack the cut_entry.apk
181
182HAR USAGE:
183java -jar hmos_app_unpacking_tool.jar --mode <options> --har-path <option>
184--out-path [option] --force [option]
185OPTIONS:
186 --mode not null must be har.
187 --har-path not null har path.
188 --out-path not null target path of unzip.
189 --force default false; if true, force delete destination
190 out file if exists.
191
192APP USAGE:
193java -jar hmos_app_unpacking_tool.jar --mode <options> --app-path <option>
194--out-path [option] --force [option] --unpackapk [option]
195
196APP MODE OPTIONS:
197 --mode not null must be app.
198 --app-path not null app path.
199 --out-path target app unpackage path.
200 --force default false; if true, force delete destination
201 out file if exists.
202 --unpackapk default false; if true, unpack apk files from hap
203 in the app.
204
205RETURN VALUE:
206In both modes, if unpackage successfully return 0, fail return 1.
207
208EXAMPLES:
209unpackage demo.app
210 java -jar hmos_app_unpacking_tool.jar --mode app --app-path example/demo.app
211 --out-path example/out/ --force true
212
213unpackage test1.hap
214 java -jar hmos_app_unpacking_tool.jar --mode hap --hap-path example/out/module1.hap
215 --out-path example/out/TEST --force true
216
217unpackage test2.hap
218 java -jar hmos_app_unpacking_tool.jar --mode hap --hap-path example/out/module2.hap --force true
219
220 example/out
221 | module1.hap
222 | module2.hap
223 |----TEST
224 | | config.json
225 |----module2
226 | | config.json
227