-
Notifications
You must be signed in to change notification settings - Fork 8
/
update_all_repos.sh
executable file
·179 lines (137 loc) · 6.94 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
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
echo -e "- Script directory: $BASEDIR --> Let's move to this directory"
cd $BASEDIR
cwd=$(pwd)
now=$(date +"%d/%m/%Y %H:%M:%S-%Z")
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"
# Stable repo (master branch)
echo -e "\n# Check if we need to update the CUTV&M stable repository"
need_to_update_repo="no"
## plugin.video.catchuptvandmore
release_cutv_current_version="$(extract_addon_version "$(cat ./zips/release/plugin.video.catchuptvandmore/addon.xml)")"
release_cutv_last_version="$(extract_addon_version "$(wget https://raw.github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/master/addon.xml -q -O -)")"
echo -e "\t* Version of plugin.video.catchuptvandmore --> repository: $release_cutv_current_version, master branch: $release_cutv_last_version"
if [ "$release_cutv_current_version" != "$release_cutv_last_version" ]; then
need_to_update_repo="yes"
fi
## resource.images.catchuptvandmore
release_images_current_version="$(extract_addon_version "$(cat ./zips/release/resource.images.catchuptvandmore/addon.xml)")"
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 --> repository: $release_images_current_version, master branch: $release_images_last_version"
if [ "$release_images_current_version" != "$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/addon.xml
# Update commit message
commit_msg="$commit_msg stable,"
# 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 stable repository"
python3 ./create_repository.py \
--datadir ./zips/release \
--info ./addons_xmls/release/addons.xml \
--checksum ./addons_xmls/release/addons.xml.md5 \
./repo_addons_src/catchuptvandmore.kodi.release/ \
./temp/plugin.video.catchuptvandmore-master/ \
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
# 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 --amend -m "$commit_msg ($now)"
git push --force
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
# Beta repo
echo -e "\n# Check if we need to update the CUTV&M beta repository"
need_to_update_repo="no"
need_to_commit_push="false"
## plugin.video.catchuptvandmore
beta_cutv_current_version="$(extract_addon_version "$(cat ./zips/beta/plugin.video.catchuptvandmore/addon.xml)")"
beta_cutv_last_version="$(extract_addon_version "$(wget https://raw.github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/dev/addon.xml -q -O -)")"
echo -e "\t* Version of plugin.video.catchuptvandmore --> repository: $beta_cutv_current_version, dev branch: $beta_cutv_last_version"
if [ "$beta_cutv_current_version" != "$beta_cutv_last_version" ]; then
need_to_update_repo="yes"
fi
## resource.images.catchuptvandmore
release_images_current_version="$(extract_addon_version "$(cat ./zips/release/resource.images.catchuptvandmore/addon.xml)")"
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 --> repository: $release_images_current_version, master branch: $release_images_last_version"
if [ "$release_images_current_version" != "$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/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/addon.xml
# Update commit message
commit_msg="$commit_msg 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 beta repository"
python3 ./create_repository.py \
--datadir ./zips/beta \
--info ./addons_xmls/beta/addons.xml \
--checksum ./addons_xmls/beta/addons.xml.md5 \
./repo_addons_src/catchuptvandmore.kodi.beta/ \
./temp/plugin.video.catchuptvandmore-dev/ \
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
# 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 --amend -m "$commit_msg ($now)"
git push --force
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