-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge
executable file
·158 lines (141 loc) · 11.3 KB
/
merge
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
#!/bin/bash
# Copyright (c) 2018, Redmaner
VERSION=18.04.22NL
up=$PWD/merge
git_root=$PWD
# Define bash colors for Mac OSX / Linux
case `uname -s` in
Darwin)
txtrst='\033[0m' # Color off
txtred='\033[0;31m' # Red
txtgrn='\033[0;32m' # Green
txtblu='\033[0;34m' # Blue
;;
*)
txtrst='\e[0m' # Color off
txtred='\e[1;31m' # Red
txtgrn='\e[1;32m' # Green
txtblu='\e[1;36m' # Blue
;;
esac
echo -e "
#################################################
MIUI MERGER V$VERSION
#################################################
"
# Source information
source $up/config
values=values
max_proces() {
while [ $(jobs | wc -l) -gt $max_processes ]; do
sleep 1;
done
}
# Main event
SingleMerge () {
find $orig_dir -iname "*.apk" | sort -rh | while read apk; do
apk_name=$(basename $apk)
if [ -d $targ_dir/$apk_name ] && [ $(cat $blacklist | grep ''$apk_name' strings.xml' | wc -l) == 0 ]; then
if [ -f "$orig_dir/$apk_name/res/$values/strings.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/strings.xml" ]; then
max_proces; ($up/merge_strings $orig_dir/$apk_name/res/$values/strings.xml $targ_dir/$apk_name/res/values-$lang_iso/strings.xml $new_dir/$apk_name/res/values-$lang_iso/strings.xml $apk_name $untranslateable_list)&
elif [ -f "$orig_dir/$apk_name/res/$values/strings.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/strings.xml" ] && [ $merge_non_exsisting == "enabled" ]; then
max_proces; ($up/merge_strings $orig_dir/$apk_name/res/$values/strings.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/strings.xml $apk_name $untranslateable_list)&
fi
fi
done
wait
#find $orig_dir -iname "*.apk" | sort -rh | while read apk; do
# apk_name=$(basename $apk)
# if [ -d $targ_dir/$apk_name ] && [ $(cat $blacklist | grep ''$apk_name' arrays.xml' | wc -l) == 0 ]; then
# if [ -f "$orig_dir/$apk_name/res/$values/arrays.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/arrays.xml" ]; then
# max_proces; ($up/merge_arrays $orig_dir/$apk_name/res/$values/arrays.xml $targ_dir/$apk_name/res/values-$lang_iso/arrays.xml $new_dir/$apk_name/res/values-$lang_iso/arrays.xml $apk_name $untranslateable_list)&
# fi
# fi
#done
#wait
find $orig_dir -iname "*.apk" | sort -rh | while read apk; do
apk_name=$(basename $apk)
if [ -d $targ_dir/$apk_name ] && [ $(cat $blacklist | grep ''$apk_name' plurals.xml' | wc -l) == 0 ]; then
if [ -f "$orig_dir/$apk_name/res/$values/plurals.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/plurals.xml" ]; then
max_proces; ($up/merge_plurals $orig_dir/$apk_name/res/$values/plurals.xml $targ_dir/$apk_name/res/values-$lang_iso/plurals.xml $new_dir/$apk_name/res/values-$lang_iso/plurals.xml $apk_name $untranslateable_list)&
fi
fi
done
wait
}
# Main event dual merge
DualMerge () {
# Make one list of all apks in both repositories
find $orig_dir -iname "*.apk" | sort -rh | while read apk; do
basename $apk
done > $up/dual_merge_apk_list
find $orig_dir_second -iname "*.apk" | sort -rh | while read apk; do
basename $apk
done >> $up/dual_merge_apk_list
cat $up/dual_merge_apk_list | sort | uniq > $up/dual_merge_apk.list && rm $up/dual_merge_apk_list
cat $up/dual_merge_apk.list | while read apk_name; do
if [ -d $targ_dir/$apk_name ] && [ $(cat $blacklist | grep ''$apk_name' strings.xml' | wc -l) == 0 ]; then
if [ -f "$orig_dir/$apk_name/res/$values/strings.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/strings.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/strings.xml" ]; then
max_proces; ($up/merge_strings $orig_dir/$apk_name/res/$values/strings.xml $targ_dir/$apk_name/res/values-$lang_iso/strings.xml $new_dir/$apk_name/res/values-$lang_iso/strings.xml $apk_name $untranslateable_list $dual_merge $orig_dir_second/$apk_name/res/$values/strings.xml)&
elif [ -f "$orig_dir/$apk_name/res/$values/strings.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/strings.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/strings.xml" ]; then
max_proces; ($up/merge_strings $orig_dir/$apk_name/res/$values/strings.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/strings.xml $apk_name $untranslateable_list $dual_merge $orig_dir_second/$apk_name/res/$values/strings.xml)&
elif [ -f "$orig_dir/$apk_name/res/$values/strings.xml" ] && [ ! -f "$orig_dir_second/$apk_name/res/$values/strings.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/strings.xml" ]; then
max_proces; ($up/merge_strings $orig_dir/$apk_name/res/$values/strings.xml $targ_dir/$apk_name/res/values-$lang_iso/strings.xml $new_dir/$apk_name/res/values-$lang_iso/strings.xml $apk_name $untranslateable_list false)&
elif [ -f "$orig_dir/$apk_name/res/$values/strings.xml" ] && [ ! -f "$orig_dir_second/$apk_name/res/$values/strings.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/strings.xml" ]; then
max_proces; ($up/merge_strings $orig_dir/$apk_name/res/$values/strings.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/strings.xml $apk_name $untranslateable_list false)&
elif [ ! -f "$orig_dir/$apk_name/res/$values/strings.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/strings.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/strings.xml" ]; then
max_proces; ($up/merge_strings $orig_dir_second/$apk_name/res/$values/strings.xml $targ_dir/$apk_name/res/values-$lang_iso/strings.xml $new_dir/$apk_name/res/values-$lang_iso/strings.xml $apk_name $untranslateable_list false)&
elif [ ! -f "$orig_dir/$apk_name/res/$values/strings.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/strings.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/strings.xml" ]; then
max_proces; ($up/merge_strings $orig_dir_second/$apk_name/res/$values/strings.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/strings.xml $apk_name $untranslateable_list false)&
fi
fi
done
wait
#cat $up/dual_merge_apk.list | while read apk_name; do
# if [ -d $targ_dir/$apk_name ] && [ $(cat $blacklist | grep ''$apk_name' arrays.xml' | wc -l) == 0 ]; then
# if [ -f "$orig_dir/$apk_name/res/$values/arrays.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/arrays.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/arrays.xml" ]; then
# max_proces; ($up/merge_arrays $orig_dir/$apk_name/res/$values/arrays.xml $targ_dir/$apk_name/res/values-$lang_iso/arrays.xml $new_dir/$apk_name/res/values-$lang_iso/arrays.xml $apk_name $untranslateable_list $dual_merge $orig_dir_second/$apk_name/res/$values/arrays.xml)&
# elif [ -f "$orig_dir/$apk_name/res/$values/arrays.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/arrays.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/arrays.xml" ]; then
# max_proces; ($up/merge_arrays $orig_dir/$apk_name/res/$values/arrays.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/arrays.xml $apk_name $untranslateable_list $dual_merge $orig_dir_second/$apk_name/res/$values/arrays.xml)&
# elif [ -f "$orig_dir/$apk_name/res/$values/arrays.xml" ] && [ ! -f "$orig_dir_second/$apk_name/res/$values/arrays.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/arrays.xml" ]; then
# max_proces; ($up/merge_arrays $orig_dir/$apk_name/res/$values/arrays.xml $targ_dir/$apk_name/res/values-$lang_iso/arrays.xml $new_dir/$apk_name/res/values-$lang_iso/arrays.xml $apk_name $untranslateable_list false)&
# elif [ -f "$orig_dir/$apk_name/res/$values/arrays.xml" ] && [ ! -f "$orig_dir_second/$apk_name/res/$values/arrays.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/arrays.xml" ]; then
# max_proces; ($up/merge_arrays $orig_dir/$apk_name/res/$values/arrays.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/arrays.xml $apk_name $untranslateable_list false)&
# elif [ ! -f "$orig_dir/$apk_name/res/$values/arrays.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/arrays.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/arrays.xml" ]; then
# max_proces; ($up/merge_arrays $orig_dir_second/$apk_name/res/$values/arrays.xml $targ_dir/$apk_name/res/values-$lang_iso/arrays.xml $new_dir/$apk_name/res/values-$lang_iso/arrays.xml $apk_name $untranslateable_list false)&
# elif [ ! -f "$orig_dir/$apk_name/res/$values/arrays.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/arrays.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/arrays.xml" ]; then
# max_proces; ($up/merge_arrays $orig_dir_second/$apk_name/res/$values/arrays.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/arrays.xml $apk_name $untranslateable_list false)&
# fi
# fi
#done
#wait
cat $up/dual_merge_apk.list | while read apk_name; do
if [ -d $targ_dir/$apk_name ] && [ $(cat $blacklist | grep ''$apk_name' plurals.xml' | wc -l) == 0 ]; then
if [ -f "$orig_dir/$apk_name/res/$values/plurals.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/plurals.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/plurals.xml" ]; then
max_proces; ($up/merge_plurals $orig_dir/$apk_name/res/$values/plurals.xml $targ_dir/$apk_name/res/values-$lang_iso/plurals.xml $new_dir/$apk_name/res/values-$lang_iso/plurals.xml $apk_name $untranslateable_list $dual_merge $orig_dir_second/$apk_name/res/$values/plurals.xml)&
elif [ -f "$orig_dir/$apk_name/res/$values/plurals.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/plurals.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/plurals.xml" ]; then
max_proces; ($up/merge_plurals $orig_dir/$apk_name/res/$values/plurals.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/plurals.xml $apk_name $untranslateable_list $dual_merge $orig_dir_second/$apk_name/res/$values/plurals.xml)&
elif [ -f "$orig_dir/$apk_name/res/$values/plurals.xml" ] && [ ! -f "$orig_dir_second/$apk_name/res/$values/plurals.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/plurals.xml" ]; then
max_proces; ($up/merge_plurals $orig_dir/$apk_name/res/$values/plurals.xml $targ_dir/$apk_name/res/values-$lang_iso/plurals.xml $new_dir/$apk_name/res/values-$lang_iso/plurals.xml $apk_name $untranslateable_list false)&
elif [ -f "$orig_dir/$apk_name/res/$values/plurals.xml" ] && [ ! -f "$orig_dir_second/$apk_name/res/$values/plurals.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/plurals.xml" ]; then
max_proces; ($up/merge_plurals $orig_dir/$apk_name/res/$values/plurals.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/plurals.xml $apk_name $untranslateable_list false)&
elif [ ! -f "$orig_dir/$apk_name/res/$values/plurals.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/plurals.xml" ] && [ -f "$targ_dir/$apk_name/res/values-$lang_iso/plurals.xml" ]; then
max_proces; ($up/merge_plurals $orig_dir_second/$apk_name/res/$values/plurals.xml $targ_dir/$apk_name/res/values-$lang_iso/plurals.xml $new_dir/$apk_name/res/values-$lang_iso/plurals.xml $apk_name $untranslateable_list false)&
elif [ ! -f "$orig_dir/$apk_name/res/$values/plurals.xml" ] && [ -f "$orig_dir_second/$apk_name/res/$values/plurals.xml" ] && [ ! -f "$targ_dir/$apk_name/res/values-$lang_iso/plurals.xml" ]; then
max_proces; ($up/merge_plurals $orig_dir_second/$apk_name/res/$values/plurals.xml $up/dummy.xml $new_dir/$apk_name/res/values-$lang_iso/plurals.xml $apk_name $untranslateable_list false)&
fi
fi
done
wait
}
# Single or dual merge
if [ $dual_merge == true ]; then
DualMerge
else
SingleMerge
fi
wait; sleep 60
if [ $post_clean == "enabled" ]; then
source $up/post_clean
fi
$python $up/sort.py $new_dir > /dev/null