Build .rpm package with all its dependencies

package-managementrpm

I'm not sure if its the recommended approach or not, in case the user doesn't have web access, and my software requires, lets say: libgcc-4.3.0.0.rpm (for e.g), I would like to bundle this for the specific supported os (e.g: RHEL 5.10) and all of its dependencies in a single .rpm.

whats the best approach for this?

thanks,

Best Answer

It would be tricky to bundle all the dependencies into a single RPM, not least because the system you build on may have a different package composition from your target (e.g., your target has newer, or conflicted packages already installed, which you may unintentionally overwrite).

However, you could instead obtain a list of all prerequisite packages and install them all at the same time.

Assuming that you have two systems (build and target) which are the same flavour and release (e.g., making a package list on CentOS 6, for CentOS 6), try something this:

$ sudo yum install yum-utils # not necessary on the target
$ mkdir package-bundle
$ yumdownloader --destdir package-bundle `repoquery --resolve --requires $PACKAGE_NAME`
$ tar -czvf package-bundle.tar.gz package-bundle

On the target system:

$ tar -xzvf package-bundle.tar.gz
$ sudo yum install package-bundle/*.rpm

The above uses repoquery instead of relying on yumdownloader to resolve the dependencies, as yumdownloader does not appear to recursively resolve when the --resolve flag is set.

Related Topic