-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathopkg-ext.py
355 lines (242 loc) · 9.73 KB
/
opkg-ext.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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#!/usr/bin/env python
##############################################################################################
#### - python script is intended for easier search of installation packages, on feed servers from specific Enigma2 distributions
#### - therefore, it is also necessary to occasionally update the source URLs in this script, i.e. according to the currently released firmware version - for a specific Enigma2
#### - this python script is compatible with both PY2 and PY3
#### - written by s3n0, 2019-2025
##############################################################################################
from __future__ import print_function
import os
import sys
if sys.version_info.major == 3: # data of this object type, as example: sys.version_info(major=3, minor=10, micro=1, releaselevel='final', serial=0)
import urllib.request as urllib2
else:
import urllib2
import ssl # I use the SSL module for unverified connections with the urllib2 module, due to problems with SSL certificates
ssl._create_default_https_context = ssl._create_unverified_context # this will ensure downloading from the Internet without SSL-key verification as default, for all open HTTPS websites
################################# FEEDS variable format: #####################################
####
#### ----atv # Enigma2 distribution shortcut for your database (4 x minus/dash character + the Enigma2 distribution shortcut)
####
####
#### http.......Packages.gz # if the line starts with "http" and ends with "Packages.gz" - it means to download + browse the only one package-list (directly)
####
####
#### # blank lines are also allowed ! they will ignored :-)
####
####
#### http.........../ # if the line starts with "http" and ends with the "/" (slash character), then the following additional sub-directories (sub-feeds) are assumed...
#### # ...and the following assumed sub-feeds (sub-folders) will be added after the previous URL (source feed URL)
#### # ...and also then the string "/Packages.gz" will be added at the end of the whole URL (whole line)
#### armv7ahf-neon # example 1 - of assumed sub-directory (sub-feed)
#### mips32el # example 2 - of assumed sub-directory (sub-feed)
#### vusolo # example 3 - of assumed sub-directory (sub-feed)
####
####
####
#### ----END # end of your database (4 x minus/dash character + the string END)
####
##############################################################################################
FEEDS = """
----pli
http://taapat.ho.ua/openpli/openpli-5/sh4/Packages.gz
http://downloads.openpli.org/feeds/openpli-8-release/
all
mips32el
3rd-party-mips32el
vusolose
3rd-party-vusolose
et8000
3rd-party-et8000
et6x00
3rd-party-et6x00
armv7ahf-neon
3rd-party-armv7ahf-neon
armv7vehf-neon-vfpv4
cortexa7hf-vfp
cortexa15hf-neon-vfpv4
3rd-party-cortexa15hf-neon-vfpv4
aarch64
3rd-party-aarch64
http://downloads.openpli.org/feeds/openpli-9-release/
all
mips32el
3rd-party-mips32el
vusolose
3rd-party-vusolose
et8000
3rd-party-et8000
et6x00
3rd-party-et6x00
armv7ahf-neon
3rd-party-armv7ahf-neon
armv7vehf-neon-vfpv4
cortexa7hf-vfp
cortexa15hf-neon-vfpv4
3rd-party-cortexa15hf-neon-vfpv4
aarch64
3rd-party-aarch64
----atv
http://feeds2.mynonpublic.com/7.5.1/
formuler4turbo/mips32el
formuler4turbo/all
formuler4turbo/3rdparty
formuler4turbo/formuler4turbo_3rdparty
formuler4turbo/formuler4turbo
vuzero4k/cortexa15hf-neon-vfpv4
vuzero4k/all
vuzero4k/3rdparty
vuzero4k/vuzero4k_3rdparty
vuzero4k/vuzero4k
http://feeds2.mynonpublic.com/7.4/
formuler4turbo/mips32el
formuler4turbo/all
formuler4turbo/3rdparty
formuler4turbo/formuler4turbo_3rdparty
formuler4turbo/formuler4turbo
vuzero4k/cortexa15hf-neon-vfpv4
vuzero4k/all
vuzero4k/3rdparty
vuzero4k/vuzero4k_3rdparty
vuzero4k/vuzero4k
http://feeds2.mynonpublic.com/6.4/
spark/sh4
spark/spark
spark/spark_3rdparty
http://updates.mynonpublic.com/oea/4.4/
mips32el
cortexa15hf-neon-vfpv4
sh4
http://updates.mynonpublic.com/oea/4.3/aarch64/Packages.gz
----pure2
http://pur-e2.club/OU/
6.2/3rdparty
6.3/extra-aarch64
6.5/3rdparty
6.5/vusolo/vusolo
6.5/vusolo/all
6.5/vusolo/mips32el
6.5/vuzero4k/vuzero4k
6.5/vuzero4k/all
6.5/vuzero4k/cortexa15hf-neon-vfpv4
6.5/amikoalien/amikoalien
6.5/amikoalien/all
6.5/amikoalien/sh4
http://pur-e2.club/cam/6.2/aarch64/Packages.gz
----nn2
https://feed.newnigma2.to/weekly/oe2.0/ipk/
mips32el
mips32el-nf
----openeight-arm
http://feed.openeight.de/6.8/
sf8008/all
sf8008/cortexa15hf-neon-vfpv4
sf8008/sf8008
sf8008/3rdparty
sf8008/sf8008_3rdparty
http://openeight.dyndns.tv/armv7/Packages.gz
----entware
http://bin.entware.net/
armv7sf-k2.6
armv7sf-k3.2
mipselsf-k3.4
----satdreamgr
http://188.165.252.42/feeds/satdreamgr-10/
mips32el
armv7ahf-neon
all
vusolo2
sf4008
sf8008
vuzero4k
http://188.165.252.42/feeds/
satdreamgr-extra
satdreamgr-extra-aarch64
satdreamgr-extra-vuzero4k
satdreamgr-extra-osmio4k
http://188.165.252.42/feeds/3rd-party/Packages.gz
----END
"""
FEEDS = FEEDS.splitlines()
FEEDS = [s.strip() for s in FEEDS if s.strip() != '']
###############################################################################################
def downloadFile(url, targetfile):
header = { 'User-Agent' : 'Mozilla/5.0 (X11; Linux i686; rv:110.0) Gecko/20100101 Firefox/110.0' } # pre stiahnutie obrazkovych suborov z internetu musim zmenit UserAgent-a v requestovacej hlavicke, nakolko niektore webstranky nedovoluju stahovat obrazky urllib2 klientovi, ktory sa pouziva v module Python jazyka
try:
req = urllib2.Request(url, None, header)
content = urllib2.urlopen(req).read()
with open(targetfile, 'wb') as f:
f.write(content)
print('%s - DOWNLOADED' % (url,))
except urllib2.HTTPError as e:
print("HTTP Error: ", e, url)
return False
except urllib2.URLError as e:
print("URL Error: ", e, url)
return False
except IOError as e:
print("I/O Error: ", e, targetfile)
return False
except Exception as e:
print("Another error: ", e, targetfile, url)
return False
return True
def findPackages(distr, ipkname):
global FEEDS
print('-' * 20 + ' FEED LISTs DOWNLOADing: ' + '-' * 20)
URL_LIST = []
i = FEEDS.index('----%s' % distr) + 1
while not FEEDS[i].startswith('----'):
if FEEDS[i].startswith('http'):
if FEEDS[i].endswith('Packages.gz'):
URL_LIST.append(FEEDS[i])
i += 1
elif FEEDS[i].endswith('/'):
url_template = FEEDS[i] + '%s/Packages.gz'
i += 1
while not FEEDS[i].startswith('----') and not FEEDS[i].startswith('http'):
URL_LIST.append(url_template % FEEDS[i])
i += 1
db = []
for feed_url in URL_LIST:
if downloadFile(feed_url, '/tmp/Packages.gz'): # from downloaded package will be extracted a text file named as "Package"
os.system('cd /tmp && gunzip -f /tmp/Packages.gz') # the one exactly file will be gunzipped, with the same name as the package name (without extension)
with open('/tmp/Packages', 'r') as f:
tmp = f.readlines()
db.append('@@@' + feed_url + '\n')
db += tmp
os.remove('/tmp/Packages')
#with open('/tmp/' + sys.argv[0].split(".")[0] + '.tmp', 'w') as f:
# f.writelines(db)
index_list = [i for i, val in enumerate(db) if val.startswith('Filename:') and (ipkname in val)]
if index_list:
print('-' * 23 + ' PACKAGES FOUND: ' + '-' * 23)
for idx in index_list:
url_dir = next(db[i] for i in reversed(range(idx)) if db[i].startswith('@@@')) # '@@@http://feeds2.mynonpublic.com/6.2/vusolose/mips32el/Packages.gz'
url_dir = '/'.join(url_dir.split('/')[:-1]) # '@@@http://feeds2.mynonpublic.com/6.2/vusolose/mips32el'
url_dir = url_dir[3:] + '/' + db[idx].split(':')[1].strip() # 'http://feeds2.mynonpublic.com/6.2/vusolose/mips32el/7zip-full_16.02-r0_mips32el.ipk'
print('index = %s, url = %s' % (idx, url_dir))
else:
print('The package "%s" was not found.' % ipkname)
def availableDistros():
global FEEDS
lst = []
for line in FEEDS:
if line.startswith('----') and not line.endswith('END'):
lst.append(line[4:].strip())
return lst
###############################################################################################
if __name__ == '__main__':
if len(sys.argv) == 3: # 1 + 2 arguments are neccessary ! the sum of: [0] script file name (default built-in argument) [1] Enigma feed atv/pli [2] package name to find
scriptname, distro, ipkmatchname = sys.argv
if distro in availableDistros():
findPackages(distro, ipkmatchname)
else:
print('USAGE: python %s <%s> <package-name> \n' % ( sys.argv[0] , '|'.join(availableDistros()) ) +
'Examples: python %s pli youtube \n' % sys.argv[0] +
' python %s pure2 oscam \n' % sys.argv[0] +
' python %s atv 7zip' % sys.argv[0]
)
# Note:
# - list of all feed URLs, currently for the installed local Enigma2 distribution or in the current set-top box: /etc/opkg/*.conf
# - list of all available .ipk packages, already in the form of a database downloaded to the local disk, for the currently installed Enigma2 distribution: /var/lib/opkg/lists