Installing an RPM under CentOS from a local repository

The problem with the standard -Uvh install of an RPM is that it doesn’t resolve any dependencies.  For example, the iperf package from:

ftp.pbone.net iperf-2.0.5-5.3.i686.rpm

needs a boatload of other packages.  You could add the dependencies one at a time, but you’d be doing that all afternoon.  Using yum and a local repository will do the heavy lifting.

  • Create a directory for you local repository, e.g. /root/repo.
  • Put a copy of the RPM into that directory.
  • Fix the ownership and files permissions if root doesn’t own the repository directory:
    # chown -R root.root /root/repo
    
  • Install the createrepo package if not installed yet, and then run:
    # createrepo /root/repo
    # chmod -R o-w+r /root/repo
    
  • Make a repository configuration file in /etc/yum.repos.d/, e.g. /etc/yum.repos.d/my.local.repo containing:
    [local]
    name=My local repository
    baseurl=file:///root/repo
    enabled=1
    gpgcheck=0
    
  • Install the package (iperf in this case) using:
    # yum install iperf
    
  • Once the local repository is setup, you can add other RPMs to the repository directory without need to rerun the repository creation or configuration steps.
Advertisements
%d bloggers like this: