Gabriele M | 5b33c6c | 2017-01-22 22:50:02 +0100 | [diff] [blame] | 1 | ui_print("Installing su addon..."); |
| 2 | ifelse(is_mounted("/system"), unmount("/system")); |
| 3 | package_extract_file("mount-system.sh", "/tmp/mount-system.sh"); |
Christopher N. Hesse | 1f94c93 | 2018-06-11 21:56:24 +0200 | [diff] [blame] | 4 | package_extract_file("unmount-system.sh", "/tmp/unmount-system.sh"); |
Gabriele M | 5b33c6c | 2017-01-22 22:50:02 +0100 | [diff] [blame] | 5 | set_metadata("/tmp/mount-system.sh", "uid", 0, "gid", 0, "mode", 0755); |
Christopher N. Hesse | 1f94c93 | 2018-06-11 21:56:24 +0200 | [diff] [blame] | 6 | set_metadata("/tmp/unmount-system.sh", "uid", 0, "gid", 0, "mode", 0755); |
Gabriele M | 5b33c6c | 2017-01-22 22:50:02 +0100 | [diff] [blame] | 7 | run_program("/tmp/mount-system.sh") == 0 || abort("Could not mount /system"); |
| 8 | |
LuK1337 | fd798c5 | 2018-07-05 13:40:09 +0200 | [diff] [blame] | 9 | if getprop("ro.build.system_root_image") != "true" then |
| 10 | package_extract_dir("system", "/system"); |
| 11 | set_metadata("/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0"); |
| 12 | set_metadata("/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0"); |
| 13 | set_metadata("/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0"); |
| 14 | symlink("/system/xbin/su", "/system/bin/su"); |
| 15 | else |
| 16 | package_extract_dir("system", "/system/system"); |
| 17 | set_metadata("/system/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0"); |
| 18 | set_metadata("/system/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0"); |
| 19 | set_metadata("/system/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0"); |
| 20 | symlink("/system/xbin/su", "/system/system/bin/su"); |
| 21 | endif; |
Gabriele M | 5b33c6c | 2017-01-22 22:50:02 +0100 | [diff] [blame] | 22 | |
Christopher N. Hesse | 1f94c93 | 2018-06-11 21:56:24 +0200 | [diff] [blame] | 23 | run_program("/tmp/unmount-system.sh") == 0 || ui_print("Could not unmount /system"); |
Gabriele M | 5b33c6c | 2017-01-22 22:50:02 +0100 | [diff] [blame] | 24 | ui_print("Done"); |
| 25 | set_progress(1.000000); |