-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmk_module.sh
More file actions
executable file
·174 lines (151 loc) · 4 KB
/
mk_module.sh
File metadata and controls
executable file
·174 lines (151 loc) · 4 KB
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
#!/bin/bash
## Inject YouTube
## ipdev @ xda-developers
# Set main variables
DATE=$(date '+%Y%m%d')
TDIR=$(pwd)
SDIR="$TDIR"/staging
OUT="$TDIR"/out/"$DATE"
# Set additional variables
## None
# Set main functions
check_dir() {
[[ ! -d $OUT ]] && mkdir -p $OUT;
[[ ! -d $SDIR ]] && mkdir -p $SDIR;
}
# Set additional functions
backup() {
if [ -f "$OUT"/"$ZIPNAME" ]; then
FLTM=$(date -r "$OUT"/"$ZIPNAME" '+%H%M');
BACKUPFILE=$(printf "$ZIPNAME" | sed 's/.zip/-'"$FLTM".zip'/g');
mv "$OUT"/"$ZIPNAME" "$OUT"/"$BACKUPFILE";
if [ $MODID = yt ]; then
BUZYT=""$OUT"/"$BACKUPFILE"";
# elif [ $MODID = d ]; then
# BUZD=""$OUT"/"$BACKUPFILE"";
fi;
fi;
}
change_log() {
echo "## YouTube v"$VNAME"" >update.md;
echo "" >>update.md;
echo "- Module updated to YouTube v"$VNAME"" >>update.md;
echo "- Requires YouTube to be updated to v"$VNAME" also." >>update.md;
}
create_json() {
JSON="$TDIR"/iyt.json
echo "{" >"$JSON";
echo " \"versionCode\": \""$VCODE"\"," >>"$JSON";
echo " \"version\": \"Module\"," >>"$JSON";
echo " \"zipUrl\": \"https://github.com/mModule/iYT/releases/download/v"$VNAME"/"$ZIPNAME"\"," >>"$JSON";
echo " \"changelog\": \"https://github.com/mModule/iYT/releases/download/v"$VNAME"/update.md\"" >>"$JSON";
echo "}" >>"$JSON";
}
edit_service_script() {
if [ "$(uname -s)" = Darwin ]; then
RNAME=$(grep "Required YouTube" service.sh | cut -f6 -d' ');
sed -i "" s/$RNAME/$VNAME/ service.sh;
RCODE=$(grep "RYTVC=" service.sh);
sed -i "" s/$RCODE/RYTVC=$VCODE/ service.sh;
else
RNAME=$(grep "Required YouTube" service.sh | cut -f6 -d' ');
sed -i s/$RNAME/$VNAME/ service.sh;
RCODE=$(grep "RYTVC=" service.sh);
sed -i s/$RCODE/RYTVC=$VCODE/ service.sh;
fi;
}
# get_app_abi() {
# ABI=$(aapt dump badging "$i" | grep native-code | cut -f2 -d "'" | cut -f2 -d "-");
# if [ "$ABI" = "v7a" ]; then
# ARCH=arm
# elif [ "$ABI" = "v8a" ]; then
# ARCH=arm64
# fi
# }
get_app_version() {
VCODE=$(aapt dump badging base.apk| grep version | cut -f4 -d"'");
VNAME=$(aapt dump badging base.apk| grep version | cut -f6 -d"'");
VER=$(aapt dump badging base.apk| grep version | cut -f6 -d"'" | sed 's/\.//g');
}
module_prop() {
echo "id=iyt" >module.prop
echo "name=Inject YouTube" >>module.prop
echo "version=Module" >>module.prop
echo "versionCode="$VCODE"" >>module.prop
echo "author=ip" >>module.prop
echo "description=YouTube v"$VNAME >>module.prop
echo "updateJson=https://raw.githubusercontent.com/mModule/iYT/master/iyt.json" >>module.prop
}
# set_mod_id() {
# if [ $NAME = iYT ]; then
# if [ $i = black.apk ]; then
# MODID=b
# THEME="Black"
# elif [ $i = dark.apk ]; then
# MODID=d
# THEME="Dark"
# fi
# fi;
# }
zip_yt(){
echo ""
echo "iYT ("$ARCH")."
cp -rf META-INF "$SDIR"
cp customize.sh "$SDIR"
cp post-fs-data.sh "$SDIR"
cp service.sh "$SDIR"
cp uninstall.sh "$SDIR"
cp "$i" "$SDIR"/base.apk
cd "$SDIR"
get_app_version
module_prop
edit_service_script
ZIPNAME="$NAME"-v"$VER".zip
IYT=""$OUT"/"$ZIPNAME""
zip -r "$ZIPNAME" META-INF/* base.apk customize.sh module.prop post-fs-data.sh service.sh uninstall.sh # > /dev/null 2>&1
backup
create_json
change_log
mv "$ZIPNAME" "$OUT"
mv update.md "$OUT"
rm -rf *
cd "$TDIR"
}
# Check and create directory(s) if needed.
check_dir
# __ Make zip file(s). __
### Modified APK file names..
### YouTube (currently full apk only)
## YouTube 'yt.apk'
for i in *.apk; do
if [ -f "$i" ]; then
if [ "$(aapt dump badging "$i" | grep version | cut -f2 -d"'")" = "com.google.android.youtube" ]; then
NAME=iYT
# get_app_abi
ARCH=all
# set_mod_id
MODID=yt
zip_yt
fi
fi
done
if [ -z $NAME ]; then
echo ""; echo "Nothing to do.";
fi;
# Note backup file(s).
if [ -n "$BUZYT" ]; then
echo ""; echo "Your previous zip file(s) renamed.";
if [ -n "$BUZYT" ]; then
echo " iYT backup as "$BUZYT"";
fi;
fi;
# Note new file(s).
if [ -n "$IYT" ]; then
echo ""; echo "New zip file(s).";
if [ -n "$IYT" ]; then
echo " iYT saved as "$IYT"";
fi;
fi;
# Finish script.
echo ""; echo "Done."; echo "";
exit 0;