-2

Usually one rpm depends on many other packages or libs. This is not easy for massive deployment without internet access.

Since yum can automatically resolve dependencies. Is it possible to build a portable executable? So that we can copy it to other machines with the same OS.

Osiris
  • 1,007
  • 4
  • 17
  • 30

2 Answers2

2

The general way to build a binary without runtime library dependencies is to build it to be static, ie. using the -static argument to gcc, which links in static versions of the libraries required such that they're included in the resulting executable. This doesn't bundle in any data file dependencies or external executables (ie. libexec-style helpers), but simpler applications often don't need them.

For more complex needs (where data files are involved, or elements of the dependency chain can't be linked in for one reason or another), consider using AppImageKit -- which bundles an application and its dependency chain into a runnable ISO. See docs/links at PortableLinuxApps.org.


In neither of these cases does rpm or yum have anything to do with it. It's certainly possible to build an RPM that packages static executables, but that's a matter of changing the %build section of the spec file such that it passes -static to gcc, not of doing anything RPM-specific.


To be clear, by the way -- there are compelling reasons why we don't use static libraries all the time!

  • Using shared libraries means that applying a security update to a library only means replacing the library itself, not recompiling all applications using it.
  • Using shared libraries is more memory-efficient, since the single shared copy of the library in memory can be used by multiple applications.
  • Using shared libraries means your executables don't need to include full copies of all the libraries they use, making them much smaller.
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
2

If you want a known collection of RPMs to install, yum offers a downloadonly plugin. With that, you should be able to collect all the associated RPMs in one shot to install what you wanted on a disconnected machine.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39