#!/bin/sh
#woof patches
#run this in the root dir of the woof tree #old, now runs from 3builddistro
#(C)01micko gpl3 (see /usr/share/doc/legal)
#20110819
#110822 BK modified, called from 3builddistro. runs with current-dir in 'sandbox3'.
#110825 01micko: some fixes.
#111015 01micko, remove icon and boot screen fixes, integrated in woof
#121108 01micko, fix gconv-modules.cache
#130801 removed fixes for dpi (gtkrc), remove old repos to help ppm
#131209 Packages-puppy- files renamed to Packages-pet-

#option to remove Thunar.desktop if not part of build
echo
echo "do you want to install Thunar as a base package"
echo "hit \"t\" [enter] for yes, Enter only for no."
read THUNAR
if [ "$THUNAR" != "t" ];then
	if [ -f rootfs-complete/usr/share/applications/Thunar.desktop ];then
	rm -f rootfs-complete/usr/share/applications/Thunar.desktop
	echo "removing Thunar.desktop"
		else
	echo "Thunar.desktop not present"
	fi
	else
	echo "leaving Thunar.desktop"
fi
#option to remove video-upgrade-wizard
echo
#echo "do you want to remove video-upgrade-wizard? hit \"y\" for yes"
#read NOVIDWIZ
#if [ "$NOVIDWIZ" = "y" ];then
	#[ -f rootfs-complete/usr/share/applications/video-upgrade-wizard.desktop ] && \
	#rm -f rootfs-complete/usr/share/applications/video-upgrade-wizard.desktop
	#echo "removing video-upgrade-wizard.desktop"
#cat > vidwiz.patch <<_PATCH
#--- rootfs-complete/usr/sbin/wizardwizard	2010-10-19 14:42:44.000000000 +0800
#+++ rootfs-complete/usr/sbin/wizardwizard-new	2011-08-19 09:09:05.000000000 +0800
#@@ -70,16 +70,6 @@ export WizardWizard="
   
   #<hbox>
    #<text>
#-    <label>Upgrade X drivers...</label>
#-   </text>
#-   <button>
#-    <input file>/usr/local/lib/X11/mini-icons/x16.xpm</input>
#-    <action>/usr/sbin/video_upgrade_wizard & </action>
#-   </button>
#-  </hbox>
#-
#-  <hbox>
#-   <text>
     #<label>Connect to Internet or Intranet...</label>
    #</text>
    #<button>
#_PATCH
	#patch -p0 < vidwiz.patch
	#if [ $? -ne 0 ];then echo "FAILED patching /usr/sbin/wizardwizard" 
	#rm -f rootfs-complete/usr/sbin/*.rej
	#rm -f vidwiz.patch
	##exit 1
		#else
	#echo "patching /usr/sbin/wizardwizard succeeded"
	#rm -f vidwiz.patch
	#fi
	#else echo "Ok, video wizard is staying"
#fi
#set PPM gui preference
echo
echo "Do you want the Classic gui or the Ziggy gui for PPM?"
echo "hit \"z\" [enter] for Ziggy, Enter only for Classic."
read ZIGGY
if [ "$ZIGGY" = "z" ];then
	ZIGSET="UI=\"Ziggy\""
	CLASET="UI=\"Classic\""
	sed -i "s%$CLASET%$ZIGSET%" rootfs-complete/usr/local/petget/configure.sh
	sed -i "s%$CLASET%$ZIGSET%" rootfs-complete/usr/local/petget/pkg_chooser.sh
	echo "PPM gui set to \"Ziggy\""
	else echo "Leaving PPM gui set to \"Classic\""
fi
#custom Slacko images, optional #commented 111015
#echo
	#echo "Do you want to have the custom Slacko images?"
	#echo "These are the boot image and a blue Puppy logo instead of grey"
	#echo "\"y\" > enter for yes, enter to skip"
	#read SLACK
	#if [ "$SLACK" = "y" ];then
		#cp -f ../support/slacko/s_puppylogo48.png rootfs-complete/usr/share/doc/puppylogo48.png
		#cp -f ../support/slacko/s_puppylogo96.png rootfs-complete/usr/share/doc/puppylogo96.png
		#[ ! -f ../boot/boot-dialog/puppy.gifORIG ] && mv ../boot/boot-dialog/puppy.gif ../boot/boot-dialog/puppy.gifORIG
		#cp -f ../support/slacko/S_puppy.gif ../boot/boot-dialog/puppy.gif
		#echo "Custom Slacko logos applied"
	#else
		#echo "leaving standard Puppy logos"
		#cp -f ../boot/boot-dialog/puppy.gifORIG ../boot/boot-dialog/puppy.gif
	#fi
echo "Fixing jwm"
	head -n6 rootfs-complete/root/.jwm/jwm_colors > /tmp/jwm_colors
	cp -af /tmp/jwm_colors rootfs-complete/root/.jwm/
	rm -f /tmp/jwm_colors
#echo "Fixing gtkrc theme"
	#head -n2 rootfs-complete/root/.gtkrc-2.0 > /tmp/.gtkrc-2.0
	#echo '
#style "user-font" {
	#font_name = "Sans 12"
#}

#widget_class "*" style "user-font"

#gtk-font-name="Sans 12"

#include "/root/.gtkrc.mine"

## -- THEME AUTO-WRITTEN DO NOT EDIT' >> /tmp/.gtkrc-2.0
#cp -af /tmp/.gtkrc-2.0 rootfs-complete/root/
#rm -f /tmp/.gtkrc-2.0

#echo "fixing PKGS_MANAGEMENT for Slacko repo only"

#grep -v 'PKG_REPOS_ENABLED=' rootfs-complete/root/.packages/PKGS_MANAGEMENT > /tmp/PKGS_MANAGEMENT
#echo "PKG_REPOS_ENABLED=' Packages-pet-slacko-official '" >> /tmp/PKGS_MANAGEMENT
#cp -af /tmp/PKGS_MANAGEMENT rootfs-complete/root/.packages/
#rm -f /tmp/PKGS_MANAGEMENT

# get rid of alsaconf, copied back in in 3builddistro
cat > rootfs-complete/usr/sbin/alsaconf <<_EOF
#!/bin/sh
Xdialog --title "alsaconf" --msgbox "Alsaconf is removed pending a fix \
\n\nPlease try the Multiple Sound Card Wizard then \
\n configure retrovol (the volume icon, right click)" 0 0
_EOF
#make sure still execuatble
chmod 755 rootfs-complete/usr/sbin/alsaconf
echo "Disabling alsaconf"

#121108 fix up gconv-modules.cache
# ***NOTICE*** cross-build, this will have to be executed at first boot... #01micko 121108
if [ "$WOOF_HOSTARCH" = "$WOOF_TARGETARCH" ];then
  [ ! -f rootfs-complete/usr/lib/gconv/gconv-modules.cache ] && chroot rootfs-complete /usr/sbin/iconvconfig
fi
echo "Generating /usr/lib/gconv/gconv-modules.cache"
echo "Removing old slacko and wary5 repos"
DFILE=rootfs-complete/root/.packages/Packages-pet-slacko-official
rm $DFILE
AFILE=rootfs-complete/root/.packages/Packages-pet-wary5-official
rm $AFILE
echo "Removing udev from Packages-slackware-14.0-official"
sed -i '/^udev/d' rootfs-complete/root/.packages/Packages-slackware-14.0-official
echo
echo "Slacko customisation complete"

#exit 0
