-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcheck-upstream.py
executable file
·178 lines (162 loc) · 6.15 KB
/
check-upstream.py
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
#!/usr/bin/python3
# VDR4Arch upstream check script
# Copyright (C) 2023 Manuel Reimer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import requests
import re
# Packages to check
PACKAGES = [
["irctl", "github"],
["minisatip", "github"],
["t2scan", "github"],
["vdradmin-am", "github"],
["vdr-epg-daemon", "github"],
["w_scan_cpp", "github"],
["w_scan2", "github"],
["deps/cxxtools", "github"],
["deps/graphlcd-base", "github"],
["deps/libnetceiver", "github"],
["deps/librepfunc", "github"],
["deps/tntdb", "github"],
["deps/tntnet", "github"],
["plugins/vdr-bgprocess", "github"],
["plugins/vdr-burn", "github"],
["plugins/vdr-chanman", "github"],
["plugins/vdr-channellists", "github"],
["plugins/vdr-channelscan", "github"],
["plugins/vdr-cinebars", "github"],
["plugins/vdr-dbus2vdr", "github"],
["plugins/vdr-ddci2", "github"],
["plugins/vdr-devstatus", "gitlab"],
["plugins/vdr-dfatmo", "github"],
["plugins/vdr-duplicates", "github"],
["plugins/vdr-dvbapi", "github"],
["plugins/vdr-eepg", "github"],
["plugins/vdr-epg2vdr", "github"],
["plugins/vdr-epgborder", "github"],
# ["plugins/vdr-epgfixer", "github"],
["plugins/vdr-epgsearch", "github"],
["plugins/vdr-epgsync", "github"],
["plugins/vdr-extrecmenung", "gitlab"],
["plugins/vdr-favorites", "github"],
["plugins/vdr-femon", "github"],
["plugins/vdr-filebrowser", "github"],
["plugins/vdr-fritzbox", "github"],
["plugins/vdr-gamepad", "github"],
["plugins/vdr-graphlcd", "github"],
["plugins/vdr-imonlcd", "github"],
["plugins/vdr-iptv", "github"],
["plugins/vdr-lcdproc", "github"],
["plugins/vdr-live", "github"],
["plugins/vdr-markad", "github"],
["plugins/vdr-mcli", "github"],
["plugins/vdr-mp3", "github"],
["plugins/vdr-mpv", "github"],
["plugins/vdr-osd2web", "github"],
["plugins/vdr-osdteletext", "github"],
["plugins/vdr-plex", "github"],
["plugins/vdr-radio", "github"],
["plugins/vdr-recsearch", "github"],
["plugins/vdr-remoteosd", "github"],
["plugins/vdr-restfulapi", "github"],
["plugins/vdr-rpihddevice", "github"],
["plugins/vdr-rssreader", "github"],
["plugins/vdr-scraper2vdr", "github"],
["plugins/vdr-skindesigner", "gitlab"],
["plugins/vdr-skinenigmang", "github"],
["plugins/vdr-skinflat", "github"],
["plugins/vdr-skinflatplus", "github"],
["plugins/vdr-skinpearlhd", "github"],
["plugins/vdr-skinsoppalusikka", "github"],
["plugins/vdr-sleeptimer", "github"],
["plugins/vdr-softhdcuvid", "github"],
["plugins/vdr-softhddevice", "github"],
["plugins/vdr-streamdev", "github"],
["plugins/vdr-svdrposd", "github"],
["plugins/vdr-svdrpservice", "github"],
["plugins/vdr-systeminfo", "github"],
["plugins/vdr-targavfd", "github"],
["plugins/vdr-tvguide", "gitlab"],
["plugins/vdr-tvguideng", "gitlab"],
["plugins/vdr-tvscraper", "github"],
["plugins/vdr-vdrmanager", "github"],
["plugins/vdr-vdrtva", "github"],
["plugins/vdr-vnsiserver", "github"],
["plugins/vdr-weatherforecast", "github"],
["plugins/vdr-wirbelscan", "github"],
["plugins/vdr-xmltv2vdr", "github"],
["plugins/vdr-zaphistory", "github"],
["plugins/vdr-zappilot", "github"]
]
# Simple .SRCINFO parser
def parse_srcinfo(path):
result = {"source": []}
file = open(path, "r")
for line in file:
parts = line.strip().split(" = ")
if len(parts) != 2:
break
name, value = parts
if name in ["pkgbase", "pkgver"]:
result[name] = value
if name == "source":
result["source"].append(value)
return result
# Get latest version of a GitHub project without using their API
def get_github_version(source):
projecturl = "/".join(source.split("/", 5)[:-1])
tagsurl = f"{projecturl}/tags"
text = requests.get(tagsurl).text
versions = re.findall(r'<a href=".+?/tag/([^"]+)', text)
latest = versions[0].replace("v", "").replace("V", "")
return latest
# Get latest version of a GitLab project without using their API
def get_gitlab_version(source):
projecturl = "/".join(source.split("/", 5)[:-1])
tagsurl = f"{projecturl}/-/tags?format=atom"
text = requests.get(tagsurl).text
versions = re.findall(r'<title>([^<]+)', text)
latest = versions[1].replace("v", "").replace("V", "")
return latest
# Get latest version of a BitBucket project without using their API
def get_bitbucket_version(source):
projecturl = "/".join(source.split("/", 5)[:-1])
tagsurl = f"{projecturl}/downloads/?tab=tags"
text = requests.get(tagsurl).text
versions = re.findall(r'<td class="name">([^<]+)', text)
latest = versions[0].replace("v", "").replace("V", "")
return latest
def main():
for package in PACKAGES:
path, host = package
srcinfo = parse_srcinfo(f"{path}/.SRCINFO")
source = srcinfo["source"][0]
if "::" in source:
source = source.split("::")[1]
if host == "github":
version = get_github_version(source)
elif host == "gitlab":
version = get_gitlab_version(source)
elif host == "bitbucket":
version = get_bitbucket_version(source)
# TODO: Add more hosting platforms
else:
raise Exception()
status = "OK"
if version != srcinfo["pkgver"]:
status = f"Local: {srcinfo['pkgver']} Upstream: {version}"
print(srcinfo["pkgbase"], status)
if __name__ == "__main__":
main()