forked from Catch-up-TV-and-More/repository.catchuptvandmore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_all_repos.sh
executable file
·238 lines (171 loc) · 9.93 KB
/
update_all_repos.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
echo -e "- Script directory: $BASEDIR --> Let's move to this directory"
cd $BASEDIR
cwd=$(pwd)
echo -e ""
echo -e "- Current workning directory: $cwd"
# Arg: string that contains the addon.xml content
# Return: version of the addon
function extract_addon_version() {
local addon_xml_content="$1"
local re="<addon([^>]+)>"
if [[ $addon_xml_content =~ $re ]]; then
local addon_line=${BASH_REMATCH[0]}
local re='version="([^"]+)"'
if [[ $addon_line =~ $re ]]; then
local version=${BASH_REMATCH[1]}
echo $version
fi
fi
}
commit_msg="Auto update repo(s): "
need_to_commit_push="false"
# Krypton release repo
echo -e "\n# Check if we need to update the Krypton release official repository"
need_to_update_repo="no"
## plugin.video.catchuptvandmore
krypton_release_cutv_current_version="$(extract_addon_version "$(cat ./zips/krypton_release/plugin.video.catchuptvandmore/addon.xml)")"
echo -e "\t* Version of plugin.video.catchuptvandmore on the repository is: $krypton_release_cutv_current_version"
krypton_release_cutv_last_version="$(extract_addon_version "$(wget https://raw.github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/master/plugin.video.catchuptvandmore/addon.xml -q -O -)")"
echo -e "\t* Version of plugin.video.catchuptvandmore on master branch available is: $krypton_release_cutv_last_version"
if [ "$krypton_release_cutv_current_version" != "$krypton_release_cutv_last_version" ]; then
need_to_update_repo="yes"
fi
## resource.images.catchuptvandmore
krypton_release_images_current_version="$(extract_addon_version "$(cat ./zips/krypton_release/resource.images.catchuptvandmore/addon.xml)")"
echo -e "\t* Version of resource.images.catchuptvandmore on the repository is: $krypton_release_images_current_version"
krypton_release_images_last_version="$(extract_addon_version "$(wget https://raw.github.com/Catch-up-TV-and-More/resource.images.catchuptvandmore/master/resource.images.catchuptvandmore/addon.xml -q -O -)")"
echo -e "\t* Version of resource.images.catchuptvandmore on master branch available is: $krypton_release_images_last_version"
if [ "$krypton_release_images_current_version" != "$krypton_release_images_last_version" ]; then
need_to_update_repo="yes"
fi
if [ "${need_to_update_repo}" == "yes" ]; then
echo -e "\n\t--> Need to update this repository"
# Download cutv&m zip file from GitHub repo
mkdir temp
wget https://github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/archive/master.zip -q -P ./temp
# Unzip cutv&m zip file
unzip -q ./temp/master.zip -d ./temp
# Set reuselanguageinvoker to true
sed -i 's#<reuselanguageinvoker>false</reuselanguageinvoker>#<reuselanguageinvoker>true</reuselanguageinvoker>#g' ./temp/plugin.video.catchuptvandmore-master/plugin.video.catchuptvandmore/addon.xml
# Update commit message
commit_msg="$commit_msg Krypton release,"
# Set need_to_commit_push to true in order to trigger a commit and push at the end of the script
need_to_commit_push="true"
# Update our Kodi repo with create_repository.py
echo -e "\t\t- Start create_repository.py on Krypton release repository"
python3 ./create_repository.py \
--datadir ./zips/krypton_release \
--info ./addons_xmls/krypton_release/addons.xml \
--checksum ./addons_xmls/krypton_release/addons.xml.md5 \
./repo_addons_src/catchuptvandmore.kodi.krypton.release/ \
./temp/plugin.video.catchuptvandmore-master/plugin.video.catchuptvandmore/ \
https://github.com/Catch-up-TV-and-More/resource.images.catchuptvandmore\#master:resource.images.catchuptvandmore
else
echo -e "\n\t--> No need to update this repository"
fi
# Krypton beta repo
echo -e "\n# Check if we need to update the Krypton beta official repository"
need_to_update_repo="no"
## plugin.video.catchuptvandmore
krypton_beta_cutv_current_version="$(extract_addon_version "$(cat ./zips/krypton_beta/plugin.video.catchuptvandmore/addon.xml)")"
echo -e "\t* Version of plugin.video.catchuptvandmore is: $krypton_beta_cutv_current_version"
krypton_beta_cutv_last_version="$(extract_addon_version "$(wget https://raw.github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/dev/plugin.video.catchuptvandmore/addon.xml -q -O -)")"
echo -e "\t* Version of plugin.video.catchuptvandmore on dev branch available is: $krypton_beta_cutv_last_version"
if [ "$krypton_beta_cutv_current_version" != "$krypton_beta_cutv_last_version" ]; then
need_to_update_repo="yes"
fi
## resource.images.catchuptvandmore
krypton_beta_images_current_version="$(extract_addon_version "$(cat ./zips/krypton_beta/resource.images.catchuptvandmore/addon.xml)")"
echo -e "\t* Version of resource.images.catchuptvandmore on the repository is: $krypton_beta_images_current_version"
krypton_beta_images_last_version="$(extract_addon_version "$(wget https://raw.github.com/Catch-up-TV-and-More/resource.images.catchuptvandmore/master/resource.images.catchuptvandmore/addon.xml -q -O -)")"
echo -e "\t* Version of resource.images.catchuptvandmore on master branch available is: $krypton_beta_images_last_version"
if [ "$krypton_beta_images_current_version" != "$krypton_beta_images_last_version" ]; then
need_to_update_repo="yes"
fi
if [ "${need_to_update_repo}" == "yes" ]; then
echo -e "\n\t--> Need to update this repository"
# Download cutv&m zip file from GitHub repo
mkdir temp
wget https://github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/archive/dev.zip -q -P ./temp
# Unzip cutv&m zip file
unzip -q ./temp/dev.zip -d ./temp
# Set reuselanguageinvoker to true
sed -i 's#<reuselanguageinvoker>false</reuselanguageinvoker>#<reuselanguageinvoker>true</reuselanguageinvoker>#g' ./temp/plugin.video.catchuptvandmore-dev/plugin.video.catchuptvandmore/addon.xml
# Update commit message
commit_msg="$commit_msg Krypton beta,"
# Set need_to_commit_push to true in order to trigger a commit and push at the end of the script
need_to_commit_push="true"
# Update our Kodi repo with create_repository.py
echo -e "\t\t- Start create_repository.py on Krypton beta repository"
python3 ./create_repository.py \
--datadir ./zips/krypton_beta \
--info ./addons_xmls/krypton_beta/addons.xml \
--checksum ./addons_xmls/krypton_beta/addons.xml.md5 \
./repo_addons_src/catchuptvandmore.kodi.krypton.beta/ \
./temp/plugin.video.catchuptvandmore-dev/plugin.video.catchuptvandmore/ \
https://github.com/Catch-up-TV-and-More/resource.images.catchuptvandmore\#master:resource.images.catchuptvandmore
else
echo -e "\n\t--> No need to update this repository"
fi
# Matrix beta repo
echo -e "\n# Check if we need to update the Matrix beta official repository"
need_to_update_repo="no"
## plugin.video.catchuptvandmore
matrix_beta_cutv_current_version="$(extract_addon_version "$(cat ./zips/matrix_beta/plugin.video.catchuptvandmore/addon.xml)")"
echo -e "\t* Version of plugin.video.catchuptvandmore is: $matrix_beta_cutv_current_version"
matrix_beta_cutv_last_version="$(extract_addon_version "$(wget https://raw.github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/kodi19/plugin.video.catchuptvandmore/addon.xml -q -O -)")"
echo -e "\t* Version of plugin.video.catchuptvandmore on kodi19 branch available is: $matrix_beta_cutv_last_version"
if [ "$matrix_beta_cutv_current_version" != "$matrix_beta_cutv_last_version" ]; then
need_to_update_repo="yes"
fi
## resource.images.catchuptvandmore
matrix_beta_images_current_version="$(extract_addon_version "$(cat ./zips/matrix_beta/resource.images.catchuptvandmore/addon.xml)")"
echo -e "\t* Version of resource.images.catchuptvandmore on the repository is: $matrix_beta_images_current_version"
matrix_beta_images_last_version="$(extract_addon_version "$(wget https://raw.github.com/Catch-up-TV-and-More/resource.images.catchuptvandmore/master/resource.images.catchuptvandmore/addon.xml -q -O -)")"
echo -e "\t* Version of resource.images.catchuptvandmore on master branch available is: $matrix_beta_images_last_version"
if [ "$matrix_beta_images_current_version" != "$matrix_beta_images_last_version" ]; then
need_to_update_repo="yes"
fi
if [ "${need_to_update_repo}" == "yes" ]; then
echo -e "\n\t--> Need to update this repository"
# Download cutv&m zip file from GitHub repo
mkdir temp
wget https://github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/archive/kodi19.zip -q -P ./temp
# Unzip cutv&m zip file
unzip -q ./temp/kodi19.zip -d ./temp
# Set reuselanguageinvoker to true
sed -i 's#<reuselanguageinvoker>false</reuselanguageinvoker>#<reuselanguageinvoker>true</reuselanguageinvoker>#g' ./temp/plugin.video.catchuptvandmore-kodi19/plugin.video.catchuptvandmore/addon.xml
# Update commit message
commit_msg="$commit_msg Matrix beta,"
# Set need_to_commit_push to true in order to trigger a commit and push at the end of the script
need_to_commit_push="true"
# Update our Kodi repo with create_repository.py
echo -e "\t\t- Start create_repository.py on Matrix beta repository"
python3 ./create_repository.py \
--datadir ./zips/matrix_beta \
--info ./addons_xmls/matrix_beta/addons.xml \
--checksum ./addons_xmls/matrix_beta/addons.xml.md5 \
./repo_addons_src/catchuptvandmore.kodi.matrix.beta/ \
./temp/plugin.video.catchuptvandmore-kodi19/plugin.video.catchuptvandmore/ \
https://github.com/Catch-up-TV-and-More/resource.images.catchuptvandmore\#master:resource.images.catchuptvandmore \
https://github.com/Catch-up-TV-and-More/script.module.youtube.dl\#kodi19 \
https://github.com/Catch-up-TV-and-More/script.module.codequick\#kodi19:script.module.codequick
else
echo -e "\n\t--> No need to update this repository"
fi
# Commit and push if needed
if [ "$need_to_commit_push" == "true" ]; then
# Remove temp folder
rm -rf ./temp
# Add all, commit and push
echo -e "\n# Need to update one or more repos, need to commit/push on the GitHub repo\n"
echo -e "\t* Commit message: $commit_msg"
git add --all
git commit -m "$commit_msg"
git push
echo -e "\t* Changes have been pushed"
else
echo -e "\n# No change detected on any repos, no need to commit/push on the GitHub repo\n"
fi