[Android Software/Hacking General [Developers Only]] osm0sis:
New version of the GApps Auto-Integration script up in the OPs!

/system/su.d/000gappsintegrator:

#!/system/bin/sh
# chmod -R 755 /system/etc/init.d /system/su.d
#
# ROM GApps Auto-Integration
# osm0sis @ xda-developers

logbuff() { logbuff+="$($*)"; }
writable() { touch $1/tmpfile 2>/dev/null; ret=$?; rm $1/tmpfile 2>/dev/null; echo $ret; }

# wait for /system to become remountable/writable
until [ "$(mount -o remount,rw /system >/dev/null; writable /system; mount -o remount,ro /system >/dev/null)" == 0 ]; do
sleep 1;
done;

logbuff echo -n `date`;
gtmp=/data/local/tmp/gapp;

# get SDK version to perform different actions due to /data/app layout changes
sdkver=`getprop ro.build.version.sdk`;

# find new unintegrated Google Apps APKs in /data
for i in $(ls /data/app/ | grep -E 'com.android|com.google.android'); do

# find equivalent /system APK name and only process if it exists
xml=/data/system/packages.xml;
package=`echo $i | cut -d- -f1`;
sysapk=`grep "updated-package name=\"$package" $xml | grep -o 'codePath=.*$' | cut -d\" -f2`;

logbuff echo -ne "\n/data/app/$i $sysapk";

if [ "$sysapk" ]; then

