ui_print("VibeOS 0.1.4.3 for the Galaxy S10e: kernel, firmware, device settings.");
assert(getprop("ro.product.device") == "beyond0lte" || getprop("ro.build.product") == "beyond0lte" ||
       abort("This package is for the Galaxy S10e (beyond0lte); this device is " + getprop("ro.product.device") + "."););
show_progress(1.000000, 0);
package_extract_file("vibeos-lib.sh", "/tmp/vibeos-lib.sh");
package_extract_file("install.sh", "/tmp/vibeos-dinstall.sh");
package_extract_file("device-sums.txt", "/tmp/vibeos-dsums.txt");

if run_program("/system/bin/sh", "/tmp/vibeos-dinstall.sh", "find") != 0 then
    abort("ERROR: " + file_getprop("/tmp/vibeos.prop", "error"));
endif;
if file_getprop("/tmp/vibeos.prop", "ready") != "" then
    ui_print(file_getprop("/tmp/vibeos.prop", "ready"));
else
set_progress(0.050000);
ui_print("- unpacking the device files");
package_extract_file("payload.tar", "/tmp/vibeos-payload.tar") ||
    abort("ERROR: could not unpack payload.tar");
package_extract_dir("debs", "/tmp/vibeos-debs") ||
    abort("ERROR: could not unpack the device packages");
set_progress(0.400000);
ui_print("- putting them into the system");
if run_program("/system/bin/sh", "/tmp/vibeos-dinstall.sh", "install") != 0 then
    abort("ERROR: " + file_getprop("/tmp/vibeos.prop", "error"));
endif;
set_progress(0.800000);
package_extract_file("uboot.img", "/tmp/vibeos-uboot.img") || abort("ERROR: could not unpack U-Boot");
package_extract_file("s10e-logo", "/tmp/vibeos-logo");
package_extract_dir("boot-logo", "/tmp/vibeos-boot-logo");
ui_print("- boot");
if run_program("/system/bin/sh", "/tmp/vibeos-dinstall.sh", "boot") != 0 then
    abort("ERROR: " + file_getprop("/tmp/vibeos.prop", "error"));
endif;
set_progress(1.000000);
ui_print("Done. Login: user, password 147147.");
ui_print("First boot: the device packages install, then one restart.");
ui_print("Power on starts Android (or Linux, with no Android).");
ui_print("Restart to recovery starts Linux. Restarting into it.");
run_program("/system/bin/setprop", "sys.powerctl", "reboot,recovery");
endif;
