I am trying to install some config files using an rpm package and am having trouble with the final build step. I have tried using a lot of different variable combinations but I keep getting file not found errors. It appears to be a problem with where rpmbuild is unpacking (or not unpacking) files and where it anticipates those files. Right now I have a spec file that looks like this:
Summary: My Package
Name: my-package
Version: 1.1
Release: Public
Group: Applications/System
License: Public
Requires: collectd
Source: sources.tar.gz
%prep
%setup
%install
mkdir -p %{buildroot}/etc/collectd/
mkdir -p %{buildroot}/etc/collectd/collectd.conf.d/
mkdir -p %{buildroot}/usr/bin/
# list files owned by the package here
%files
%defattr(-,root,root)
%config /etc/collectd/collectd.conf.custom
%config /etc/collectd/collectd.d/http.conf
%config /etc/collectd/collectd.d/csv.conf
/usr/local/bin/myfile.py
/usr/local/bin/my-package
%post
ln -sf /etc/collectd.conf.custom /etc/collectd.conf
I currently get output which looks like this:
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.m5Qvz9
+ umask 022
+ cd ./BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /BUILD
/var/tmp/rpm-tmp.m5Qvz9: line 31: cd: /BUILD: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.m5Qvz9 (%prep)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.m5Qvz9 (%prep)
I'm not sure why it is trying to cd into the /BUILD directory twice.
If I leave out the %setup line I get the following output:
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.3c5as7
+ umask 022
+ cd ./BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.FAF3wq
+ umask 022
+ cd ./BUILD
+ '[' ./BUILDROOT/my-package-1.1-Public.x86_64 '!=' / ']'
+ rm -rf ./BUILDROOT/my-package-1.1-Public.x86_64
++ dirname ./BUILDROOT/my-package-1.1-Public.x86_64
+ mkdir -p ./BUILDROOT
+ mkdir ./BUILDROOT/my-package-1.1-Public.x86_64
+ LANG=C
+ export LANG
+ unset DISPLAY
+ mkdir -p ./BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd/
+ mkdir -p ./BUILDROOT/my-package-1.1-Public.x86_64/usr/bin/
+ mkdir -p ./BUILDROOT/my-package-1.1-Public.x86_64/usr/bin/collectd.conf.d/
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: my-package-1.1-Public.x86_64
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.conf.custom
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.d/http.conf
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.d/csv.conf
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/usr/local/bin/myfile.py
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/usr/local/bin/my-package
RPM build errors:
File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.conf.custom
File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.d/http.conf
File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.d/csv.conf
File not found: /BUILDROOT/my-package-1.1-Public.x86_64/usr/local/bin/myfile.py
File not found: /BUILDROOT/my-package-1.1-Public.x86_64/usr/local/bin/my-package
Which I would expect after remove %setup as it no longer unpacks the source. Any help appreciated.