RE: [opensuse-buildservice] Build C++ Files for different distributions
Okay, so what I achieved/understood so far is this: What Open Build Service does is extract my helloWorld-1.tar.gz After that we have a folder helloWorld-1 in our working directory. After which we change into that directory. Afterwards my build command "g++ -o helloWorldBin helloWorld.cpp" is executed, so I have a binary called "helloWorldBin" in my helloWorld-1 folder. As you said I now need to copy this binary into the" $RPM_BUILDROOT%{_bindir}" -Folder in the install section and add this file to the files section. Did I miss anything? If not, why can´t I just add the binary to the files Section? Because I just have one .cpp file and no make file I can´t execute any make commands like all of the examples I found., I tried to do the following: --- Name: helloWorld Version: 1 Release: 0 License: GPL-2.0+ Summary: helloWorld Url: http://www.qosmotec.com Group: Other Source: helloWorld-1.tar.gz BuildRequires: gcc-c++ cmake BuildRoot: %{_tmppath}/helloWorld %description %prep %setup -q %build g++ -o helloWorldBin helloWorld.cpp %install cp helloWorldBin $RPM_BUILDROOT%{_bindir}/hello_world_1 %post %postun %files %defattr(-,root,root) $RPM_BUILDROOT%{_bindir}/hello_world_1 ------ I get the following error: cp: cannot create regular file `/usr/bin/hello_world_1': Permission denied Somehow the spec guideline isn´t helping me much (https://en.opensuse.org/openSUSE:Specfile_guidelines) Excuse me for asking again and thank you very much for your help! Tobias N�����r��y隊Z)z{.���Wlz��qﮞ˛���m�)z{.��+�:�{Zr�az�'z��j)h���Ǜ�)]���Ǿ� ޮ�^�ˬz��
Am Mittwoch, 26. November 2014, 10:27:05 schrieb Tobias Lauterbach:
Okay, so what I achieved/understood so far is this: What Open Build Service does is extract my helloWorld-1.tar.gz After that we have a folder helloWorld-1 in our working directory. After which we change into that directory. Afterwards my build command "g++ -o helloWorldBin helloWorld.cpp" is executed, so I have a binary called "helloWorldBin" in my helloWorld-1 folder.
As you said I now need to copy this binary into the" $RPM_BUILDROOT%{_bindir}" -Folder in the install section and add this file to the files section. Did I miss anything? If not, why can´t I just add the binary to the files Section?
As far as I understand it, because when the binary rpm is created, it gets filled with the buildroot's content, which is a sort of mirror of the final installation at a writable location.
Because I just have one .cpp file and no make file I can´t execute any make commands like all of the examples I found., I tried to do the following: --- Name: helloWorld Version: 1 Release: 0 License: GPL-2.0+ Summary: helloWorld Url: http://www.qosmotec.com Group: Other Source: helloWorld-1.tar.gz BuildRequires: gcc-c++ cmake BuildRoot: %{_tmppath}/helloWorld
%description
%prep %setup -q
%build g++ -o helloWorldBin helloWorld.cpp
%install cp helloWorldBin $RPM_BUILDROOT%{_bindir}/hello_world_1
%post
%postun
%files %defattr(-,root,root) $RPM_BUILDROOT%{_bindir}/hello_world_1
------
I get the following error: cp: cannot create regular file `/usr/bin/hello_world_1': Permission denied
This is partially my fault ;) In my previous mail I wrote off the top of my head and made a mistake: the buildroot variable is $RPM_BUILD_ROOT, not $RPM_BUILDROOT. So if you read the buildlog carefully you'll see that $RPM_BUILDROOT expands to nothing and it tries to copy the binary to /usr/bin - where you don't have the permissions. So once you replace it, it should work, but as I said, in %files you have to put %{_bindir}/hello_world_1 (without the buildroot) as it specifies the final location.
Somehow the spec guideline isn´t helping me much (https://en.opensuse.org/openSUSE:Specfile_guidelines)
Excuse me for asking again and thank you very much for your help! Tobias N�����r��y隊Z)z{.����Wlz��qﮞ˛���m�)z{.��+�:�{Zr�az�'z��j)h����Ǜ�)]����Ǿ� ޮ�^�ˬz��
Edgar -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-buildservice+owner@opensuse.org
On Wed, Nov 26, Tobias Lauterbach wrote:
As you said I now need to copy this binary into the" $RPM_BUILDROOT%{_bindir}" -Folder in the install section and add this file to the files section. Did I miss anything? If not, why can´t I just add the binary to the files Section?
Because the file is not in the "final place" below the "offset".
%install cp helloWorldBin $RPM_BUILDROOT%{_bindir}/hello_world_1
RPM_BUILD_ROOT is initially empty. mkdir -vp $RPM_BUILD_ROOT%{_bindir}
%files %defattr(-,root,root) $RPM_BUILDROOT%{_bindir}/hello_world_1
Use either %{_bindir}/hello_world_1 or a wildcard %{_bindir}/* to package everything which was previously populated into $RPM_BUILD_ROOT. There are various docs about rpm spec files. An old one is this: http://www.rpm.org/max-rpm/ http://www.aepfle.de/software/maximum-rpm.ps.gz Olaf -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-buildservice+owner@opensuse.org
On Wed, Nov 26, 2014 at 5:27 AM, Tobias Lauterbach <tol@qosmotec.com> wrote:
%install cp helloWorldBin $RPM_BUILDROOT%{_bindir}/hello_world_1
In addition to the other comments, I always use "install", not "cp". This is from the tripwire spec file: install -m 700 bin/* $RPM_BUILD_ROOT/usr/sbin If you run it through spec-cleaner, it becomes: install -m 700 bin/* %{buildroot}%{_prefix}/sbin I try to run most of my spec files through spec-cleaner before I submit them to a devel project. Greg Greg -- Greg Freemyer -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-buildservice+owner@opensuse.org
participants (4)
-
Edgar Aichinger
-
Greg Freemyer
-
Olaf Hering
-
Tobias Lauterbach