Tuesday, August 30, 2022

[SOLVED] Specify installdir/builddir with RPM

Issue

I am relatively new to building and distributing packages with RPM.

I am trying to achieve the following functionality, and I am a bit confused about how to manage that:

  1. On the build machine, the RPM package should be build under my account, e.g. under /home/username/rpmbuild. This folder has the proper structure (e.g. contains SPECS, RPMS, SOURCES etc). The file I want to package is basically the binaries of a .tgz file located at the SOURCES directory. I also have root access, so that shouldn't be a problem.
  2. On the ''client'' machines, software should be installed under a specific directory, e.g. /specific_mountpoint/program_name. This should happen even if the users should execute a simple rpm -ivh rpm_name.rpm command without additional parameters.

I have the following questions:

  • My current understanding of the RPM process is that the build machine must mirror the client machine during the rpmbuild process. If that is correct, then I must have /specific_mountpoint/program_name created through the rpmbuild process at the build machine, right? Does this mean that I must copy files from RPM_BUILD_ROOT to that directory or is there a way to override RPM_BUILD_ROOT inside the spec file?
  • My problem then is that under %files in the spec file, I cannot seem to be able to point rpmbuild to take the files from /specific_mountpoint/program_name (as it currently goes to the /home/username/rpmbuild/BUILDROOT folder). I have tried overriding this behavior to no success.

Any ideas and concrete spec files are more than welcome.

I am using RPM v4.8. I am mentioning this since specific flags have been deprecated from what I am reading.

Many thanks!


Solution

No, you are close but slightly off. What you build in buildroot is the equivalent to the root on the target machine. So have your stuff in /home/username/rpmbuild/BUILDROOT/packagename-version/specific_mountpoint/program_name AKA %{buildroot}/specific_mountpoint/program_name. Then in %files you list the destination location, e.g. %doc /specific_mountpoint/program_name/README.



Answered By - Aaron D. Marasco
Answer Checked By - Cary Denson (WPSolving Admin)