#!/usr/bin/sh
# Almohazzem 0.3.1
# Under Waqf License 
# By Mosaab Alzoubi (moceap@linuxac.org - facebook.com/moceap)
# 1433-10-28
#---------------------------------------------------------------
mo_arg="$@"
mo_almohazzem_ver=0.3.1
mo_autoarch=$(arch)
mo_date=$(date +"%a %b %d %Y")
if test -x "`which zenity 2>/dev/null`"
    then
        mo_touse=zenity
elif test -x "`which kdialog 2>/dev/null`"
    then
        mo_touse=kdialog
fi
if [ "$mo_touse" = "" ]
	then 
		echo "You don't has any one of (zenity , kdialog) , you can't run Almohazzem" 
		exit
fi
Tlanguage="بسم الله الرحمن الرحيم
يتوفر برنامج المحزم "$mo_almohazzem_ver" باللغتين العربية والإنجليزية .
 
باختيارك (نعم) فأنت تثبت لغة البرنامج إلى العربية
وباختيارك (لا) فأنت تثبت لغة البرنامج إلى الإنكليزية
كما يمكن تغيير الخيار لاحقاً بتمرير الأمر almohazzem --language في الطرفية .


هل ترغب بتثبيت اللغة إلى اللغة العربية ؟ 

-=-=-=-=-=-=-=-=-

Almohazzem "$mo_almohazzem_ver" is available in Arabic and English 

If you select (Yes) then language of this program set to Arabic
If you select (No) then language of this program set to English
Also you can change language again by command 'almohazzem --language' in terminal .


Do you want to set program language to Arabic ? 
"
detect_language()
{
if [ "$mo_touse" = "zenity" ]
	then 
		Gdetect_language
elif [ "$mo_touse" = "kdialog" ]
	then
		Kdetect_language
fi
}
Gdetect_language()
{
zenity --question --title "اختر اللغة -- Select Language" --text "$Tlanguage"
if [ $? = 1 ]
	then
		mo_language=english
	else
		mo_language=arabic
fi
echo "$mo_language" > $HOME/.almohazzem/language
}
Kdetect_language()
{
kdialog --title "اختر اللغة -- Select Language" --yesno "$Tlanguage"
if [ $? = 1 ]
	then
		mo_language=english
	else
		mo_language=arabic
fi
echo "$mo_language" > $HOME/.almohazzem/language
}
if ( ! [ -e $HOME/.almohazzem/language ] )
	then
		touch $HOME/.almohazzem/language
		mo_language=$(cat $HOME/.almohazzem/language)	
	else
		mo_language=$(cat $HOME/.almohazzem/language)
fi
if [ "$mo_language" = "" ]
	then 
		detect_language
fi
if ( ! [ -e $HOME/Almohazzem\ RPMs/ ] )
	then
		mkdir $HOME/Almohazzem\ RPMs/
fi
if ( ! [ -e $HOME/.almohazzem/ ] )
	then
		mkdir $HOME/.almohazzem/
fi
if ( [ -e /opt/mo_soft/Almohazzem/almohazzem.spec ] )
	then
		cp /opt/mo_soft/Almohazzem/almohazzem.spec $HOME/.almohazzem/almohazzem.spec
	else
		cp almohazzem.spec $HOME/.almohazzem/almohazzem.spec
fi
if [ "$mo_language" = "arabic" ]
	then
		mo_title="المحزم "$mo_almohazzem_ver""		
		if ( [ -e /opt/mo_soft/Almohazzem/mo_description ] )
			then
				cp /opt/mo_soft/Almohazzem/mo_description $HOME/.almohazzem/mo_description
				cp /opt/mo_soft/Almohazzem/mo_description $HOME/.almohazzem/mo_description_test
			else
				cp mo_description $HOME/.almohazzem/mo_description
				cp mo_description $HOME/.almohazzem/mo_description_test
		fi
elif [ "$mo_language" = "english" ]
	then
		mo_title="Almohazzem "$mo_almohazzem_ver""		
		if ( [ -e /opt/mo_soft/Almohazzem/mo_description ] )
			then
				cp /opt/mo_soft/Almohazzem/mo_description-en $HOME/.almohazzem/mo_description
				cp /opt/mo_soft/Almohazzem/mo_description-en $HOME/.almohazzem/mo_description_test
			else
				cp mo_description-en $HOME/.almohazzem/mo_description
				cp mo_description-en $HOME/.almohazzem/mo_description_test
		fi
