Create local repository with all dependencies from rpm

6,527

Solution 1

yum install yum-utils to get some useful package management utilities. repotrack package will download all dependencies. Put this in a directory and run createrepo /srv/my/repo This is a repository you can add to the closed system's /etc/yum.repos.d/ with a file URI:

   [myrepo]
   name = This is my repo
   baseurl = file:///srv/my/repo/

You also need a system for updates anyway. Download updates on an Internet connected system and put them in a repo in the same way. (Updates could be sourced with a management product like Satellite but do not have to be.)

yumdownloader vs repotrack

http://yum.baseurl.org/wiki/RepoCreate

Solution 2

I had the same requirement but I wasn't able to get 100% of the info I needed to do this from these answers. I hope this is helpful to someone.

These commands must be run on the source machine, which has an internet connection.

yum install -y createrepo

# Add a local temporary directory
mkdir packages

# Download whatever packages you need to the temporary directory
yum install --downloadonly --downloaddir=packages perl

# Now, create the repository. If you need to add more packages, be sure to execute this
# command again before you bundle it up
createrepo packages

# Compress the packages directory:
tar -zcf packages.tgz packages

Now, transfer this to your destination machine, which does not have an internet connection and decompress the archive:

tar -zxf packages.tgz -C /opt/

Create /etc/yum.repos.d/local.repo and add these contents:

[local]
name=Local Repository
baseurl=file:///opt/packages
enabled=1
gpgcheck=1
protect=1

If you're updating the packages bundle, you will need to clean the cache first, or your new packages won't be found:

yum clean all

You can now install your desired package without an internet connection:

yum --disablerepo='*' --enablerepo=local install perl

The gpgcheck parameter is quite important, it means that you check that the packages weren't changed since leaving your source machine as they're signed by Red Hat's key. This is generally good enough for most infosec teams.

Share:
6,527
Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I have a custom rpm given to me by a vendor that has dependencies that are pulled when installed. I need to install this package on a closed network system, so I cannot access the internet to gather the dependencies. I can however access a intermediate server that can access the internet but will not allow traffic from the closed network though.

    Is it possible to create a local network repository the closed network can access to install this package? I have already created a repo in my local directory using:

    createrepo .
    

    I have also tried to get a list of the dependencies using:

    rpm -qpR *package*
    

    How would I go about pulling the rpms or other installation data from the dependencies list into the local repo?

  • dortegaoh
    dortegaoh over 6 years
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.