Reputation: 1761
I am building a custom package which for the most part has a couple of dependencies and install my own files and scripts. I have those files in a tar
file and after attempting the build I can see those files unpacked in the rpmbuild/BUILD
directory. However there seems to be a problem with the %files
directive as any file within is listed as error: File not found
. The relevant section of my spec
file looks like this:
%prep
%setup
%install
mkdir -p %{buildroot}/etc/collectd/
mkdir -p %{buildroot}/usr/bin/
mkdir -p %{buildroot}/usr/bin/collectd.conf.d/
install -m 777 collectd.conf.custom %{_builddir}/%{name}-%{version}/etc/collectd/
# list files owned by the package here
%files
%defattr(-,root,root)
%config /etc/collectd.conf.custom
%config /etc/collectd.d/http.conf
%config /etc/collectd.d/csv.conf
/usr/local/bin/my-plugin.py
/usr/local/bin/my-script
Like I said these files unpack to /BUILD
but the builder fails in the %install
directive after it executes the three mkdir
statements. I am only trying to install one of the files in the above script so I can more easily tell that it succeeded. I consistently get the following error no matter what I try:
+ install -m 777 collectd.conf.turbine /home/vagrant/rpmbuild/BUILD/my-package-1.1/etc/collectd/
install: cannot stat `collectd.conf.custom': No such file or directory
This file is in this directory as I checked using ls
but for some reason I keep getting this error.
EDIT:
My %.spec
file is as follows:
Summary: my-package Collectd
Name: my-package-collectd
Version: 1.1
Release: Public
Group: Applications/System
License: Public
Requires: collectd
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}
Source: %{name}-%{version}.tar.gz
%prep
%setup
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/etc/collectd/
mkdir -p %{buildroot}/etc/collectd/collectd.conf.d/
mkdir -p %{buildroot}/usr/bin/
install -m 777 %{_builddir}/%{name}-%{version}/etc/collectd/collectd.conf.custom %{buildroot}/etc/collectd/
install -m 777 %{_builddir}/%{name}-%{version}/etc/collectd/collectd.conf.d/csv.conf %{buildroot}/etc/collectd/collectd.conf.d/
install -m 777 %{_builddir}/%{name}-%{version}/etc/collectd/collectd.conf.d/http.conf %{buildroot}/etc/collectd/collectd.conf.d/
# list files owned by the package here
%files
%defattr(-,root,root)
%config /etc/collectd.conf.my-package
%config /etc/collectd.d/http.conf
%config /etc/collectd.d/csv.conf
/usr/local/bin/cloudhealth.py
/usr/local/bin/my-package-collectd
Upvotes: 0
Views: 3121
Reputation: 80921
The way building an RPM works is that the %prep
section (and often just the %setup
macro) unpacks any source files into the build directory.
Then the %build
section performs any compilation, etc. in the build directory and produces the built/output files.
Then the %install
section copies the appropriate files from the build directory into their "final" locations under the %{buildroot}
.
Then the %files
section paths are matched against the files in the %{buildroot}
and packaged into the RPM.
The %install
section in your spec file is not doing that correctly.
Upvotes: 2