fi
Ts_continue_ar="تابع لفتح المجلد الناتج ، "
Ts_continue_en="Continue to open Package folder , "
Gs_continue_ar()
{
zenity --title="$mo_title" --info --text="$Ts_continue_ar"
}
Ks_continue_ar()
{
kdialog --title="$mo_title" --msgbox "$Ts_continue_ar"
}
Gs_continue_en()
{
zenity --title="$mo_title" --info --text="$Ts_continue_en"
}
Ks_continue_en()
{
kdialog --title="$mo_title" --msgbox "$Ts_continue_en"
}
datafile_error()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				zenity --title="$mo_title" --info --text="$Tdatafile_error_ar"
				exit
		elif [ "$mo_touse" = "kdialog" ]
			then
				kdialog --title="$mo_title" --msgbox "$Tdatafile_error_ar"
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				zenity --title="$mo_title" --info --text="$Tdatafile_error_en"
		elif [ "$mo_touse" = "kdialog" ]
			then
				kdialog --title="$mo_title" --msgbox "$Tdatafile_error_en"
		fi
fi
}
if [ "$mo_arg" = "--language" ]
	then
		detect_language
		exit
fi
if [ "$mo_arg" = "--version" ]
	then
		echo "$mo_almohazzem_ver"
		exit
fi
if [ "$mo_arg" = "--help" ]
	then
		echo "Almohazzem "$mo_almohazzem_ver" simple RPM packager

--help for help
--language for change almohazzem language
--version for show version of almohazzem"
		exit
fi
if ( ! [ "$mo_arg" = "" ] )
	then
		if ( [ -e "./$mo_arg" ] )
			then
				source "./$mo_arg"
			else
				source "$mo_arg"
		fi
		Tdatafile_error_ar="لم يتم العثور على الملف "$mo_arg_name".almohazzem.tar والضروري للمتابعة"
		Tdatafile_error_en="Can't find necessary file "$mo_arg_name".almohazzem.tar"
		if ( ! [ -e "$mo_arg".tar ] )
			then
			datafile_error
			exit	
		fi			 		
		cp "$mo_arg".tar $HOME/.almohazzem/
		if ( ! [ -e $HOME/.almohazzem/$mo_arg_name.almohazzem.tar ] )
			then
			datafile_error
			exit	
		fi
		cd $HOME/.almohazzem/		 
		tar -xf $HOME/.almohazzem/$mo_arg_name.almohazzem.tar
		mv $HOME/.almohazzem/$mo_arg_name/"$mo_arg_name"-almohazzem.spec $HOME/.almohazzem/almohazzem.spec
		rpmbuild --buildroot=$HOME/.almohazzem/$mo_arg_name/ -ba $HOME/.almohazzem/almohazzem.spec
		rm $HOME/.almohazzem/$mo_arg_name.almohazzem.tar		
		rm -rf $HOME/.almohazzem/$mo_arg_name
		if [ "$mo_language" = "arabic" ]
			then
				if [ "$mo_touse" = "zenity" ]
					then 
						Gs_continue_ar
				elif [ "$mo_touse" = "kdialog" ]
					then
						Ks_continue_ar
				fi
		elif [ "$mo_language" = "english" ]
			then
				if [ "$mo_touse" = "zenity" ]
					then 
						Gs_continue_en
				elif [ "$mo_touse" = "kdialog" ]
					then
						Ks_continue_en
				fi
		fi
		xdg-open $HOME/Almohazzem\ RPMs/		
		exit
fi
Twelcome_ar="بسم الله الرحمن الرحيم

الحمد لله الذي وفقني لكتابة هذا البرنامج والذي أرجوه تعالى أن يكتب به النفع .
- تمت هذه النسخة من الصفر تقريباً وذلك بعد استدراك الكثير من الأخطاء في النسخ السابقة ، 
وإضافة العديد من التحسينات . 

برنامج المحزم "$mo_almohazzem_ver" صمم لمساعدة المبرمجين الجدد في إنشاء
حزمهم الردهاتية بكل سهولة ،

