addonsu: Fix installation on TWRP A/B

* These checks need to be added back otherwise it fails to
  extract files due to 'Too many symbolic links encountered' errors.
* Log:
Installing su addon...
Installing su addon...about to run program [/tmp/mount-system.sh] with 1 args
Extracted file "/system/xbin/su"
Extracted file "/system/addon.d/51-addonsu.sh"
failed to create dir for /system/etc/init/superuser.rc
script aborted: set_metadata: Error on lstat of "/system/etc/init/superuser.rc": Too many symbolic links encountered
set_metadata: Error on lstat of "/system/etc/init/superuser.rc": Too many symbolic links encounterederror: 25
cause: 111
Updater process ended with ERROR: 7

Change-Id: Ibf5082756063f7e703cbc47cf9642677983874ac
diff --git a/addonsu/updater-script-install b/addonsu/updater-script-install
index c807739..6a9d655 100644
--- a/addonsu/updater-script-install
+++ b/addonsu/updater-script-install
@@ -6,11 +6,19 @@
 set_metadata("/tmp/unmount-system.sh", "uid", 0, "gid", 0, "mode", 0755);
 run_program("/tmp/mount-system.sh") == 0 || abort("Could not mount /system");
 
-package_extract_dir("system", "/system");
-set_metadata("/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
-set_metadata("/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
-set_metadata("/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
-symlink("/system/xbin/su", "/system/bin/su");
+if getprop("ro.build.system_root_image") != "true" then
+  package_extract_dir("system", "/system");
+  set_metadata("/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
+  set_metadata("/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
+  set_metadata("/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
+  symlink("/system/xbin/su", "/system/bin/su");
+else
+  package_extract_dir("system", "/system/system");
+  set_metadata("/system/system/addon.d/51-addonsu.sh", "uid", 0, "gid", 0, "mode", 0755, "selabel", "u:object_r:system_file:s0");
+  set_metadata("/system/system/etc/init/superuser.rc", "uid", 0, "gid", 0, "mode", 0644, "selabel", "u:object_r:system_file:s0");
+  set_metadata("/system/system/xbin/su", "uid", 0, "gid", 2000, "mode", 0755, "selabel", "u:object_r:su_exec:s0");
+  symlink("/system/xbin/su", "/system/system/bin/su");
+endif;
 
 run_program("/tmp/unmount-system.sh") == 0 || ui_print("Could not unmount /system");
 ui_print("Done");