forked from magic-merlin/dvbapp2-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade.py
36 lines (30 loc) · 1.12 KB
/
upgrade.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
import os
opkgDestinations = ['/']
opkgStatusPath = ''
def findMountPoint(path):
'Example: findMountPoint("/media/hdd/some/file") returns "/media/hdd"'
path = os.path.abspath(path)
while not os.path.ismount(path):
path = os.path.dirname(path)
return path
def opkgExtraDestinations():
global opkgDestinations
return ''.join([" --add-dest %s:%s" % (i, i) for i in opkgDestinations])
def opkgAddDestination(mountpoint):
global opkgDestinations
if mountpoint not in opkgDestinations:
opkgDestinations.append(mountpoint)
print "[Ipkg] Added to OPKG destinations:", mountpoint
mounts = os.listdir('/media')
for mount in mounts:
mount = os.path.join('/media', mount)
if mount and not mount.startswith('/media/net'):
if opkgStatusPath == '':
# recent opkg versions
opkgStatusPath = 'var/lib/opkg/status'
if not os.path.exists(os.path.join('/', opkgStatusPath)):
# older opkg versions
opkgStatusPath = 'usr/lib/opkg/status'
if os.path.exists(os.path.join(mount, opkgStatusPath)):
opkgAddDestination(mount)
os.system('opkg ' + opkgExtraDestinations() + ' upgrade 2>&1 | tee /home/root/ipkgupgrade.log && reboot')