وهو برنامج بسيط سهل الإستخدام لإنشاء الحزم الردهاتية 

منشور تحت رخصة وقف 
تم في يوم السبت الثامن و العشرون من شهر شعبان سنة ثلاث وثلاثين وأربع مئة وألف 
بواسطة مصعب حسني الزعبي moceap@linuxac.org 
-=-=-=-=-=-=-=-"
Twelcome_en="بسم الله الرحمن الرحيم

Thank Allah to help me to write this program .
This version written almost from zero ,
alot of bugs fixed 
and features added .

Almohazzem "$mo_almohazzem_ver" created to help new
programmers to build thier packages very easily 

It's Simple RPM packager

Under Waqf licence 
Done on Sat 28-10-1433
By Mosaab Hosni Alzoubi moceap@linuxac.org

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 "
Gwelcome_ar()
{
zenity --title="$mo_title" --info --text="$Twelcome_ar"
}
Kwelcome_ar()
{
kdialog --title="$mo_title" --msgbox "$Twelcome_ar"
}
Gwelcome_en()
{
zenity --title="$mo_title" --info --text="$Twelcome_en"
}
Kwelcome_en()
{
kdialog --title="$mo_title" --msgbox "$Twelcome_en"
}
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gwelcome_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kwelcome_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gwelcome_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kwelcome_en
		fi
fi
Terror_ar=" - لا يمكن الإستمرار بإدخال بيانات فارغة ، هل ترغب حقاً بالإستمرار بالعمل على البرنامج ؟"
Terror_en="Can't continue with empty data , Do you really want to continue ?"
Gerror_ar()
{
zenity --question --title "$mo_title" --text "$Terror_ar"
}
Kerror_ar()
{
kdialog --title "$mo_title" --yesno "$Terror_ar"
}
Gerror_en()
{
zenity --question --title "$mo_title" --text "$Terror_en"
}
Kerror_en()
{
kdialog --title "$mo_title" --yesno "$Terror_en"
}
Merror()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gerror_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kerror_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gerror_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kerror_en
		fi
fi
}
Tname_ar="اكتب اسم الحزمة المطلوب إنشاءها بالأحرف الإنكليزية الصغيرة"
Tname_en="Write the name of package you want to create with only English small letters"
Gname_ar()
{
mo_name=$(zenity --entry --text "$Tname_ar" --entry-text "" --title "$mo_title" )
}
Kname_ar()
{
mo_name=$(kdialog --inputbox "$Tname_ar" "" --title "$mo_title" )
}
Gname_en()
{
mo_name=$(zenity --entry --text "$Tname_en" --entry-text "" --title "$mo_title" )
}
Kname_en()
{
mo_name=$(kdialog --inputbox "$Tname_en" "" --title "$mo_title" )
}
Mname()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gname_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kname_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gname_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kname_en
		fi
fi
if [ "$mo_name" = "" ]
	then Mname_error
fi
}
Mname_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Mname
fi
}
Mname
Tdir_ar=" - اختر المجلد الذي يحوي الملفات الجاهزة للتحزيم والذي فيه الملفات 
موزعة بالشكل الإفتراضي ليونكس أي (usr - bin - lib .... ) 
(يجب أن لا يحوي المسار على أحرف غير إنكليزية)"
Tdir_en="Select folder wich contain files you want to pack
distributed to Unix-like folders (usr - bin - lib ....) 
(Path must be in English only) "
Gdir_ar()
{
zenity --title="$mo_title" --info --text="$Tdir_ar"
}
Kdir_ar()
{
kdialog --title="$mo_title" --msgbox "$Tdir_ar"
}
Gdir_en()
{
zenity --title="$mo_title" --info --text="$Tdir_en"
}
Kdir_en()
{
kdialog --title="$mo_title" --msgbox "$Tdir_en"
}
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gdir_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kdir_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gdir_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kdir_en
		fi
