#!/bin/sh
set -e

# Hook for building live images
#
# This script is run in the built chroot after all packages are installed,
# before it is packed into a squashfs. This is where you can apply extra tweaks
# to the live system.

#cat /usr/share/ubuntukylin-default-settings/remove-package.list | while read line
#do
#    [ `dpkg -l $line | grep -c "^ii"` != 0 ] && apt-get purge --auto-remove -y $line
#done

#rawlist=$(cat /usr/share/ubuntukylin-default-settings/remove-package.list)
#list=$(dpkg -l $rawlist | awk '/^i/ {print $2}')
#[ -z "$list" ] || apt-get purge --auto-remove -y $list

#extra install operation for ubuntu-kylin-docs is conflicted with ubuntu-docs
#apt-get install -y ubuntu-kylin-docs

#apt-get purge --auto-remove -y ibus ibus-gtk ibus-gtk3 python-ibus libopencc1 ubuntu-wallpapers ubuntu-wallpapers-trusty indicator-keyboard libtcl8.6 
#apt-get purge --auto-remove -y totem totem-common gstreamer1.0-clutter libtotem0 gir1.2-totem-plparser-1.0 libreoffice-help-en-us
#apt-get purge --auto-remove -y totem totem-common libtotem0 gir1.2-totem-plparser-1.0
#apt-get purge --auto-remove -y language-pack-de language-pack-es language-pack-pt firefox-locale-de firefox-locale-es firefox-locale-pt
#apt-get purge --auto-remove -y example-content guile-2.0-libs liblouis-data lintian landscape-client-ui-install
#apt-get purge --auto-remove -y fonts-freefont-ttf fonts-kacst fonts-kacst-one fonts-lao fonts-nanum fonts-takao-pgothic fonts-tlwg-kinnari fonts-tlwg-loma fonts-tlwg-mono fonts-tlwg-norasi fonts-tlwg-purisa fonts-tlwg-sawasdee fonts-tlwg-typewriter fonts-tlwg-typist fonts-tlwg-typo fonts-tlwg-umpush fonts-tlwg-waree fonts-thai-tlwg 
#mkdir -p /etc/skel/桌面
#cp /usr/share/applications/firefox.desktop /etc/skel/桌面/

sed -i "s/\`lsb_release -i -s 2> \/dev\/null || echo Debian\`/Ubuntu\\\ Kylin/g" /etc/default/grub
#sed -i "/CHROMIUM_FLAGS/s/\"\"/\"http:\/\/123.sogou.com\/?11458\"/g" /etc/chromium-browser/default
#sed -i "/DISTRIB_DESCRIPTION/s/Ubuntu/Ubuntu Kylin/g" /etc/lsb-release
#sed -i "s/Ubuntu/Ubuntu Kylin/g" /usr/lib/firefox/distribution/distribution.ini
#sed -i "s/canonical/Ubuntu Kylin/g" /usr/lib/firefox/distribution/distribution.ini
#cp -f /usr/share/icons/hicolor/UbuntuLogo.png /usr/share/gnome-control-center/ui/UbuntuLogo.png


# Close the startup applications
#if [ -f "/etc/xdg/autostart/deja-dup-monitor.desktop" ];then
#echo "\nX-GNOME-Autostart-enabled=false" >> /etc/xdg/autostart/deja-dup-monitor.desktop
#fi
#if [ -f "/etc/xdg/autostart/vino-server.desktop" ];then
#echo "\nX-GNOME-Autostart-enabled=false" >> /etc/xdg/autostart/vino-server.desktop
#fi
#if [ -f "/etc/xdg/autostart/gnome-user-share.desktop" ];then
#echo "\nX-GNOME-Autostart-enabled=false" >> /etc/xdg/autostart/gnome-user-share.desktop
#fi
#if [ -f "/etc/xdg/autostart/update-notifier.desktop" ];then
#echo "\nX-GNOME-Autostart-enabled=false" >> /etc/xdg/autostart/update-notifier.desktop
#fi
