Issue
Looking for someone to just clarify the %install
macro when it comes to just placing files. I created a RPM without errors that is supposed to just take files from the buildroot and cp them to /usr/lib. What I have in the SPEC file for the %install is the following, and based on this post. I though that would be enough for the rpm to copy the files from the buildroot to the /usr/lib location.
This is what I tried and it builds:
%install
mkdir -p %{buildroot}/usr/lib
install -d %{buildroot}/usr/lib/
Rethinking, I figure, well lets tell the rpm where I want to copy the files. SO I tried this:
%install
mkdir -p %{buildroot}/usr/lib
cp %{buildroot}/usr/lib/ /usr/lib/
well that complains about the /usr/lib/ location not being writable by the user I am creating the rpm as on the build machine. Which my impression is that %install
section of the spec file should be instructions on where the files should be copied to when the rpm is installed on the destination server. I don't want it looking at the local files system for the rpm build server. My though behind this is, the RPM should build, but it shouldn't fail until the rpm install if I try to install the rpm as a non-privileged user. It shouldn't care during the build. I'm merely trying to cp/extract some lib files to the /usr/lib on the server I install the rpm on.
My assumption is, the rpm would create the BUILDROOT location on the server I'm installing the rpm on, then cp the contents from the buildroot location to the mentioned destination location.
Solution
%install
section is executed on your machine during buildtime of your package. In this section you should create the file structure in %{buildroot}
. It is not your task to copy it final destination on client machine.
So you should do something like:
%install
mkdir -p %{buildroot}/usr/lib
cp -a some-your-file-from-extracted-targz %{buildroot}/usr/lib/
and then in %files section:
%files
/usr/lib/foobar.bin
/usr/lib/somedir/
Rpm will then takes all listed files in %files
section from %buildroot and will put it in package.
Answered By - msuchy Answer Checked By - Mary Flores (WPSolving Volunteer)