fi
Gdir()
{
mo_dir=$(zenity --file-selection --directory --title "$mo_title" )
}
Kdir()
{
mo_dir=$(kdialog --getexistingdirectory "$HOME" --title "$mo_title" )
}
Mdir()
{
if [ "$mo_touse" = "zenity" ]
	then 
		Gdir
elif [ "$mo_touse" = "kdialog" ]
	then
		Kdir
fi
if [ "$mo_dir" = "" ]
	then Mdir_error
fi
}
Mdir_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Mdir
fi
}
Mdir
Tsummary_ar="أدخل ملخصاً بسيطاً عن البرنامج"
Tsummary_en="Enter short summary for the program "
Gsummary_ar()
{
mo_summary=$(zenity --entry --text "$Tsummary_ar" --entry-text "" --title "$mo_title" )
}
Ksummary_ar()
{
mo_summary=$(kdialog --inputbox "$Tsummary_ar" "" --title "$mo_title" )
}
Gsummary_en()
{
mo_summary=$(zenity --entry --text "$Tsummary_en" --entry-text "" --title "$mo_title" )
}
Ksummary_en()
{
mo_summary=$(kdialog --inputbox "$Tsummary_en" "" --title "$mo_title" )
}
Msummary()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gsummary_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Ksummary_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gsummary_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Ksummary_en
		fi
fi
if [ "$mo_summary" = "" ]
	then Msummary_error
fi
}
Msummary_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Msummary
fi
}
Msummary
Tversion_ar="أدخل رقم الإصدار للبرنامج بالصيغة المذكورة"
Tversion_en="Enter version number with same format"
Gversion_ar()
{
mo_version=$(zenity --entry --text "$Tversion_ar" --entry-text "1.0" --title "$mo_title" )
}
Kversion_ar()
{
mo_version=$(kdialog --inputbox "$Tversion_ar" "1.0" --title "$mo_title" )
}
Gversion_en()
{
mo_version=$(zenity --entry --text "$Tversion_en" --entry-text "1.0" --title "$mo_title" )
}
Kversion_en()
{
mo_version=$(kdialog --inputbox "$Tversion_en" "1.0" --title "$mo_title" )
}
Mversion()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gversion_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kversion_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gversion_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kversion_en
		fi
fi
if [ "$mo_version" = "" ]
	then Mversion_error
fi
}
Mversion_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Mversion
fi
}
Mversion
Trelease_ar="أدخل رقم الإطلاق للحزمة بالصيغة المذكورة"
Trelease_en="Enter release number with same format"
Grelease_ar()
{
mo_release=$(zenity --entry --text "$Trelease_ar" --entry-text "1" --title "$mo_title" )
}
Krelease_ar()
{
mo_release=$(kdialog --inputbox "$Trelease_ar" "1" --title "$mo_title" )
}
Grelease_en()
{
mo_release=$(zenity --entry --text "$Trelease_en" --entry-text "1" --title "$mo_title" )
}
Krelease_en()
{
mo_release=$(kdialog --inputbox "$Trelease_en" "1" --title "$mo_title" )
}
Mrelease()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Grelease_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Krelease_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Grelease_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Krelease_en
		fi
fi
if [ "$mo_release" = "" ]
	then Mrelease_error
fi
}
Mrelease_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Mrelease
fi
}
Mrelease
Tlicense_ar="اكتب اسم الرخصة التي ستنشر الحزمة ببنودها"
Tlicense_en="Write license name"
Glicense_ar()
{
mo_license=$(zenity --entry --text "$Tlicense_ar" --entry-text "Waqf" --title "$mo_title" )
}
Klicense_ar()
{
mo_license=$(kdialog --inputbox "$Tlicense_ar" "Waqf" --title "$mo_title" )
}
Glicense_en()
{
mo_license=$(zenity --entry --text "$Tlicense_en" --entry-text "Waqf" --title "$mo_title" )
}
Klicense_en()
{
mo_license=$(kdialog --inputbox "$Tlicense_en" "Waqf" --title "$mo_title" )
}
Mlicense()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Glicense_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Klicense_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Glicense_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Klicense_en
		fi
fi
if [ "$mo_license" = "" ]
	then Mlicense_error
