#! /bin/sh
# Now this script is a lot of common functions, in the near future, th
set -e

# LliureX removing the ubiquity-desktop

[ ! -e  "/usr/share/applications/ubiquity-gtkui.desktop" ] || rm -f "/usr/share/applications/ubiquity-gtkui.desktop"

chroot /target dpkg --purge casper-customize-mod-sources-list  || true
chroot /target dpkg --purge ubiquity ubiquity-casper ubiquity-frontend-gtk ubiquity-ubuntu-artwork || true
chroot /target dpkg --purge ubiquity ubiquity-casper ubiquity-frontend-gtk ubiquity-ubuntu-artwork lliurex-ubiquity-slideshow|| true


# Common Hooks to solve the braindamage Localechooser

#cat /etc/default/locale > /target/etc/default/locale
#echo "LANGUAGE=$LANGUAGE" >> /target/etc/environment

# Sources.list Hooks


# Remove sources.list.d 
rm -rf /target/etc/apt/sources.list.d/* || true


# Client
rc=0
lliurex-version -t client || rc=1
if [ $rc -eq 0 ] ; then
	# Sanity operations
	mkdir -p /target/etc/apt/

	# Now Write the sources.list
	echo "# LliureX Installation Client" > /target/etc/apt/sources.list
	echo "deb http://mirror/llx1406 pandora main universe restricted multiverse partner" >> /target/etc/apt/sources.list
fi

# Server
rc=0
lliurex-version -t server || rc=1
if [ $rc -eq 0 ] ; then
	# Sanity operations
	mkdir -p /target/etc/apt/

	# Now Write the sources.list
	echo "# LliureX Installation Server" >> /target/etc/apt/sources.list
	echo "# Uncomment the next line to enable the local mirror" >> /target/etc/apt/sources.list
	echo "#deb file:///net/mirror/llx1406 pandora main universe restricted multiverse partner" >> /target/etc/apt/sources.list
fi



exit 0
