Go to directory of rpm packages and install createrepo package :

#  rpm  -ivh  createrepo*

Now, edit yum configuration file :

#  vi  /etc/yum.repos.d/rhel-debuginfo.repo

baseurl=file://[directory of packages]

Eg. — file:///var/ftp/pub


:wq [press enter]

Now, run :

#  createrepo  -v  [directory of packages]

Eg.  #  createrepo  -v  /var/ftp/pub

#  yum   list

Now, you are ready to install any package :

#  yum  install  gcc*

If you add new packages to the directory just refresh yum by :

#  createrepo  -v  [directory of packages]
#  yum list