Reputation: 4296
I have a pre-made directory structure that I want to make an rpm from. In my spec file I specify all files from that directory structure that I want to include in the rpm, and when executing rpmbuild I set the buildroot to the (from what I can tell) correct directory:
%files
/usr/local/bin/test/Test
/usr/local/bin/test/something.awk
/usr/share/snmp/mibs
/etc/init.d/test
My rpmbuild command looks like this:
rpmbuild --rmspec --buildroot=bin/<files dir> -bb bin/tmp.spec
Both the buildroot directory & location of my spec file are relative. The directory structure looks like this:
/home/<me>/Projects/<project>/ <-- I execute rpmbuild from here
/home/<me>/Projects/<project>/bin/tmp.spec
/home/<me>/Projects/<project>/bin/<files dir>/ <-- All files/directories mentioned in spec file reside here
/home/<me>/Projects/<project>/bin/<files dir>/usr/local/bin/test/Test
/home/<me>/Projects/<project>/bin/<files dir>/usr/local/bin/test/something.awk
/home/<me>/Projects/<project>/bin/<files dir>/usr/share/snmp/mibs/ <-- directory with a few MIB files, which I all want to include
/home/<me>/Projects/<project>/bin/<files dir>/etc/init.d/test
However, when executing the rpmbuild command I get the following errors:
Processing files: <rpm>
error: File not found: /bin/<files dir>/usr/local/bin/test/Test
error: File not found: /bin/<files dir>/usr/local/bin/test/something.awk
error: File not found: /bin/<files dir>/usr/share/snmp/mibs
error: File not found: /bin/<files dir>/etc/init.d/test
RPM build errors:
File not found: /bin/<files dir>/usr/local/bin/test/Test
File not found: /bin/<files dir>/usr/local/bin/test/something.awk
File not found: /bin/<files dir>/usr/share/snmp/mibs
File not found: /bin/<files dir>/etc/init.d/test
The spec file does not contain any %prep, %build or %install directives, as the complete file structure is pre-made before building the rpm file. I am convinced it is some small thing that I am missing, and I suspect that it is a case of rpmbuild using a different directory than I am specifying. I've been toying around with the buildroot & _topdir directives, both with relative & absolute paths, but to no avail...
Upvotes: 0
Views: 4760
Reputation: 5417
It seems to me that you are confused by semantics of buildroot. The --buildroot
option and %{buildroot}
macro points to build root. Let me elaborate more:
In the %install
section you are located in directory where your sources have been extracted (this has been done by %setup
macro in %prep
section). Now you are should create the file/directory structure in the build root. So:
%install
install -d %{buildroot}/usr/local/bin/test/
cp -a something.awk %{buildroot}/usr/local/bin/test/
This assume that something.awk
was in in tar.gz file of Source0 and it was in root of that archive (there was no leading paths in that archive).
%buildroot
is always defined. And usually is in form of ~/rpmbuild/BUILDROOT/%{name}-%{version}-%{release}.$arch
. When you override it with --buildroot=bin/<files dir>
option as in your example, then the previous script in %install
will copy the something.awk into 'bin//usr/local/bin/test/something.awk'. Which is not error per se, but does not have sense too.If you previously copied the files into your ./bin directory, then you should know that %{buildroot}
is usually wiped before %install
section. So you have to copy those files into '%{buildroot}' in this section.
So what was the cause of the error? When you stated:
%files
/usr/local/bin/test/something.awk
Then rpmbuild looks for file %{buildroot}/usr/local/bin/test/something.awk
. It does not exist so rpmbuild yield "file not found". So you are obviously missing the actions in %install
section. If you add it there then it will work. And you can omit the --buildroot
option too.
Upvotes: 3