My thoughts on Tech

Creating Your Own YUM Repository

This is a guest post by Kunal Gautam. This article is aimed at RHEL and Fedora users.

If you’ve been using Linux for a while, then you’d know how much of a pain it is to install a software which runs into dependency problems. One way of getting around this is to use a repository.

What is YUM?

YUM or Yellowdog Updater Modified is an interactive, automated update program which can be used for maintaining system using rpm. Yum is an automatic updater and package installer/remover for rpm systems. It automatically computes dependencies and figures out what things should occur to install packages.
Yum makes it easier to maintain groups of machines without having to manually update each one using rpm.

What is a Repository ?
A repository is a collection of list of rpm[s]. It contain various information regarding the rpm like its dependencies etc

Why to use Yum if I can install RPM using rpm command?
Well if you want to install RPM you have to make sure that its dependencies are also installed . But this is not in the case of YUM you can simply install package with its dependencies. YUM take care of your all install things . Also update feature is not available in the rpm installation method but it is available in yum.

Here are some key features of “Yum”:

  • Multiple Repositories
  • Simple config file
  • Correct dependency calculation
  • Fast operation
  • rpm-consistent behavior
  • comps.xml group support, including multiple repository groups
  • Simple interface

Starting With Creating Your Own Repository [Server Side Configuration]

Step One: Check Prequisites

  • Have Your Distro CD/DVD
  • Check if you have free space on your Hard Disk or not [Total space required vary from Distro to Distro]

Step Two : Copy Disc to Hard Disk

First mount your CD/DVD  and copy it to hard disk
cp –avr /cd/dvd/mount/point/   /destination/directory/

Repeat this step with your all your cds .
Note:- If you want install Repository on your network thrugh ftp or http upload in their respective default directories i.e /var/ftp/pub for ftp server and /var/www/html for http server.

Step Three : Intalling CreateRepo Package

Now go to your directory where you copied the files and search for createrepo-*.rpm file * may be different from version to version and system architecture
Install that rpm using rpm command, as follows

rpm -ivh --aid createrepo-*.rpm

Step Four: Run createrepo

Go to the directory where you copied the file and run the createrepo command

createrepo -v .

[please note that “.” {dot} after that command as we are in present directory ]

The server side settings are done.
Lets have a look at client side setting now.

Client Side Setting For YUM

Create a repo file in /etc/yum.repos.d/ directory [ you can name anything to your file make sure a .repo extension is added later on]

vim /etc/yum.repos.d/my.repo

Add following date in that file

[Myrepo]
name=Any name you want to put
baseurl=file:///destination/directory/
enabled=1
gpgcheck=0

The first line is alias given for your repository . This help to indicate/find that from which repository the package is available.
Second line is name for your repo, which you can put anything
Next comes baseurl
baseurl supports different protocols like file:// ftp:// httpd:// etc. If you are running repository from local system then give absolute path after file:// .
For ftp give ftp://server_ip_or_domain/pub_dir_or_accessable_dir or http://server_ip_or_domain/dir
Next line is enabled this specifies if yum should enable that repo server for installation or not 1 is for enable and 0 is for disable
gpgcheck is for checking gpg key. As I didn’t require the key-checking feature, I have disabled this. If you have enabled it, then you will have to add one more line after that,

gpgkey=/your/path/to/key

which specifies the location to the gpgkey

After this save that repo file and run following command

yum clean all [ will clean yum database ]
yum list [will list the files / packages available on that directory ]

If you are finding this difficult, or are having some promblems, then please feel free to ask your query by dropping a comment.

Note 1:- SElinux or Firewall may conflict sometimes [ for ftp and http service ]
Note2 :- I have used RHEL server 5 edition . This process is same for RHEL 4, 5 or for Fedora.

If you enjoyed this post, make sure you subscribe to my RSS feed!

10 Comments

  1. June 22, 2008    

    Not only RHEL also Fedora Core.

  2. June 25, 2008    

    Man Publish full detail here . Site will be unavailable .

  3. November 4, 2008    

    Loading “rhnplugin” plugin
    Loading “security” plugin
    Loading “installonlyn” plugin
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up repositories
    file://root/server/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: ‘/server/repodata/repomd.xml’
    Trying other mirror.
    Error: Cannot open/read repomd.xml file for repository: Serverpackage

  4. November 4, 2008    

    yum list
    Loading “rhnplugin” plugin
    Loading “security” plugin
    Loading “installonlyn” plugin
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up repositories
    file://root/server/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: ‘/server/repodata/repomd.xml’
    Trying other mirror.
    Error: Cannot open/read repomd.xml file for repository: Serverpackage

  5. November 4, 2008    

    @Annadurai
    It clearly says that File not exsist [ and it will not coz address/path is wrong ]

    PLEASE SEE CLEARLY file:///root/server/ [ it shud have triple slash two for protocol and one for path :) ]

    Rest if you have any prob Leave a mail @ admin@tech-nologic.info Will reply ASAP :)

  6. February 5, 2009    

    To add more to what Kunal said…

    The process is the same regardless of OS if you are using current versions of rpm/yum/createrepo.

    So you can use this setup on any distro (SuSe, Slackware, Debian, etc…) as long as rpm, yum, and createrepo are installed.

    The OS is not what dictates the process here it is the application(s). :~)

  7. Kunal Gautam's Gravatar Kunal Gautam
    July 30, 2009    

    Rhn error whenever i want to install packacge through yum

  8. Hari's Gravatar Hari
    November 18, 2009    

    Thank u v.much Sathya,
    the information given regarding “Creating Your Own YUM Repository” is really very informative and helpful,
    i’m searching this answer for nearly 2 weeks, and it solved my issues too, great Job..!

    • November 18, 2009    

      Thanks should goto Kunal for composing it :-)

  1. Proj3ct » Blog Archive » Créer son propre repository Yum on November 7, 2010 at 10:46 pm

Leave a Reply