# distribution specific definitions %define use_systemd (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} == 1315) %define bdir %{_builddir}/%{name}-%{version}-1 %define goroot %(go env GOROOT) %define goos %(go env GOOS) %define goarch %(go env GOARCH) %define dotests 0 %if ( 0%{?rhel} == 5 || 0%{?rhel} == 6 ) Requires: initscripts >= 8.36 %endif %if 0%{?rhel} == 7 Requires: systemd BuildRequires: systemd-units %define dist .el7 %endif %if 0%{?suse_version} == 1315 BuildRequires: systemd Requires: systemd %endif Name: unit Summary: NGINX Unit Version: 0.1 Release: 1%{?dist}.ngx License: ASL 2.0 Vendor: Nginx Software, Inc. URL: https://www.nginx.com/ Packager: Nginx Software, Inc. Group: System Environment/Daemons Source0: unit-%{version}-1.tar.gz Source1: unitd.service Source2: unitd.init Source3: unitd.sysconf Source4: unit.dumpconfig.sh Source5: unit.restoreconfig.sh Source6: unit.example.config Source7: unit.example-php-app Source8: unit.example-python-app Source9: unit.example-go-app BuildRequires: python-devel BuildRequires: php-devel, php-embedded BuildRequires: golang BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description NGINX Unit is a runtime and delivery environment for modern distributed applications. It runs the application code in multiple languages (PHP, Python, Go, etc.), and tightly couples it with traffic delivery in and out of the application. Take this application server and proxy directly in the cloud / container environments and fully control your app dynamically via an API. %if 0%{?suse_version} %debug_package %endif %package -n unit-devel Summary: %{summary} (development tools) %description -n unit-devel Development tools for NGINX Unit. %prep %setup -q -n unit-%{version}-1 %build CFLAGS="-O0" ./configure \ --prefix=/usr \ --modules=%{_libdir}/unit/modules \ --control="unix:/var/run/control.unit.sock" \ --pid=/var/run/unitd.pid \ --log=/var/log/unitd.log \ --debug \ --tests ./configure python ./configure php ./configure go --go-path=%{goroot} %{__make} %{?_smp_mflags} %{__make} python %{__make} php %{__make} go %install %{__rm} -rf %{buildroot} DESTDIR=%{buildroot} make unitd-install DESTDIR=%{buildroot} make python-install DESTDIR=%{buildroot} make php-install DESTDIR=%{buildroot} make go-install %{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig %{__install} -m 644 -p %{SOURCE3} \ %{buildroot}%{_sysconfdir}/sysconfig/unitd %{__mkdir} -p %{buildroot}%{_sysconfdir}/unit %{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples %{__install} -m 644 -p %{SOURCE6} \ %{buildroot}%{_datadir}/doc/unit/examples/example.config %{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples/php-app %{__install} -m 644 -p %{SOURCE7} \ %{buildroot}%{_datadir}/doc/unit/examples/php-app/index.php %{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples/python-app %{__install} -m 644 -p %{SOURCE8} \ %{buildroot}%{_datadir}/doc/unit/examples/python-app/wsgi.py %{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples/go-app %{__install} -m 644 -p %{SOURCE9} \ %{buildroot}%{_datadir}/doc/unit/examples/go-app/let-my-people.go %{__install} -m 644 -p CHANGES \ %{buildroot}%{_datadir}/doc/unit/ %{__install} -m 644 -p NOTICE \ %{buildroot}%{_datadir}/doc/unit/COPYRIGHT %{__install} -m 644 -p README.md \ %{buildroot}%{_datadir}/doc/unit/ # init scripts %if %{use_systemd} %{__rm} -rf %{buildroot}%{_initrddir}/ %{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unitd.service %{__mkdir} -p %{buildroot}%{_libexecdir}/initscripts/legacy-actions/unitd %{__install} -m755 %SOURCE4 \ %{buildroot}%{_libexecdir}/initscripts/legacy-actions/unitd/dumpconfig %{__install} -m755 %SOURCE5 \ %{buildroot}%{_libexecdir}/initscripts/legacy-actions/unitd/restoreconfig %else %{__mkdir} -p %{buildroot}%{_initrddir} %{__install} -p -D -m 0755 %{SOURCE2} %{buildroot}%{_initrddir}/unitd %endif QA_SKIP_BUILD_ROOT=1 export QA_SKIP_BUILD_ROOT %check %if %{dotests} cd %{bdir} && make tests && ./build/tests %endif %clean %{__rm} -rf %{buildroot} %post if [ $1 -eq 1 ]; then %if %{use_systemd} /usr/bin/systemctl preset unitd.service >/dev/null 2>&1 ||: %else /sbin/chkconfig --add unitd %endif cat </dev/null 2>&1 ||: /usr/bin/systemctl stop unitd.service >/dev/null 2>&1 ||: %else /sbin/service unitd stop >/dev/null 2>&1 /sbin/chkconfig --del unitd %endif fi %postun %if %{use_systemd} /usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||: %endif if [ $1 -ge 1 ]; then %if %{use_systemd} /usr/bin/systemctl try-restart unitd.service >/dev/null 2>&1 ||: %else /sbin/service unitd condrestart >/dev/null 2>&1 ||: %endif fi %files %defattr(-,root,root,-) %attr(0755,root,root) %{_sbindir}/unitd %config(noreplace) %{_sysconfdir}/sysconfig/unitd %dir %{_sysconfdir}/unit %if %{use_systemd} %{_unitdir}/unitd.service %dir %{_libexecdir}/initscripts/legacy-actions/unitd %{_libexecdir}/initscripts/legacy-actions/unitd/* %else %{_initrddir}/unitd %endif %dir %{_datadir}/doc/unit %{_datadir}/doc/unit/* %dir %{_libdir}/unit/modules %{_libdir}/unit/modules/* %files -n unit-devel %dir %{goroot}/src/unit %{goroot}/src/unit/* %{goroot}/pkg/%{goos}_%{goarch}/unit.a %changelog * Wed Sep 6 2017 Andrei Belov - 0.1-1%{?dist}.ngx - First public release.