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"); |
| 4 | set_metadata("/tmp/mount-system.sh", "uid", 0, "gid", 0, "mode", 0755); |
| 5 | run_program("/tmp/mount-system.sh") == 0 || abort("Could not mount /system"); |
| 6 | |
| 7 | if getprop("ro.build.system_root_image") != "true" then |
| 8 | package_extract_dir("system", "/system"); |
| 9 | set_metadata("/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0"); |
| 10 | set_metadata("/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0"); |
| 11 | set_metadata("/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0"); |
| 12 | symlink("/system/xbin/su", "/system/bin/su"); |
| 13 | else |
| 14 | package_extract_dir("system", "/system/system"); |
| 15 | set_metadata("/system/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0"); |
| 16 | set_metadata("/system/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0"); |
| 17 | set_metadata("/system/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0"); |
| 18 | symlink("/system/xbin/su", "/system/system/bin/su"); |
| 19 | endif; |
| 20 | |
| 21 | unmount("/system"); |
| 22 | ui_print("Done"); |
| 23 | set_progress(1.000000); |