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.
So, in order to install an RPM package and all the other packages that it depends on, you only need to run:
# yum install my_package.rpm
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 all your custom RPM packages in a directory. Assuming that this directory is
/mnt/fc_local_repo/, you can create all the necessary metadata for your local repository by running the following command as root or as the user that owns the directory:
# createrepo /mnt/fc_local_repo/
That’s it! Your local YUM repository is ready.
Keep in mind that every time you put any new RPMs in that directory or remove any old RPMs, you will need to run the above command again, so that the repository metadata gets updated.
Add your local repo to the list
The next thing you need to do is to add your local repository to your list of repos, so that yum knows where to find it. This info is kept in the
/etc/yum.repos.d/ directory. As root, create a new text file in this directory, name it
fedora-local.repo (you can use any name you like, but remember to add the extension
.repo), and add the following info in it:
[localrepo] name=Fedora Core $releasever - My Local Repo baseurl=file:///mnt/fc_local_repo/ enabled=1 gpgcheck=0 #gpgkey=file:///path/to/you/RPM-GPG-KEY
As you can see, we used the protocol
file:/// in the
baseurl option. This assumes that the local repo exists in the local machine. If it exists in another machine of your internal network, feel free to use any other protocol in order to tell yum where to find your local repository, For example you can use
In the above example, the GPG key check is disabled (
gpgcheck=0). If you sign your packages, you can set this to "1" and uncomment the following line (
gpgkey=...). This contains the path to your public key, so that YUM can verify the package signatures.
You can have as many local YUM repositories as you like.
Other uses of a local repository
Using a local repository does not only serve as a place for your custom RPMs. You can perfectly save some bandwidth by downloading all the released fedora updates in that repo and use this to update all the systems of your internal network. This will save bandwidth and time.
There is an excellent YUM guide at the Fedora web site. It’s well written and will help you become experts with YUM:
- Managing Software with YUM, by Stuart Ellis.
Local YUM Repository by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Permissions beyond the scope of this license may be available at Licensing Information.
Copyright © 2005 - Some Rights Reserved