]> glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/actions/upgrader.py
tools: Drop need of sudo as much as possible
[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
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
17 def upgrade(args):
18 get_config(args)
19 status = "STOPPED"
20 if os.path.exists(tools.config.defaults["lxc"] + "/waydroid"):
21 status = helpers.lxc.status(args)
22 if status != "STOPPED":
23 logging.info("Stopping container")
24 helpers.lxc.stop(args)
25 helpers.images.umount_rootfs(args)
26 helpers.drivers.loadBinderNodes(args)
27 if not args.offline:
28 if args.images_path != tools.config.defaults["preinstalled_images_path"]:
29 helpers.images.get(args)
30 helpers.lxc.setup_host_perms(args)
31 helpers.lxc.set_lxc_config(args)
32 helpers.lxc.make_base_props(args)
33 if status != "STOPPED":
34 logging.info("Starting container")
35 helpers.images.mount_rootfs(args, args.images_path)
36 helpers.lxc.start(args)