fi
}
Mlicense_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Mlicense
fi
}
Mlicense
Tgroup_ar="أدخل المجموعة التي تندرج الحزمة تحتها"
Tgroup_en="Enter the group of package"
Ggroup_ar()
{
mo_group=$(zenity --entry --text "$Tgroup_ar" --entry-text "" --title "$mo_title" )
}
Kgroup_ar()
{
mo_group=$(kdialog --inputbox "$Tgroup_ar" "" --title "$mo_title" )
}
Ggroup_en()
{
mo_group=$(zenity --entry --text "$Tgroup_en" --entry-text "" --title "$mo_title" )
}
Kgroup_en()
{
mo_group=$(kdialog --inputbox "$Tgroup_en" "" --title "$mo_title" )
}
Mgroup()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Ggroup_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kgroup_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Ggroup_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kgroup_en
		fi
fi
if [ "$mo_group" = "" ]
	then Mgroup_error
fi
}
Mgroup_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Mgroup
fi
}
Mgroup
Tarch_ar="أدخل نوع المعالج المطلوب من الحزمة العمل عليه وإذا كانت تعمل على الجميع أدخل 
noarch"
Tarch_en="Enter the arch type , if not enter noarch"
Garch_ar()
{
mo_arch=$(zenity --entry --text "$Tarch_ar" --entry-text "$mo_autoarch" --title "$mo_title" )
}
Karch_ar()
{
mo_arch=$(kdialog --inputbox "$Tarch_ar" "$mo_autoarch" --title "$mo_title" )
}
Garch_en()
{
mo_arch=$(zenity --entry --text "$Tarch_en" --entry-text "$mo_autoarch" --title "$mo_title" )
}
Karch_en()
{
mo_arch=$(kdialog --inputbox "$Tarch_en" "$mo_autoarch" --title "$mo_title" )
}
March()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Garch_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Karch_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Garch_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Karch_en
		fi
fi
if [ "$mo_arch" = "" ]
	then March_error
fi
}
March_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		March
fi
}
March
Tpname_ar="أدخل اسمك"
Tpname_en="Enter your name"
Gpname_ar()
{
mo_pname=$(zenity --entry --text "$Tpname_ar" --entry-text "" --title "$mo_title" )
}
Kpname_ar()
{
mo_pname=$(kdialog --inputbox "$Tpname_ar" "" --title "$mo_title" )
}
Gpname_en()
{
mo_pname=$(zenity --entry --text "$Tpname_en" --entry-text "" --title "$mo_title" )
}
Kpname_en()
{
mo_pname=$(kdialog --inputbox "$Tpname_en" "" --title "$mo_title" )
}
Mpname()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gpname_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kpname_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gpname_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kpname_en
		fi
fi
if [ "$mo_pname" = "" ]
	then Mpname_error
fi
}
Mpname_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Mpname
fi
}
Mpname
Temail_ar="أدخل بريدك الإلكتروني"
Temail_en="Enter your email"
Gemail_ar()
{
mo_email=$(zenity --entry --text "$Temail_ar" --entry-text "" --title "$mo_title" )
}
Kemail_ar()
{
mo_email=$(kdialog --inputbox "$Temail_ar" "" --title "$mo_title" )
}
Gemail_en()
{
mo_email=$(zenity --entry --text "$Temail_en" --entry-text "" --title "$mo_title" )
}
Kemail_en()
{
mo_email=$(kdialog --inputbox "$Temail_en" "" --title "$mo_title" )
}
Memail()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gemail_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kemail_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gemail_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kemail_en
		fi
fi
if [ "$mo_email" = "" ]
	then Memail_error