# compare /data and /system APK versions and only integrate if /data is newer (necessary on Lollipop and above)
datver=$(grep "codePath=\"/data/app/$i" $xml | grep -o 'version=.*$' | cut -d\" -f2);
sysver=$(grep "codePath=\"$sysapk" $xml | grep -o 'version=.*$' | cut -d\" -f2);

if [ "$datver" -gt "$sysver" ]; then

logbuff echo -ne "\t ($datver > $sysver)";
mkdir -p $gtmp;

# KitKat (and below) support
if [ "$sdkver" -le 20 ]; then

# remove libraries from copied APK and zipalign if the binaries exist
datapk=/data/app/$i;
if [ "$(zip --help)" -a "$(zipalign --help 2>&1)" ]; then
cp -fp $datapk $gtmp/preopt-$i;
zip -d $gtmp/preopt-$i lib/*;
zipalign -v 4 $gtmp/preopt-$i $gtmp/$i;
datapk=$gtmp/$i;
fi;

# extract and force copy libraries to /system
unzip /data/app/$i -d $gtmp;
chmod 644 $gtmp/lib/arm*/*;
mount -o remount,rw /system;
cp -fp $gtmp/lib/arm*/* /system/lib/;

# overwrite /system APK with new /data APK then fix permissions
cp -f $datapk $sysapk;
chown root.root $sysapk;
chmod 644 $sysapk;

# Lollipop support
elif [ "$sdkver" -le 22 ]; then

# save time on boots after APK work has been completed but apps are awaiting optimzation
if [ ! -f /data/app/$i/integrated ]; then

# remove libraries from copied APK and zipalign if the binaries exist
datapk=/data/app/$i/base.apk;
if [ "$(zip --help)" -a "$(zipalign --help 2>&1)" ]; then

# workaround for Chrome not playing by the usual rules (per usual)
if [ "$(basename $sysapk)" == "Chrome" ]; then
mount -o remount,rw /system;
rm -f $sysapk/lib/arm*/libchrome.so;
else

cp -fp $datapk $gtmp/preopt-$i.apk;
zip -d $gtmp/preopt-$i.apk lib/*;
zipalign -v 4 $gtmp/preopt-$i.apk $gtmp/$i.apk;
datapk=$gtmp/$i.apk;

fi;
fi;

# force copy libraries to /system respecting symlinks then clean up empty files
mount -o remount,rw /system;
cp -RLf /data/app/$i/lib $sysapk;
for j in `ls $sysapk/lib/arm*/*`; do
test ! -s $j && rm -f $j;
done;

# overwrite /system APK with new /data APK then fix permissions
cp -fp $datapk $sysapk/`basename $sysapk`.apk;
chown -R root.root $sysapk;
chmod 644 $sysapk/*.apk $sysapk/lib/arm*/*;

# flag for cleanup on reboot following optimization
touch /data/app/$i/integrated;

fi;
# remove packages.xml entry for /data APK
sed -i -e "/<updated-package name=\"${package}/,/<\/updated-package>/d" $xml;

# Marshmallow (and above) support
elif [ "$sdkver" -ge 23 ]; then

# save time on boots after APK work has been completed but apps are awaiting optimzation
if [ ! -f /data/app/$i/integrated ]; then

# if necessary force copy libraries to /system respecting symlinks then clean up empty files
mount -o remount,rw /system;
if [ -d $sysapk/lib ]; then
cp -RLf /data/app/$i/lib $sysapk;
for j in `ls $sysapk/lib/arm*/*`; do
test ! -s $j && rm -f $j;
done;
fi;

# if necessary force copy APK odex file to /system
if [ -d $sysapk/oat ]; then
cp -fp /data/app/$i/oat/arm*/base.odex $sysapk/oat/arm*/`basename $sysapk`.odex;
fi;

# overwrite /system APK with new /data APK then fix permissions
cp -fp /data/app/$i/base.apk $sysapk/`basename $sysapk`.apk;
chown -R root.root $sysapk;
chmod 644 $sysapk/lib/arm*/* $sysapk/oat/arm*/*;

# flag for cleanup on reboot following optimization
touch /data/app/$i/integrated;

fi;
# remove packages.xml entry for /data APK
sed -i -e "/<updated-package name=\"${package}/,/<\/updated-package>/d" $xml;

fi;
mount -o remount,ro /system;
rm -rf $gtmp;

fi;
elif [ -f /data/app/$i/integrated ]; then

# clean up to mimic pre-Lollipop (AOSP) behavior
rm -rf /data/app/$i;

fi;
done;

# global cleanups required on Lollipop (and above)
if [ "$sdkver" -ge 21 ]; then

# fix /system/lib permissions to ensure libs copied via symlink are correct
mount -o remount,rw /system;
chown root.root /system/lib/*.so;
chmod 644 /system/lib/*.so;
mount -o remount,ro /system;

fi;

logbuff echo -e "\n---";

# write buffered log once /sdcard is available
until [ "$(writable /sdcard)" == 0 ]; do
sleep 1;
done;
log=/sdcard/gapps-integrator.log;
test ! -f $log && echo -e "## GApps Auto-Integration Script Log\n" > $log;
echo -e "$logbuff\n" >> $log;

Changelog:

- added a check-and-wait until /system is writable to hopefully resolve the issues from the script possibly running too early to make changes.

- buffered the script output to a variable and then output it to sdcard at the end after a check-and-wait until /sdcard is writable to hopefully resolve reported logless running.

- skip processing APKs once they've been integrated on Lollipop+, allowing significantly more (usually the rest of the) apps to be optimized on the reboot after integration; finally fewer reboots to fully integrate a long list of updated APKs!

- added lib removal and zipalignment for Lollipop and below if the zip and zipalign binaries are present on the system. Many custom ROMs have zipalign but not many will have zip, so I've done the Google-fu for any who would like to test it out and hunted down static builds of both and uploaded them to my AFH so people may add whichever they need to /system/xbin. Remember to make them root and executable.

- added a lib removal workaround for Chrome on Lollipop, which apparently cannot function without its libraries being present inside the APK. I even attempted to extract crazy.libchrome.so (not present in /data/app) to replace libchrome.so but it doesn't like it, so now we just delete the external (/system/app) libchrome.so to save the space instead and that seems to work!

Working well on my Jelly Bean TV Box (though with lib removal and zipalignment the boot takes significantly longer), and also on my aging Galaxy Nexus running AOSP Lollipop. So far no issues that another reboot hasn't resolved. Enjoy! :)