android-custom/dist-font/cm-data/99-font.sh.addon

78 lines
1.5 KiB
Bash
Executable File

#!/sbin/sh
#
# ADDOND_VERSION=2
#
# /system/addon.d/99-font.sh
#
# we partially use the script at install, if so, $SYSTEM is allready defined
if [ -z $SYSTEM ]; then
. /tmp/backuptool.functions
else
S=$SYSTEM
fi
if [ -z $backuptool_ab ]; then
SYS=$S
TMP="/tmp"
else
SYS="/postinstall/$S"
TMP="/postinstall/tmp"
fi
# path is needed when running from recovery (at install)
export PATH="${PATH}:$S/bin:$S/xbin"
list_files() {
cat <<EOF
fonts/NotoSans-BlackItalic.ttf
fonts/NotoSans-Black.ttf
fonts/NotoSans-BoldItalic.ttf
fonts/NotoSans-Bold.ttf
fonts/NotoSans-Italic.ttf
fonts/NotoSans-LightItalic.ttf
fonts/NotoSans-Light.ttf
fonts/NotoSans-MediumItalic.ttf
fonts/NotoSans-Medium.ttf
fonts/NotoSans-Regular.ttf
fonts/NotoSans-ThinItalic.ttf
fonts/NotoSans-Thin.ttf
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# update fonts.xml
cp -p "$SYS/etc/fonts.xml" "$SYS/etc/fonts.xml.bak"
sed -i \
-e "s/Roboto-/NotoSans-/g" \
"$SYS/etc/fonts.xml"
# Fix ownership/permissions
for i in $(list_files); do
chown root:root "$SYS/$i"
chmod 644 "$SYS/$i"
chmod 755 "$(dirname "$SYS/$i")"
done
;;
esac