fi
}
Memail_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Memail
fi
}
Memail
Tdescription_ar="إذا أردت إدخال تفصيل الحزمة بسطر واحد اختر ( نعم ) ، وفي حال رغبت بأن يكون أكثر من سطر فإن برنامج المحزم سيستعين بمحرر النصوص الإفتراضي لديك لإدخال الوصف ولا تنس أن تقوم بالحفظ على نفس الملف بعد قيامك بالتعديلات 
-=-=-=-=-=-
هل ترغب بكتابة الوصف بسطر واحد ؟"
Tdescription_en="If you want to write one-line description enter (yes) , and if you want to write multi-line description then Almohazzem will depend on your defult text editor to enter description , Don't forget saving the changes on same file
-=-=-=-=-=-
Do you want to write one-line description ?
"
Tdescription_ok_ar="اضغط موافق فقط عند الإنتهاء من التحرير"
Tdescription_ok_en="Press OK when you finish editing"
Tdescription1_ar="أدخل تفصيلاً عن الحزمة"
Tdescription1_en="Enter description for the package "
Gdescription_ar()
{
zenity --question --title "$mo_title" --text "$Tdescription_ar"
}
Kdescription_ar()
{
kdialog --title "$mo_title" --yesno "$Tdescription_ar"
}
Gdescription_en()
{
zenity --question --title "$mo_title" --text "$Tdescription_en"
}
Kdescription_en()
{
kdialog --title "$mo_title" --yesno "$Tdescription_en"
}
Gdescription_ok_ar()
{
zenity --title="$mo_title" --info --text="$Tdescription_ok_ar"
}
Kdescription_ok_ar()
{
kdialog --title="$mo_title" --msgbox "$Tdescription_ok_ar"
}
Gdescription_ok_en()
{
zenity --title="$mo_title" --info --text="$Tdescription_ok_en"
}
Kdescription_ok_en()
{
kdialog --title="$mo_title" --msgbox "$Tdescription_ok_en"
}
Gdescription1_ar()
{
mo_description=$(zenity --entry --text "$Tdescription1_ar" --entry-text "" --title "$mo_title" )
}
Kdescription1_ar()
{
mo_description=$(kdialog --inputbox "$Tdescription1_ar" "" --title "$mo_title" )
}
Gdescription1_en()
{
mo_description=$(zenity --entry --text "$Tdescription1_en" --entry-text "" --title "$mo_title" )
}
Kdescription1_en()
{
mo_description=$(kdialog --inputbox "$Tdescription1_en" "" --title "$mo_title" )
}
Mdescription()
{
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gdescription_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kdescription_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gdescription_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kdescription_en
		fi
fi
if [ $? = 1 ]
	then
		xdg-open $HOME/.almohazzem/mo_description		
		if [ "$mo_language" = "arabic" ]
			then
				if [ "$mo_touse" = "zenity" ]
					then 
						Gdescription_ok_ar
				elif [ "$mo_touse" = "kdialog" ]
					then
						Kdescription_ok_ar
				fi
		elif [ "$mo_language" = "english" ]
			then
				if [ "$mo_touse" = "zenity" ]
					then 
						Gdescription_ok_en
				elif [ "$mo_touse" = "kdialog" ]
					then
						Kdescription_ok_en
				fi
		fi
		mo_description=$(cat $HOME/.almohazzem/mo_description)
		mo_description_test=$(cat $HOME/.almohazzem/mo_description_test)		
		if [ "$mo_description" = "$mo_description_test" ]
			then Mdescription_error
		fi
	else
		if [ "$mo_language" = "arabic" ]
			then
				if [ "$mo_touse" = "zenity" ]
					then 
						Gdescription1_ar
				elif [ "$mo_touse" = "kdialog" ]
					then
						Kdescription1_ar
				fi
		elif [ "$mo_language" = "english" ]
			then
				if [ "$mo_touse" = "zenity" ]
					then 
						Gdescription1_en
				elif [ "$mo_touse" = "kdialog" ]
					then
						Kdescription1_en
				fi
		fi
		if [ "$mo_description" = "" ]
			then Mdescription_error
		fi
fi
}
Mdescription_error()
{
Merror
if [ $? = 1 ]
	then
		exit
	else
		Mdescription
fi
}
Mdescription
replace "mo_name" "$mo_name" "mo_arch" "$mo_arch" "mo_summary" "$mo_summary" "mo_version" "$mo_version" "mo_release" "$mo_release" "mo_license" "$mo_license" "mo_group" "$mo_group" "mo_date" "$mo_date" "mo_pname" "$mo_pname" "mo_email" "$mo_email" "mo_description" "$mo_description" -- $HOME/.almohazzem/almohazzem.spec
Trequires_ar=" - أدخل أسماء الحزم الضروري وجودها قبل التثبيت (الاعتماديات)
 - افصل الأسماء بواسطة الفاصلة ,  

-=-=-=-=

كن حذراً في هذا الخيار ، كما يمكن تركه فارغاً
"
Trequires_en="Enter names of requires (depends)
Separate the names by comma ,

