]>
glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/actions/upgrader.py
1 # Copyright 2021 Erfan Abdi
2 # SPDX-License-Identifier: GPL-3.0-or-later
5 from tools
import helpers
10 cfg
= tools
.config
.load(args
)
11 args
.arch
= cfg
["waydroid"]["arch"]
12 args
.images_path
= cfg
["waydroid"]["images_path"]
13 args
.vendor_type
= cfg
["waydroid"]["vendor_type"]
14 args
.system_ota
= cfg
["waydroid"]["system_ota"]
15 args
.vendor_ota
= cfg
["waydroid"]["vendor_ota"]
20 return tuple(map(int, (v
.split("."))))
23 old_ver
= tools
.helpers
.props
.file_get(args
, args
.work
+ "/waydroid_base.prop", "waydroid.tools_version")
24 if versiontuple(old_ver
) <= versiontuple("1.3.4"):
25 chmod_paths
= ["cache_http", "host-permissions", "lxc", "images", "waydroid_base.prop", "waydroid.prop", "waydroid.cfg"]
26 tools
.helpers
.run
.user(args
, ["chmod", "-R", "g-w,o-w"] + [os
.path
.join(args
.work
, f
) for f
in chmod_paths
], check
=False)
27 tools
.helpers
.run
.user(args
, ["chmod", "g-w,o-w", args
.work
], check
=False)
35 if os
.path
.exists(tools
.config
.defaults
["lxc"] + "/waydroid"):
36 status
= helpers
.lxc
.status(args
)
37 if status
!= "STOPPED":
38 logging
.info("Stopping container")
39 helpers
.lxc
.stop(args
)
41 args
.session
= tools
.helpers
.ipc
.DBusContainerService().GetSession()
42 except dbus
.DBusException
:
44 helpers
.images
.umount_rootfs(args
)
45 helpers
.drivers
.loadBinderNodes(args
)
47 if args
.images_path
not in tools
.config
.defaults
["preinstalled_images_paths"]:
48 helpers
.images
.get(args
)
50 logging
.info("Upgrade refused because a pre-installed image is detected at {}.".format(args
.images_path
))
51 helpers
.lxc
.setup_host_perms(args
)
52 helpers
.lxc
.set_lxc_config(args
)
53 helpers
.lxc
.make_base_props(args
)
54 if status
!= "STOPPED" and args
.session
:
55 logging
.info("Starting container")
56 helpers
.images
.mount_rootfs(args
, args
.images_path
, args
.session
)
57 helpers
.protocol
.set_aidl_version(args
)
58 helpers
.lxc
.start(args
)