-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.sh
executable file
·203 lines (157 loc) · 4.02 KB
/
package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
##
## Copyright (c) 2021 HopeBayTech.
##
## This file is part of Tera.
## See https://github.com/HopeBayMobile for further info.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
# How To Use Script
# 1.Prepare apk and hcfs first
## Apk name app-release.apk
## HCFS from source build, and copy hold system folder
## Apk with branch tmp_root_tera and name apk app-release.apk.
## HCFS with branch root_android_7_0 and name directory system.
# 2. Prepare two libcurl for 6.0.1 and 7.1.2
## then name libcurl-32bit-6.0.1.so and libcurl-32bit-7.1.2.so
# ONLY use this script with last commit contain "Version: xxxx"
HCFS_32_dir="system"
apk_filename="app-release.apk"
get_latest_version() {
git log | grep --regexp="Version: " -m 1 | sed 's/Version: //g' | sed 's/ //g' > ./out/version
}
checkout() {
git checkout .
}
message() {
echo
echo "Packaging $1"
echo
}
package() {
# Add version name for directory
version=`cat ./out/version`
echo "Root-tera Version: $version"
mv root-tera root-tera-$version-$1
zip -r out/root-tera-$version-$1.zip root-tera-$version-$1
mv root-tera-$version-$1 root-tera
}
copy_hcfs_32bit() {
check_hcfs_files
cp -r out/system/bin/* root-tera/files/
cp -r out/system/lib/* root-tera/files/
remove_unnecessary
}
check_hcfs_files() {
if [ ! -d ./out/$HCSF_32_dir ]; then
echo "./out/system not found"
exit 1
fi
}
copy_apk() {
check_apk_file
cp -r out/app-release.apk root-tera/files/HopebayHCFSmgmt.apk
}
check_apk_file() {
if [ ! -e ./out/$apk_filename ]; then
echo "app-release.apk not found in ./out"
exit 1
fi
}
check_libcurl_file() {
if [ ! -e ./out/$1 ]; then
echo "prebuild libcurl not found: $1"
exit 1
fi
echo "libcurl file found: $1"
}
remove_unnecessary() {
rm root-tera/files/api_test
rm root-tera/files/libhcfsapi.so
rm root-tera/files/liblz4-tera.so
}
seven_to_eight_64() {
version="7.1.X-8.0.0_64-bit"
message $version
git checkout origin/master
copy_apk
package $version
checkout
}
seven_to_eight_32() {
version="7.1.X-8.0.0_32-bit"
message $version
git checkout origin/master
copy_hcfs_32bit
# Copy coresponding libcurl
check_libcurl_file libcurl-32bit-7.1.2.so
cp -r out/libcurl-32bit-7.1.2.so root-tera/files/libcurl.so
copy_apk
package $version
checkout
}
six_to_seven_64() {
version="6.0.X-7.0.0_64-bit"
message $version
git checkout origin/feature/android_7_0
cp -r root-tera/files out/
git checkout origin/master
cp -r out/files root-tera/
copy_apk
package $version
rm -rf out/files
checkout
}
six_to_seven_32() {
version="6.0.X-7.0.0_32-bit"
message $version
git checkout origin/master
copy_hcfs_32bit
# Copy coresponding libcurl
check_libcurl_file libcurl-32bit-6.0.1.so
cp -r out/libcurl-32bit-6.0.1.so root-tera/files/libcurl.so
copy_apk
package $version
checkout
}
four_point_four_32() {
version="4.4.X_32-bit"
message $version
git checkout origin/master
copy_hcfs_32bit
copy_apk
package $version
checkout
}
# Main
if [[ $1 == "clean" ]]; then
rm -rf out/root-tera*.zip
echo "Clean package in ./out"
echo ""
ls -l ./out
exit 0
fi
if [ ! -d out ]; then
mkdir out
echo "put necessery apk and hcfs in ./out"
exit 1
fi
git checkout .
git checkout origin/master
get_latest_version
seven_to_eight_64
seven_to_eight_32
six_to_seven_64
six_to_seven_32
four_point_four_32
rm ./out/version