[Galaxy Tab 2 7" Android Development] Tsjoklat:
This patch fixes gapps so you dont have to re-apply gapps again after every rom upgrade with selinux enabled.

Changelog:

1) Fix file permission in updater-script for /system/etc/permissions (change xml to 644 instead of 755) because it should be non-executable

2) Fix file permission in updater-script for /system/etc/preferred-apps (change xml to 644 instead of 755) because it should be non-executable

3) Fix file permission in updater-script for /system/etc/g.priop (change to 644 instead of 755) because it should be non-executable

4) Add pre and post restore commands to reset selinux labels and directory/file permissions upon rom upgrade

diff -ru gapps-kk-20140105-2-signed/META-INF/com/google/android/updater-script gapps-kk-20140105-3-signed/META-INF/com/google/android/updater-script
--- gapps-kk-20140105-2-signed/META-INF/com/google/android/updater-script	2014-01-24 01:21:10.000000000 +0100
+++ gapps-kk-20140105-3-signed/META-INF/com/google/android/updater-script	2014-01-31 02:51:11.337992570 +0100
@@ -17,9 +17,9 @@
set_metadata_recursive("/system/addon.d", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/priv-app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
-set_metadata_recursive("/system/etc/permissions", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
-set_metadata_recursive("/system/etc/preferred-apps", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
-set_metadata("/system/etc/g.prop", "uid", 0, "gid", 0, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata_recursive("/system/etc/permissions", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata_recursive("/system/etc/preferred-apps", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/etc/g.prop", "uid", 0, "gid", 0, "mode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/framework", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/lib", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/usr/srec/en-US", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
diff -ru gapps-kk-20140105-2-signed/system/addon.d/70-gapps.sh gapps-kk-20140105-3-signed/system/addon.d/70-gapps.sh
--- gapps-kk-20140105-2-signed/system/addon.d/70-gapps.sh	2014-01-24 01:21:34.000000000 +0100
+++ gapps-kk-20140105-3-signed/system/addon.d/70-gapps.sh	2014-01-31 03:09:35.617991709 +0100
@@ -112,9 +112,39 @@
# Stub
;;
pre-restore)
- # Stub
+ setenforce 0
;;
post-restore)
- # Stub
+ setenforce 1
+ chmod 755 /system/addon.d
+ chmod 755 /system/addon.d/*
+ chmod 755 /system/app
+ chmod 644 /system/app/*
+ chmod 755 /system/priv-app
+ chmod 644 /system/priv-app/*
+ chmod 755 /system/etc/permissions
+ chmod 644 /system/etc/permissions/*
+ chmod 755 /system/etc/preferred-apps
+ chmod 644 /system/etc/preferred-apps/*
+ chmod 644 /system/etc/g.prop
+ chmod 755 /system/framework
+ chmod 644 /system/framework/*
+ chmod 755 /system/lib
+ chmod 644 /system/lib/*.*
+ chmod 755 /system/usr/srec/en-US
+ chmod 644 /system/usr/srec/en-US/*
+ chmod -R 755 /system/vendor/pittpatt
+ chmod 644 /system/vendor/pittpatt/models/detection/*
+ chmod 644 /system/vendor/pittpatt/models/recognition/*
+ chcon -Rv --type=system_file:s0 /system/addon.d
+ chcon -Rv --type=system_file:s0 /system/app
+ chcon -Rv --type=system_file:s0 /system/priv-app
+ chcon -Rv --type=system_file:s0 /system/etc/permissions
+ chcon -Rv --type=system_file:s0 /system/etc/preferred-apps
+ chcon -v --type=system_file:s0 /system/etc/g.prop
+ chcon -Rv --type=system_file:s0 /system/framework
+ chcon -Rv --type=system_file:s0 /system/lib
+ chcon -Rv --type=system_file:s0 /system/usr/srec/en-US
+ chcon -Rv --type=system_file:s0 /system/vendor/pittpatt
;;
esac