Issue
And thank you very much to everyone who responded :)
I have no experience building rpm packages with such requirements
For several days now, I can’t defeat the task of packing a static website (AngularJS) by a web server in one rpm package. That it would be possible to install and receive a ready site on any rhel/centos server.
What did I do.
- Install all needed tools for creating rpmbuild and create non-root user for this action
- rpmdev-setuptree && rpm -Uvh http://nginx.org/packages/centos/7/SRPMS/nginx-1.16.1-1.el7.ngx.src.rpm
- copy my website folder to SOURCE
- edit rpmbuild/SPECS/nginx.spec
- add Source14: website
- add to section %install, after
%{__mkdir} -p $RPM_BUILD_ROOT%{_datadir}/nginx
%{__mv} $RPM_BUILD_ROOT%{_sysconfdir}/nginx/html $RPM_BUILD_ROOT%{_datadir}/nginx/
I tried use
cp -r -f %{SOURCE14}/*.* $RPM_BUILD_ROOT%{_datadir}/nginx/html/
and
%{__install} -D -pm 755 %{SOURCE14}/*.* $RPM_BUILD_ROOT%{_datadir}/nginx/html/
But after rpmbuild -bb nginx.spec
I didn`t have any changes in rpmbuild/BUILD/nginx-1.16.1/html/ folder, it contains only index.html and 50x.html
Pls help me with resolve this task. Where in the spec file I need add my website copy step? What the best way to modify Nginx default.conf? Because I need to add support AngularJS (add servername, HTTP to https rewrite allow some type of fonts and etc)
Solution
- You should create a tarball from your website folder. Here is relevant documentation https://rpm-packaging-guide.github.io/#preparing-source-code-for-packaging
- Then you need to alter
%prep
section. Which will be tricky if you want to keep the Source0 of original nginx. The documentation is here: https://rikers.org/rpmbook/node70.html#SECTION03541000000000000000 See section "Using %setup in a Multi-source Spec File"
Instead of modifying existing nginx spec file, I would suggest you to create new spec file from scratch. Read through existing documentation like:
- https://rpm-packaging-guide.github.io/
- https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages/index.html
- https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html-single/RPM_Guide/index.html
Back to the core of your issue.
When you do:
Source14: website
then rpmbuild will include only the directory - or should, I actually never tried it, every case and source code assume only one filename there. The wildcards do not work there. Therefore later cp -r -f %{SOURCE14}/*.*
does not match anything, because it expands to cp -r -f website/*.*
but the folder is actually empty.
If you try to do:
Source14: website/foo
Source15: website/bar/foo
then it will 1) be hell of manual work 2) not work, because SourceX takes only the basename and expect it to be present in rpmbuild/SOURCES/ - and obviously you will have collision sooner or later. Therefore you want to tarball your work.
Answered By - msuchy Answer Checked By - Mildred Charles (WPSolving Admin)