[Android Software/Hacking General [Developers Only]] osm0sis:
Awesome! Here's the new version with those fixes, now 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 optimization
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)
case $(basename $sysapk) in
*Chrome*)
mount -o remount,rw /system;
rm -f $sysapk/lib/arm*/libchrome.so;;
*)

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;;

esac;
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 optimization
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:

- match complete package name to avoid major breakage on partial matches, e.g. gm (GMail) vs. gms (Google Play services)

- fuzzy match on Chrome workaround to accommodate GoogleChromeDev and GoogleChromeBeta

As previously mentioned, static ARM builds of zip and zipalign (for /system/xbin; chown root:root and chmod 755) to enable APK lib removal are located on my BasketBuild.

I've also decided this project has evolved enough that tracking these changes more closely might be worthwhile, so I've committed them all to GitHub: https://github.com/osm0sis/gappsintegrator

Should make it easier for those wanting to try older versions (I still use the more simplistic v1.5 on my Jelly Bean TV Box, for example), and hopefully will also inspire some collaboration on the project to bring it the rest of the way to fruition. :good: