Files
vendor_gapps/build/meta/com/google/android/update-binary
Paul Keith f362a67fcc Make ui_print messages consistent
Change-Id: I95f870030820557df074fa6c5d82584b9ecfe441
Signed-off-by: Paul Keith <javelinanddart@bestas.gr>
2017-05-02 14:47:44 -05:00

102 lines
2.1 KiB
Bash

#!/sbin/sh
OUTFD="/proc/self/fd/$2"
ZIP=$3
exec_util() {
LD_LIBRARY_PATH=$LD_PATH $UTILS $1
}
set_con() {
exec_util "chcon -h u:object_r:"$1":s0 $2"
exec_util "chcon u:object_r:"$1":s0 $2"
}
set_perm() {
exec_util "chmod $1 $2"
}
set_owner() {
exec_util "chown $1:$2 $3"
}
ui_print() {
echo "ui_print $1" > "$OUTFD";
echo "ui_print" > "$OUTFD";
}
ui_print "**********************"
ui_print "MindTheGapps installer"
ui_print "**********************"
ui_print "Mounting /system"
if mount /system; then
ui_print "/system mounted"
else
# Try to get the block from /etc/recovery.fstab
block=`cat /etc/recovery.fstab | cut -d '#' -f 1 | grep /system | grep -o '/dev/[^ ]*' | head -1`
if [ -n "$block" ] && mount $block /system; then
ui_print "Could not mount /system! Aborting"
exit 1
else
ui_print "/system mounted"
fi
fi
if [ -f /system/bin/toybox ]; then
UTILS=/system/bin/toybox
LD_PATH=/system/lib
else
ui_print "Could not find /system/bin/toybox! Aborting"
exit 1
fi
DIRS="addon.d app priv-app framework etc lib"
if [ -d /system/lib64 ]; then
DIRS="$DIRS lib64"
LD_PATH=/system/lib64
fi
ui_print "Extracting files"
cd /tmp
unzip -o "$ZIP" system/*
cd system
ui_print "Generating addon.d file"
cat addon.d/addond_head > addon.d/30-gapps.sh
for f in `exec_util "find . -type f"`; do
line=$(echo "$f" | sed 's/\.\///')
echo "$line" >> addon.d/30-gapps.sh
done
cat addon.d/addond_tail >> addon.d/30-gapps.sh
ui_print "Preparing files for copying"
for dirs in $DIRS; do
set_perm 0755 $dir
for d in `exec_util "find ./$dir -type d"`; do
set_perm 0755 $d
set_owner root root $d
done
for f in `exec_util "find ./$dir -type f"`; do
type=$(echo "$f" | sed 's/.*\.//')
if [ "$type" == "sh" ] || [ "$type" == "$f" ]; then
set_perm 0755 $f
else
set_perm 0644 $f
fi
set_owner root root $f
set_con system_file $f
done
done
ui_print "Copying files"
exec_util "cp --preserve=a -r ./* /system/"
ui_print "Cleaning up files"
cd ../
exec_util "rm -rf system/"
ui_print "Unmounting /system"
umount /system
ui_print "Done!"
exit 0