ifelse(is_mounted("/system_root"),unmount("/system_root"));
ifelse(is_mounted("/vendor"),unmount("/vendor"));

ui_print("Mounting partitions");
mount("ext4","EMMC","/dev/block/by-name/APP","/system_root");
mount("ext4","EMMC","/dev/block/by-name/vendor","/vendor");

ui_print("Extracting into system directory");
package_extract_dir("system", "/system_root/system");

ui_print("Extracting into vendor directory");
package_extract_dir("vendor", "/vendor");

ui_print("Setting permissions to addon.d script");
set_perm(0, 0, 0755, "/system_root/system/addon.d/99-joycond-xbox-layout.sh");

unmount("/vendor");
unmount("/system_root");
