#! /bin/sh
echoc RED $0 is BROKEN !
exit 0

	# ----- DEPS FOR SHELLS, PERLS, MANS, INFOES -----------------
	echo
	echoc GREEN "Building Temporary manifest ..."
	find $PKG_DIR -type f | grep -v "\/install\/" > ${TEMPA}

	echoc GREEN "Seaching shell's scripts ..."
	while read x ; do
		[ ! -x $x ] && continue
		file $x | grep -q "Bourne"
		if [ $? -eq 0 ]; then
			echo "Found at least one shell script ($x)"
			echo $DEPS_SHELL >> $PKG_INSTALL/REQUEST
			break
		fi
	done < ${TEMPA}

	echoc GREEN "Seaching perl's scripts ..."
	while read x ; do
		[ ! -x "$x" ] && continue
		file "$x" | grep -q "perl"
		if [ $? -eq 0 ]; then
			echo "Found at least one perl script ($x)"
			echo $DEPS_PERL >> $PKG_INSTALL/REQUEST
			break
		fi
	done < ${TEMPA}
	rm -f ${TEMPA}

	# ----- INSTALL-SCRIPTS -----------------------------------
	echo
	echoc GREEN "Adjusting scripts : "
	[ -f $PKG_INSTALL/COMPILE ] && gzip -v9f $PKG_INSTALL/COMPILE
	[ -f $PKG_INSTALL/NOTES ]   && gzip -v9f $PKG_INSTALL/NOTES
	#
	for i in  MANIFEST  MD5SUM* REQUEST COMPILE* NOTES*  CONFLICTS
	do
		TEMPSCRIPT="$PKG_INSTALL/$i"
		if [ -f $TEMPSCRIPT ]; then
			echo $i
			chmod 640 $TEMPSCRIPT
			chown root.root $TEMPSCRIPT
		fi
	done
	
	# Move old scripts
	if [ -f $PKG_INSTALL/PRE-DELETE ]; then
	  echoc YELLOW "Appending PRE-DELETE to PRE-REMOVE"
	  cat $PKG_INSTALL/PRE-DELETE >> $PKG_INSTALL/PRE-REMOVE
	  rm -f $PKG_INSTALL/PRE-DELETE
	  read x
	fi
	if [ -f $PKG_INSTALL/DELETE ]; then
	  echoc YELLOW "Appending DELETE to REMOVE"
	  cat $PKG_INSTALL/DELETE >> $PKG_INSTALL/REMOVE
	  rm -f $PKG_INSTALL/DELETE
	  read x
	fi
	if [ -f $PKG_INSTALL/POST-DELETE ]; then
	  echoc YELLOW "Appending POST-DELETE to POST-REMOVE"
	  cat $PKG_INSTALL/POST-DELETE >> $PKG_INSTALL/POST-REMOVE
	  rm -f $PKG_INSTALL/POST-DELETE
	  read x
	fi
	if [ -f $PKG_INSTALL/PRUNE ]; then
	  echoc YELLOW "Appending PRUNE to PURGE"
	  cat $PKG_INSTALL/PRUNE >> $PKG_INSTALL/PURGE
	  rm -f $PKG_INSTALL/PRUNE
	  read x
	fi
	if [ -f $PKG_INSTALL/CONFIGURE ]; then
	  echoc YELLOW "Appending CONFIGURE to INSTALL"
	  cat $PKG_INSTALL/CONFIGURE >> $PKG_INSTALL/INSTALL
	  rm -f $PKG_INSTALL/CONFIGURE
	  read x
	fi
	
	for i in PRE-INSTALL  INSTALL  POST-INSTALL X-POST-INSTALL \
		PRE-REMOVE REMOVE POST-REMOVE PURGE
	do
		TEMPSCRIPT="$PKG_INSTALL/$i"
		if [ -f $TEMPSCRIPT ]; then
			echo $i
			chmod 700 $TEMPSCRIPT
			chown root.root $TEMPSCRIPT

			grep -q "^set -e" $TEMPSCRIPT
			if [ $? -ne 0 ]; then
				echoc YELLOW "You are not using 'set -e' into this script"
				echo "Press ENTER to continue"
				read x
			fi

			grep -q "^set -x" $TEMPSCRIPT
			if [ $? -eq 0 ]; then
				echoc YELLOW "You are using 'set -x' into this script"
				echo "Press ENTER to continue"
				read x
			fi
		fi
	done

	# Se c'e' incoming ci deve essere anche PURGE
	if [ -d $PKG_DIR/incoming ]; then
          if [ ! -f $PKG_INSTALL/PURGE ]; then
            echoc YELLOW "directoy 'incoming' is present, you should write a PURGE script !"
            read x
          fi
        fi

	# ----- ICON -------------------------------------------
	if [ ! -d $PKG_DIR/usr/share/gnome/apps ]; then
		echoc YELLOW "There are no icons under /usr/share/gnome/apps"
		echo "Press ENTER to continue"
		read x
	fi

	# ---- LIBRARY NAME ------------------------------------
	echo
	echoc CYAN "Preparazione dei link delle librerie ..."
	for i in `find $PKG_DIR -type f -iname "lib*.so.*.*"` ; do
		LDIR="`dirname $i`"
		LNAME="`basename $i`"
		LSO="`echo $LNAME | cut -f 1 -d '.' `"
		LVER="`echo $LNAME | cut -f 3- -d '.' `"
		LX=`echo $LVER | cut -f 1 -d '.' `
		LY=`echo $LVER | cut -f 2 -d '.' `
		LZ=`echo $LVER | cut -f 3 -d '.' `
		echoc PURPLE "SONAME=$LSO   V=$LVER   X=$LX   Y=$LY   Z=$LZ"
		if [ "$LSO" = "" -o "$LVER" = "" -o "$LX" = "" -o "$LY" = "" ]; then
			echoc YELLOW "There's a blank value ... skipping"
			continue
		fi
		( 
			cd $LDIR
			ln -s $LNAME   $LSO.so.$LX
			ln -s $LNAME   $LSO.so
			ln -s $LNAME   ${LSO}${LX}.so
			grep -q "#SIMLINK:$LNAME" $PKG_INSTALL/INSTALL
			if [ $? -eq 0 ]; then
			  echoc YELLOW "Aggiungo del codice ad INSTALL ..."
  			  echo ""                    >>$PKG_INSTALL/INSTALL
			  echo "#SIMLINK:$LNAME"    >>$PKG_INSTALL/INSTALL
			  echo "( cd $LDIR"          >>$PKG_INSTALL/INSTALL
			  echo "rm $LSO.so.$LX    ; ln -s $LNAME $LSO.so.$LX" >>$PKG_INSTALL/INSTALL
			  echo "rm $LSO.so        ; ln -s $LNAME $LSO.so"     >>$PKG_INSTALL/INSTALL
			  echo "rm ${LSO}${LX}.so ; ln -s $LNAME ${LSO}${LX}.so" >>$PKG_INSTALL/INSTALL
			  echo ")" >>$PKG_INSTALL/INSTALL
		        fi
		)
	done

	# ---- MD5 ----
	echo
	echoc GREEN "Calculating MD5 Checksums ..."
	cd $PKG_DIR
	find -type f -perm +111 1>$TEMPDATA
        >$PKG_INSTALL/MD5SUM
        for item in $TEMPDATA ; do
          md5sum "$item" >>$PKG_INSTALL/MD5SUM
        done
	gzip -v9f $PKG_INSTALL/MD5SUM


	# ---- DIRECTORY PERMISSION
	echo
	echoc GREEN "Applying directory permissions (press ENTER at the end)..."
	OLD_DIR=$PWD
	cd $PKG_DIR
	echo | badpenguin-permissions.sh 2>/dev/null
	cd $OLD_DIR
	echo

	# ---- DIRECTORY PERMISSION INCOMING
        if [ -d $PKG_DIR/incoming ]; then
  	  echo
	  echoc GREEN "Applying permissions to incoming (press ENTER at the end)..."
	  OLD_DIR=$PWD
	  cd $PKG_DIR/incoming
	  echo | badpenguin-permissions.sh 2>/dev/null
	  cd $OLD_DIR
	  echo
        fi
	# Next
	[ $AUTOBUILD -gt 0 ] && AUTOBUILD=6
	echo 6 > $FAUTOBUILD
fi



