#!/bin/sh


PKGNAME="`basename "$0" .remove`"


remove_patch() {
    local PATCH="${2#*
}"
    PATCH="${PATCH%
*}"
	[ -z "$PATCH" ] && return
	PATCH="${PATCH//\\/\\\\}"
    local TEMP="`awk -v p="$PATCH" '{ b=b"\n"$0; i=index(b"\n","\n"p"\n"); if (i!=0) b=substr(b,1,i-1) } END { print substr(b,2) }' "$1"; echo PATCH`"
    echo "${TEMP%?PATCH}" >"$1"
}


PATCH='

## insert by '"$PKGNAME"' ##
locale | grep "LC_CTYPE=\"\?zh_CN\." || export LC_CTYPE="zh_CN.UTF-8"
export XMODIFIERS="@im=fcitx"
export GTK_XIM_MODULES="fcitx"
export QT_XIM_MODULES="fcitx"
#config creation bug-fix for fcitx
if [ ! -e /root/.fcitx/config ] || [ "`md5sum /root/.fcitx/config`" = "eb8edb73159e0a6b228de1af183b87c9  /root/.fcitx/config" ]; then
 cp /usr/share/fcitx/data/config /root/.fcitx/config
fi
fcitx &
##########

'
remove_patch "/root/.xinitrc" "$PATCH"


PATCH="

## insert by $PKGNAME ##
awk '"'$1 !~ /^#/ && $1 != "none" && $2 != "none" { system("mkdir -p "$2) }'"' /etc/fstab
mount -a
##########

"
remove_patch "/etc/rc.d/rc.local" "$PATCH"


PATCH='
<rule match="/usr/bin/sakura">
<icon>/usr/local/lib/X11/pixmaps/console48.png</icon>
</rule>
'
remove_patch "/root/Choices/ROX-Filer/globicons" "$PATCH"

sed -i 's@>/usr/bin/sakura</icon>@>/usr/bin/rxvt</icon>@' /root/Choices/ROX-Filer/PuppyPin


sed -i 's@<Option name="menu_xterm">sakura</Option>@<Option name="menu_xterm">xterm</Option>@' /root/.config/rox.sourceforge.net/ROX-Filer/Options


mkfontdir /usr/share/fonts/default/misc
mkfontscale /usr/share/fonts/default/misc

