Friday, January 9, 2009

Local YUM Repository

Sometimes, especially when you create your own RPMs, it is extremely useful to keep them in a local YUM repository. The advantage of this is that, when you install a package, YUM automatically resolves any dependencies, not only by downloading the necessary packages from the other repositories you might have in you list, but also by using your local repo as a resource for potential dependencies.

So, when installing a package (eg my_package.rpm) with YUM, you are supposed to have already created RPM packages for all of the my_package.rpm’s dependencies and to have updated the repository’s metadata, so that yum is able to resolve all the dependencies. If these dependencies do not exist in any of the repositories in your list, then, in short, you cannot install your package with yum.

How to create a local YUM repo

You will need an utility, named createrepo. Its RPM package exists in Fedora Extras. To install it, just run as root:

# yum install createrepo

Then put your all custom RPM packages into local directory (I am going to copy this RPMS on my apache web directory path). This command copy all RPMS on your CDROM to local system disk

#cp /mnt/cdrom/RedHat/RPMS/*.rpm /var/www/html/local_Redhat_repo

After copying run this command to create metadata for repo, This command will create new with name "repodata" inside /var/www/html/local_Redhat_repo

#createrepo /var/www/html/local_Redhat_repo

Now restart your apache webserver

#service httpd restart

Create new file in /etc/yum.repos.d/local.repo and add this line in that file

[local]
name=RedHat-$releasever - Base
baseurl=http://127.0.0.1/local_Redhat_repo
enabled=1
gpgcheck=0



Now to test this setup run this command

#yum install list
#yum grouplist
#yum install .rpm


Notes:- I am using HTTP server on my setup but you can use NFS, SMB, FTP or Local directory to access repo

No comments:

Post a Comment