-=-=-=-=

Be careful at this step , and you can 
let field empty 
"
Grequires_ar()
{
mo_requires=$(zenity --entry --text "$Trequires_ar" --entry-text "" --title "$mo_title" )
}
Krequires_ar()
{
mo_requires=$(kdialog --inputbox "$Trequires_ar" "" --title "$mo_title" )
}
Grequires_en()
{
mo_requires=$(zenity --entry --text "$Trequires_en" --entry-text "" --title "$mo_title" )
}
Krequires_en()
{
mo_requires=$(kdialog --inputbox "$Trequires_en" "" --title "$mo_title" )
}
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Grequires_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Krequires_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Grequires_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Krequires_en
		fi
fi
if ( ! [ "$mo_requires" = "" ] )
	then
		replace "#Requires:" "Requires: $mo_requires" -- $HOME/.almohazzem/almohazzem.spec
fi
mkdir $HOME/Almohazzem\ RPMs/"$mo_name"-"$mo_version"-"$mo_release"
rpmbuild --buildroot=$mo_dir -ba $HOME/.almohazzem/almohazzem.spec
mkdir $HOME/.almohazzem/"$mo_name"
cp $HOME/.almohazzem/almohazzem.spec $HOME/.almohazzem/"$mo_name"/"$mo_name"-almohazzem.spec
cp -r "$mo_dir"/* $HOME/.almohazzem/"$mo_name"
cd $HOME/.almohazzem
tar -cf "$mo_name".tar "$mo_name"
mv $HOME/.almohazzem/"$mo_name".tar $HOME/Almohazzem\ RPMs/"$mo_name"-"$mo_version"-"$mo_release"/"$mo_name".almohazzem.tar
almohazzemfile="#! /usr/bin/env almohazzem
mo_arg_name="$mo_name"
mo_arg_version="$mo_version"
mo_arg_release="$mo_release"
"
touch $HOME/.almohazzem/"$mo_name".almohazzem
echo "$almohazzemfile" > $HOME/.almohazzem/"$mo_name".almohazzem
mv $HOME/.almohazzem/"$mo_name".almohazzem $HOME/Almohazzem\ RPMs/"$mo_name"-"$mo_version"-"$mo_release"/"$mo_name".almohazzem
chmod +x $HOME/Almohazzem\ RPMs/"$mo_name"-"$mo_version"-"$mo_release"/"$mo_name".almohazzem
rm -rf $HOME/.almohazzem/"$mo_name"
Tcontinue_ar="تابع لفتح المجلد الناتج ، كما تم حفظ المشروع باسم
"$mo_name".almohazzem"
Tcontinue_en="Continue to open Package folder , Project has saved at :
"$mo_name".almohazzem"
Gcontinue_ar()
{
zenity --title="$mo_title" --info --text="$Tcontinue_ar"
}
Kcontinue_ar()
{
kdialog --title="$mo_title" --msgbox "$Tcontinue_ar"
}
Gcontinue_en()
{
zenity --title="$mo_title" --info --text="$Tcontinue_en"
}
Kcontinue_en()
{
kdialog --title="$mo_title" --msgbox "$Tcontinue_en"
}
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gcontinue_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kcontinue_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gcontinue_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kcontinue_en
		fi
fi
xdg-open $HOME/Almohazzem\ RPMs/
Tend_ar="نأمل من الله أن يكون البرنامج قد نال استحسانكم -  
لا تنسونا من صالح دعائكم"
Tend_en="We ask Allah to give us your approvement"
Gend_ar()
{
zenity --title="$mo_title" --info --text="$Tend_ar"
}
Kend_ar()
{
kdialog --title="$mo_title" --msgbox "$Tend_ar"
}
Gend_en()
{
zenity --title="$mo_title" --info --text="$Tend_en"
}
Kend_en()
{
kdialog --title="$mo_title" --msgbox "$Tend_en"
}
if [ "$mo_language" = "arabic" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gend_ar
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kend_ar
		fi
elif [ "$mo_language" = "english" ]
	then
		if [ "$mo_touse" = "zenity" ]
			then 
				Gend_en
		elif [ "$mo_touse" = "kdialog" ]
			then
				Kend_en
		fi
fi
