#! /bin/sh

VER=1.0.0
RELEASE_NUM=2
OS=mdk
PACK_FORMAT=rpm

PACKAGE_LIST=PackageListMFC
LANGUAGE_LIST=languageList
RELEASE_DIR=linux-2.4-intel

echo ""
echo Version = $VER
echo Relese Number = $RELEASE_NUM
echo ""

if [ "$RELEASE_NUM" = "0" ]
then
	SRC_NAME=linux-2.4-intel.rpm
else
	SRC_NAME=`echo NUM-linux-2.4-intel.rpm | eval sed 's/NUM/"$RELEASE_NUM"/'`
fi
DST_NAME=`echo TEMP1.TEMP2.i386.TEMP3 | eval sed -e 's/TEMP1/"$RELEASE_NUM"/' -e 's/TEMP2/"$OS"/' -e 's/TEMP3/"$PACK_FORMAT"/'`

SRC_EPMLIST=epmcups.list

for LANGUAGE_NAME in `cat $LANGUAGE_LIST`
do

echo [$LANGUAGE_NAME]

LOCAL_DIR=`echo $RELEASE_DIR/TEMP1 | eval sed 's/TEMP1/"$LANGUAGE_NAME"/'`

mkdir -p $LOCAL_DIR

CNT=0
for PACKAGE_NAME in `cat $PACKAGE_LIST`
do
	CNT=`expr $CNT + 1`
#	mm
	LISTFILE=`echo TEMP1cupswrapper | eval sed 's/TEMP1/"$PACKAGE_NAME"/'`
	cat $SRC_EPMLIST | eval sed -e 's/EPM_VERSION/"$VER"/' -e 's/EPM_RELEASE/"$RELEASE_NUM"/' -e 's/EPM_LANGUAGE/"$LANGUAGE_NAME"/' -e 's/DEP_PACKAGE/"$PACKAGE_NAME"lpr/' -e 's/PT_PRINTER_NAME/\"$PACKAGE_NAME\"/' -e 's/PT_SYSTEM_VALUE/\"\"/' > $LISTFILE.list
	echo Create $LISTFILE !!

	epm -f $PACK_FORMAT $LISTFILE

	PACKAGE1=`echo $RELEASE_DIR/TEMP1-TEMP2-TEMP3 | eval sed 's/TEMP1/"$LISTFILE"/' | eval sed 's/TEMP2/"$VER"/' | eval sed 's/TEMP3/"$SRC_NAME"/'`
	PACKAGE2=`echo $LOCAL_DIR/TEMP1-TEMP2-TEMP3   | eval sed 's/TEMP1/"$LISTFILE"/' | eval sed 's/TEMP2/"$VER"/' | eval sed 's/TEMP3/"$DST_NAME"/'`

	mv $PACKAGE1 $PACKAGE2
	rm -f $LISTFILE.list

#	inch
#	LISTFILETMP=`echo TEMP1cupswrapper | eval sed 's/TEMP1/"$PACKAGE_NAME"/'`
#	LISTFILE=`echo TEMP1cupswrapperinch | eval sed 's/TEMP1/"$PACKAGE_NAME"/'`
#	cat $SRC_EPMLIST | eval sed -e 's/EPM_VERSION/"$VER"/' -e 's/EPM_RELEASE/"$RELEASE_NUM"/' -e 's/EPM_LANGUAGE/"$LANGUAGE_NAME"/' -e 's/DEP_PACKAGE/"$PACKAGE_NAME"lpr/' -e 's/PT_PRINTER_NAME/\"$PACKAGE_NAME\"/' -e 's/PT_SYSTEM_VALUE/\"_inch\"/' -e 's/CONFLICT_PACKAGE/${LISTFILETMP}/'> $LISTFILE.list
#	echo Create $LISTFILE !!

#	epm -f $PACK_FORMAT $LISTFILE

#	PACKAGE1=`echo $RELEASE_DIR/TEMP1-TEMP2-TEMP3 | eval sed 's/TEMP1/"$LISTFILE"/' | eval sed 's/TEMP2/"$VER"/' | eval sed 's/TEMP3/"$SRC_NAME"/'`
#	PACKAGE2=`echo $LOCAL_DIR/TEMP1-TEMP2-TEMP3   | eval sed 's/TEMP1/"$LISTFILE"/' | eval sed 's/TEMP2/"$VER"/' | eval sed 's/TEMP3/"$DST_NAME"/'`

#	mv $PACKAGE1 $PACKAGE2
#  	rm -f $LISTFILE.list
done

done
