]> glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/actions/upgrader.py
app_manager: Allow install/remove/list while frozen
[waydroid.git] / tools / actions / upgrader.py
1 # Copyright 2021 Erfan Abdi
2 # SPDX-License-Identifier: GPL-3.0-or-later
3 import logging
4 import os
5 from tools import helpers
6 import tools.config
7 import dbus
8
9 def get_config(args):
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"]
16 args.session = None
17
18 def upgrade(args):
19 get_config(args)
20 status = "STOPPED"
21 if os.path.exists(tools.config.defaults["lxc"] + "/waydroid"):
22 status = helpers.lxc.status(args)
23 if status != "STOPPED":
24 logging.info("Stopping container")
25 helpers.lxc.stop(args)
26 try:
27 args.session = tools.helpers.ipc.DBusContainerService().GetSession()
28 except dbus.DBusException:
29 pass
30 helpers.images.umount_rootfs(args)
31 helpers.drivers.loadBinderNodes(args)
32 if not args.offline:
33 if args.images_path not in tools.config.defaults["preinstalled_images_paths"]:
34 helpers.images.get(args)
35 else:
36 logging.info("Upgrade refused because a pre-installed image is detected at {}.".format(args.images_path))
37 helpers.lxc.setup_host_perms(args)
38 helpers.lxc.set_lxc_config(args)
39 helpers.lxc.make_base_props(args)
40 if status != "STOPPED" and args.session:
41 logging.info("Starting container")
42 helpers.images.mount_rootfs(args, args.images_path, args.session)
43 helpers.protocol.set_aidl_version(args)
44 helpers.lxc.start(args)