|
|
|
@ -62,32 +62,32 @@ def get_image_dir():
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
return cfg["waydroid"]["images_path"]
|
|
|
|
|
|
|
|
|
|
def mount_image(image, mount_point):
|
|
|
|
|
print("==> Unmounting .. ")
|
|
|
|
|
try:
|
|
|
|
|
subprocess.check_output(["losetup", "-D"], stderr=subprocess.STDOUT)
|
|
|
|
|
subprocess.check_output(["umount", mount_point], stderr=subprocess.STDOUT)
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
|
print("==> Warning: umount failed.. {} ".format(str(e.output.decode())))
|
|
|
|
|
if not os.path.exists(mount_point):
|
|
|
|
|
os.makedirs(mount_point)
|
|
|
|
|
try:
|
|
|
|
|
subprocess.check_output(["mount", "-o", "rw", image, mount_point], stderr=subprocess.STDOUT)
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
|
print("==> Failed to mount system image... ! {}".format(str(e.output.decode())))
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
def resize_img(img_file, size):
|
|
|
|
|
# Resize the system image
|
|
|
|
|
print("==> Resizing system image....")
|
|
|
|
|
try:
|
|
|
|
|
subprocess.check_output(["e2fsck -y -f "+img_file], stderr=subprocess.STDOUT, shell=True)
|
|
|
|
|
subprocess.check_output(["resize2fs '{}' {}".format(img_file, size)], stderr=subprocess.STDOUT, shell=True)
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
|
print("==> Failed to resize image '{}' .. ! {}".format(img_file, str(e.output.decode())))
|
|
|
|
|
p = input("==> You can exit and retry with sudo or force continue (May fail installation !), Continue ? [y/N]: ")
|
|
|
|
|
if not p.lower() == "y":
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
#def mount_image(image, mount_point):
|
|
|
|
|
# print("==> Unmounting .. ")
|
|
|
|
|
# try:
|
|
|
|
|
# subprocess.check_output(["losetup", "-D"], stderr=subprocess.STDOUT)
|
|
|
|
|
# subprocess.check_output(["umount", mount_point], stderr=subprocess.STDOUT)
|
|
|
|
|
# except subprocess.CalledProcessError as e:
|
|
|
|
|
# print("==> Warning: umount failed.. {} ".format(str(e.output.decode())))
|
|
|
|
|
# if not os.path.exists(mount_point):
|
|
|
|
|
# os.makedirs(mount_point)
|
|
|
|
|
# try:
|
|
|
|
|
# subprocess.check_output(["mount", "-o", "rw", image, mount_point], stderr=subprocess.STDOUT)
|
|
|
|
|
# except subprocess.CalledProcessError as e:
|
|
|
|
|
# print("==> Failed to mount system image... ! {}".format(str(e.output.decode())))
|
|
|
|
|
# sys.exit(1)
|
|
|
|
|
|
|
|
|
|
#def resize_img(img_file, size):
|
|
|
|
|
# # Resize the system image
|
|
|
|
|
# print("==> Resizing system image....")
|
|
|
|
|
# try:
|
|
|
|
|
# subprocess.check_output(["e2fsck -y -f "+img_file], stderr=subprocess.STDOUT, shell=True)
|
|
|
|
|
# subprocess.check_output(["resize2fs '{}' {}".format(img_file, size)], stderr=subprocess.STDOUT, shell=True)
|
|
|
|
|
# except subprocess.CalledProcessError as e:
|
|
|
|
|
# print("==> Failed to resize image '{}' .. ! {}".format(img_file, str(e.output.decode())))
|
|
|
|
|
# p = input("==> You can exit and retry with sudo or force continue (May fail installation !), Continue ? [y/N]: ")
|
|
|
|
|
# if not p.lower() == "y":
|
|
|
|
|
# sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def install_gapps():
|
|
|
|
@ -307,7 +307,8 @@ on property:ro.enable.native.bridge.exec=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def install_houdini():
|
|
|
|
|
sys_image_mount = "/tmp/waydroidimage"
|
|
|
|
|
sys_image_mount = "/var/lib/waydroid/overlay"
|
|
|
|
|
prop_file = "/var/lib/waydroid/waydroid_base.prop"
|
|
|
|
|
houdini_zip_url = "https://www.dropbox.com/s/v7g0fluc7e8tod8/libhoudini.zip?dl=1"
|
|
|
|
|
dl_file_name = os.path.join(download_loc, "libhoudini.zip")
|
|
|
|
|
extract_to = "/tmp/houdiniunpack" #All catalog files will be marked as executable!
|
|
|
|
@ -339,21 +340,6 @@ on property:ro.enable.native.bridge.exec=1
|
|
|
|
|
bytes = f.read()
|
|
|
|
|
loc_md5 = hashlib.md5(bytes).hexdigest()
|
|
|
|
|
|
|
|
|
|
system_img = os.path.join(get_image_dir(), "system.img")
|
|
|
|
|
if not os.path.isfile(system_img):
|
|
|
|
|
print("The system image path '{}' from waydroid config is not valid !".format(system_img))
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
print("==> Found system image: "+system_img)
|
|
|
|
|
|
|
|
|
|
img_size = int(os.path.getsize(system_img)/(1024*1024))
|
|
|
|
|
|
|
|
|
|
# Resize image to get some free space
|
|
|
|
|
resize_img(system_img, "{}M".format(img_size+300))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Mount the system image
|
|
|
|
|
mount_image(system_img, sys_image_mount)
|
|
|
|
|
|
|
|
|
|
# Download the file if hash mismatches or if file does not exist
|
|
|
|
|
while not os.path.isfile(dl_file_name) or loc_md5 != act_md5:
|
|
|
|
|
if os.path.isfile(dl_file_name):
|
|
|
|
@ -376,8 +362,8 @@ on property:ro.enable.native.bridge.exec=1
|
|
|
|
|
shutil.copytree(os.path.join(extract_to, "system"), os.path.join(sys_image_mount, "system"), dirs_exist_ok=True)
|
|
|
|
|
|
|
|
|
|
# Add entries to build.prop
|
|
|
|
|
print("==> Adding arch in build.prop")
|
|
|
|
|
with open(os.path.join(sys_image_mount, "system", "build.prop"), "r") as propfile:
|
|
|
|
|
print("==> Adding arch in", prop_file)
|
|
|
|
|
with open(os.path.join(prop_file), "r") as propfile:
|
|
|
|
|
prop_content = propfile.read()
|
|
|
|
|
for key in apply_props:
|
|
|
|
|
if key not in prop_content:
|
|
|
|
@ -385,16 +371,16 @@ on property:ro.enable.native.bridge.exec=1
|
|
|
|
|
else:
|
|
|
|
|
p = re.compile(r"^{key}=.*$".format(key=key), re.M)
|
|
|
|
|
prop_content = re.sub(p, "{key}={value}".format(key=key, value=apply_props[key]), prop_content)
|
|
|
|
|
with open(os.path.join(sys_image_mount, "system", "build.prop"), "w") as propfile:
|
|
|
|
|
with open(os.path.join(prop_file), "w") as propfile:
|
|
|
|
|
propfile.write(prop_content)
|
|
|
|
|
|
|
|
|
|
# Add entry to init.rc
|
|
|
|
|
print("==> Adding entry to init.rc")
|
|
|
|
|
# Check if init.rc is located in Android 11's path
|
|
|
|
|
init_path = os.path.join(sys_image_mount, "system", "etc", "init", "hw", "init.rc")
|
|
|
|
|
init_path = os.path.join(sys_image_mount, "system", "etc", "init", "houdini.rc")
|
|
|
|
|
if not os.path.isfile(init_path):
|
|
|
|
|
# init.rc not found, assuming it's located in the root folder (Android 10 and older)
|
|
|
|
|
init_path = os.path.join(sys_image_mount, "init.rc")
|
|
|
|
|
os.makedirs(os.path.dirname(init_path), exist_ok=True)
|
|
|
|
|
f = open(init_path, "x")
|
|
|
|
|
with open(init_path, "r") as initfile:
|
|
|
|
|
initcontent = initfile.read()
|
|
|
|
|
if init_rc_component not in initcontent:
|
|
|
|
@ -402,12 +388,6 @@ on property:ro.enable.native.bridge.exec=1
|
|
|
|
|
with open(init_path, "w") as initfile:
|
|
|
|
|
initfile.write(initcontent)
|
|
|
|
|
|
|
|
|
|
# Unmount and exit
|
|
|
|
|
print("==> Unmounting .. ")
|
|
|
|
|
try:
|
|
|
|
|
subprocess.check_output(["umount", sys_image_mount], stderr=subprocess.STDOUT)
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
|
print("==> Warning: umount failed.. {} ".format(str(e.output.decode())))
|
|
|
|
|
|
|
|
|
|
print("==> libhoudini translation installed ! Restart waydroid service to apply changes !")
|
|
|
|
|
|
|
|
|
|