Index: ipk/source.sh4/emus_gbox_773/CONTROL/postinst
===================================================================
--- ipk/source.sh4/emus_gbox_773/CONTROL/postinst	(revision 12395)
+++ ipk/source.sh4/emus_gbox_773/CONTROL/postinst	(revision 12781)
@@ -5,11 +5,4 @@
 CONFIGDIR=/var/etc
 echo "successfully installed"
-echo "syncing disk"
-sync
-if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1 | wc -l` -eq 1 ]; then
-	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1`
-	FREE=`expr $SPACE - 100`
-	echo new freespace size $FREE kb
-fi
 
 if [ ! -e /var/keys/cwshare.cfg ]; then
@@ -49,3 +42,11 @@
 fi
 
+if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1 | wc -l` -eq 1 ]; then
+	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1`
+	FREE=`expr $SPACE - 100`
+	echo new freespace size $FREE kb
+else
+	echo "syncing disk"
+	sync
+fi
 exit 0
Index: ipk/source.sh4/emus_gbox_773/CONTROL/postrm
===================================================================
--- ipk/source.sh4/emus_gbox_773/CONTROL/postrm	(revision 12395)
+++ ipk/source.sh4/emus_gbox_773/CONTROL/postrm	(revision 12781)
@@ -2,10 +2,11 @@
 TMP=/tmp/.keys
 echo "successfully removed"
-echo "syncing disk"
-sync
 if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1 | wc -l` -eq 1 ]; then
 	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1`
 	FREE=`expr $SPACE - 100`
 	echo new freespace size $FREE kb
+else
+	echo "syncing disk"
+	sync
 fi
 
Index: ipk/source.sh4/emus_gbox_773/CONTROL/preinst
===================================================================
--- ipk/source.sh4/emus_gbox_773/CONTROL/preinst	(revision 12395)
+++ ipk/source.sh4/emus_gbox_773/CONTROL/preinst	(revision 12781)
@@ -2,6 +2,4 @@
 #
 TMP=/tmp/.keys
-echo "syncing disk"
-sync
 
 model=`cat /etc/model`
@@ -33,5 +31,21 @@
 fi   
 echo "installing gbox and configs..."
-
+if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1 | wc -l` -eq 1 ]; then
+	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1`
+	FREE=`expr $SPACE - 100`
+	SIZE=1360
+	echo "checking freespace"
+	echo packege size $SIZE kb
+	echo freespace size $FREE kb
+	if  [ "$FREE" -lt "$SIZE" ]; then
+		echo "sorry no freespace left on device"
+		exit 1
+	else
+		echo ok		
+	fi
+else
+	echo "syncing disk"
+	sync
+fi
 buildgroup=`cat /etc/.buildgroup`
 echo "checking OS"	 
@@ -44,5 +58,5 @@
 	exit 1 	 	 
 fi
-sync
+
 exit 0
 
Index: ipk/source.sh4/emus_gbox_773/CONTROL/prerm
===================================================================
--- ipk/source.sh4/emus_gbox_773/CONTROL/prerm	(revision 12395)
+++ ipk/source.sh4/emus_gbox_773/CONTROL/prerm	(revision 12781)
@@ -2,10 +2,4 @@
 TMP=/tmp/.keys
 echo "syncing disk"
-sync
-if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1 | wc -l` -eq 1 ]; then
-	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1`
-	FREE=`expr $SPACE - 100`
-	echo freespace size $FREE kb
-fi
 
 if [ ! -e /var/keys/oscam.conf.oscam ]; then
@@ -34,4 +28,13 @@
 fi
 
+if [ `df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1 | wc -l` -eq 1 ]; then
+	SPACE=`df | grep /dev/mtdblock | grep var | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1`
+	FREE=`expr $SPACE - 100`
+	echo new freespace size $FREE kb
+else
+	echo "syncing disk"
+	sync
+fi
+
 echo "removing gbox and configs"
 exit 0
