X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/2ffd66ba5682212fd0c92bb570b538caf894e0b3..094a4d970ccefa2e6409c8147c1edbdaaa74df0f:/tools/helpers/images.py diff --git a/tools/helpers/images.py b/tools/helpers/images.py index 8a5a38b..cf65a11 100644 --- a/tools/helpers/images.py +++ b/tools/helpers/images.py @@ -7,7 +7,7 @@ import hashlib import os import tools.config from tools import helpers - +from shutil import which def sha256sum(filename): h = hashlib.sha256() @@ -36,6 +36,10 @@ def get(args): args, system_response['url'], system_response['filename'], cache=False) logging.info("Validating system image") if sha256sum(images_zip) != system_response['id']: + try: + os.remove(images_zip) + except: + pass raise ValueError("Downloaded system image hash doesn't match, expected: {}".format( system_response['id'])) logging.info("Extracting to " + args.images_path) @@ -61,6 +65,10 @@ def get(args): args, vendor_response['url'], vendor_response['filename'], cache=False) logging.info("Validating vendor image") if sha256sum(images_zip) != vendor_response['id']: + try: + os.remove(images_zip) + except: + pass raise ValueError("Downloaded vendor image hash doesn't match, expected: {}".format( vendor_response['id'])) logging.info("Extracting to " + args.images_path) @@ -85,8 +93,39 @@ def replace(args, system_zip, system_time, vendor_zip, vendor_time): cfg["waydroid"]["vendor_datetime"] = str(vendor_time) tools.config.save(args, cfg) +def make_prop(args, cfg, full_props_path): + if not os.path.isfile(args.work + "/waydroid_base.prop"): + raise RuntimeError("waydroid_base.prop Not found") + with open(args.work + "/waydroid_base.prop") as f: + props = f.read().splitlines() + if not props: + raise RuntimeError("waydroid_base.prop is broken!!?") + + def add_prop(key, cfg_key): + value = cfg[cfg_key] + if value != "None": + value = value.replace("/mnt/", "/mnt_extra/") + props.append(key + "=" + value) + + add_prop("waydroid.host.user", "user_name") + add_prop("waydroid.host.uid", "user_id") + add_prop("waydroid.host.gid", "group_id") + add_prop("waydroid.xdg_runtime_dir", "xdg_runtime_dir") + add_prop("waydroid.pulse_runtime_path", "pulse_runtime_path") + add_prop("waydroid.wayland_display", "wayland_display") + if which("waydroid-sensord") is None: + props.append("waydroid.stub_sensors_hal=1") + dpi = cfg["lcd_density"] + if dpi != "0": + props.append("ro.sf.lcd_density=" + dpi) -def mount_rootfs(args, images_dir): + final_props = open(full_props_path, "w") + for prop in props: + final_props.write(prop + "\n") + final_props.close() + os.chmod(full_props_path, 0o644) + +def mount_rootfs(args, images_dir, session): helpers.mount.mount(args, images_dir + "/system.img", tools.config.defaults["rootfs"], umount=True) helpers.mount.mount(args, images_dir + "/vendor.img", @@ -102,6 +141,8 @@ def mount_rootfs(args, images_dir): if os.path.isdir("/vendor/odm"): helpers.mount.bind( args, "/vendor/odm", tools.config.defaults["rootfs"] + "/odm_extra") + + make_prop(args, session, args.work + "/waydroid.prop") helpers.mount.bind_file(args, args.work + "/waydroid.prop", tools.config.defaults["rootfs"] + "/vendor/waydroid.prop")