From 8a254710b6c3496dee08c23e83a45f3d111fda90 Mon Sep 17 00:00:00 2001 From: Justin Zhang Date: Tue, 22 Apr 2014 03:52:46 +0200 Subject: [PATCH 1/7] Add spec file to build RPM This commit also fixes the Makefile.in to have correct install destination directory set. --- Makefile.in | 4 ++-- fcgiwrap.spec | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 fcgiwrap.spec diff --git a/Makefile.in b/Makefile.in index 97378e5..e6ad58f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ -targetdir = $(DESTDIR)@prefix@@sbindir@ -man8dir = $(DESTDIR)@prefix@@mandir@/man8 +targetdir = $(DESTDIR)@sbindir@ +man8dir = $(DESTDIR)@mandir@/man8 datarootdir = .PHONY: clean distclean diff --git a/fcgiwrap.spec b/fcgiwrap.spec new file mode 100644 index 0000000..b260dc6 --- /dev/null +++ b/fcgiwrap.spec @@ -0,0 +1,53 @@ +Name: fcgiwrap +Version: 1.1 +Release: 1%{?dist} +Summary: Simple FastCGI wrapper for CGI scripts + +Group: System Environment/Daemons +License: BSD +URL: http://nginx.localdomain.pl/wiki/FcgiWrap +Source0: fcgiwrap-1.1.tar.gz + +BuildRequires: autoconf fcgi-devel +Requires: fcgi + +%description +Simple FastCGI wrapper for CGI scripts w/ following features: + - very lightweight (84KB of private memory per instance) + - fixes broken CR/LF in headers + - handles environment in a sane way (CGI scripts get HTTP-related env. vars + from FastCGI parameters and inherit all the others from ``fcgiwrap``'s + environment) + - no configuration, so you can run several sites off the same ``fcgiwrap`` + pool + - passes CGI stderr output to ``fcgiwrap``'s stderr or FastCGI stderr stream + + +%prep +%setup -q + + +%build +autoreconf -i +%configure +make %{?_smp_mflags} + + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} + + +%clean +rm -rf %{buildroot} + + +%files +%defattr(-,root,root,-) +%{_sbindir}/fcgiwrap +#TODO: figure out why the manpage file is compressed automatically +%doc %{_mandir}/man8/fcgiwrap.8.gz + + +%changelog + From a51a5a558a26e1aa38b97b2c10d319d83859cc08 Mon Sep 17 00:00:00 2001 From: Justin Zhang Date: Wed, 23 Apr 2014 13:28:19 +0800 Subject: [PATCH 2/7] Detect systemd in spec file in the same way as autoconf --- fcgiwrap.spec | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/fcgiwrap.spec b/fcgiwrap.spec index b260dc6..641aced 100644 --- a/fcgiwrap.spec +++ b/fcgiwrap.spec @@ -1,35 +1,40 @@ +%define systemd_test_str %(pkg-config --print-errors libsystemd-daemon 2>&1) +%if "%{systemd_test_str}" == "" + %define with_systemd 1 +%endif + Name: fcgiwrap -Version: 1.1 +Version: 1.1.0 Release: 1%{?dist} Summary: Simple FastCGI wrapper for CGI scripts - Group: System Environment/Daemons -License: BSD +License: BSD-like URL: http://nginx.localdomain.pl/wiki/FcgiWrap -Source0: fcgiwrap-1.1.tar.gz - -BuildRequires: autoconf fcgi-devel +Source0: %{name}-%{version}.tgz +BuildRequires: autoconf automake fcgi-devel pkgconfig +%{?with_systemd:BuildRequires: systemd-devel systemd} Requires: fcgi %description -Simple FastCGI wrapper for CGI scripts w/ following features: +This package provides a simple FastCGI wrapper for CGI scripts with/ +following features: - very lightweight (84KB of private memory per instance) - fixes broken CR/LF in headers - - handles environment in a sane way (CGI scripts get HTTP-related env. vars - from FastCGI parameters and inherit all the others from ``fcgiwrap``'s - environment) - - no configuration, so you can run several sites off the same ``fcgiwrap`` - pool - - passes CGI stderr output to ``fcgiwrap``'s stderr or FastCGI stderr stream + - handles environment in a sane way (CGI scripts get HTTP-related env. + vars from FastCGI parameters and inherit all the others from + environment of fcgiwrap ) + - no configuration, so you can run several sites off the same + fcgiwrap pool + - passes CGI stderr output to stderr stream of cgiwrap or FastCGI %prep %setup -q - %build autoreconf -i %configure + make %{?_smp_mflags} @@ -47,7 +52,12 @@ rm -rf %{buildroot} %{_sbindir}/fcgiwrap #TODO: figure out why the manpage file is compressed automatically %doc %{_mandir}/man8/fcgiwrap.8.gz - +%if %{with_systemd} +%{_unitdir}/*.service +%{_unitdir}/*.socket +%endif %changelog - +* Tue Apr 22 2014 Justin Zhang - 1.1.0-1 +- version 1.1.0 +- First spec file for the fcgiwrap From ce6a101d2eb86fe15a27940c1bb65be26888eb48 Mon Sep 17 00:00:00 2001 From: Justin Zhang Date: Wed, 23 Apr 2014 09:09:47 +0200 Subject: [PATCH 3/7] Fix macro expression to check systemd presence --- fcgiwrap.spec | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fcgiwrap.spec b/fcgiwrap.spec index 641aced..b00d05f 100644 --- a/fcgiwrap.spec +++ b/fcgiwrap.spec @@ -1,5 +1,5 @@ -%define systemd_test_str %(pkg-config --print-errors libsystemd-daemon 2>&1) -%if "%{systemd_test_str}" == "" +%define systemd_test_str %(test -z '$(pkg-config --print-errors libsystemd-daemon 2>&1 |grep "No package")' && echo "yes" || echo "no") +%if "%{systemd_test_str}" == "yes" %define with_systemd 1 %endif @@ -52,11 +52,10 @@ rm -rf %{buildroot} %{_sbindir}/fcgiwrap #TODO: figure out why the manpage file is compressed automatically %doc %{_mandir}/man8/fcgiwrap.8.gz -%if %{with_systemd} -%{_unitdir}/*.service -%{_unitdir}/*.socket -%endif - +%{?with_systemd: + %{_unitdir}/*.service + %{_unitdir}/*.socket +} %changelog * Tue Apr 22 2014 Justin Zhang - 1.1.0-1 - version 1.1.0 From 3d74f67f96621322cf89b61751115976faaa8632 Mon Sep 17 00:00:00 2001 From: Justin Zhang Date: Wed, 23 Apr 2014 15:41:25 +0800 Subject: [PATCH 4/7] Fix bash scriplet to check systemd presence --- fcgiwrap.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fcgiwrap.spec b/fcgiwrap.spec index b00d05f..37463e3 100644 --- a/fcgiwrap.spec +++ b/fcgiwrap.spec @@ -1,4 +1,10 @@ -%define systemd_test_str %(test -z '$(pkg-config --print-errors libsystemd-daemon 2>&1 |grep "No package")' && echo "yes" || echo "no") +%define systemd_test_str %( +if [[ -z $(pkg-config --print-errors libsystemd-daemon 2>&1) ]]; then + echo "yes" +else + echo "no" +fi +) %if "%{systemd_test_str}" == "yes" %define with_systemd 1 %endif From 81e1616b1d4bdf12b72cb5d9619e9f1da0a6b9f3 Mon Sep 17 00:00:00 2001 From: Justin Zhang Date: Wed, 23 Apr 2014 23:26:25 +0800 Subject: [PATCH 5/7] Add rpm build instructions to README.rst --- README.rst | 65 +++++++++++++++++++++++++++++++++++++++++++++++---- fcgiwrap.spec | 30 ++++++++++++++++++++++-- 2 files changed, 88 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 4686c34..185e058 100644 --- a/README.rst +++ b/README.rst @@ -6,6 +6,7 @@ fcgiwrap :Author: Grzegorz Nosek :Contributors: W-Mark Kubacki Jordi Mallach + Justin Zhang This page has been translated into `Spanish `_ language by Maria Ramos from `Webhostinghub.com/support/edu `_. @@ -17,9 +18,11 @@ Features - handles environment in a sane way (CGI scripts get HTTP-related env. vars from FastCGI parameters and inherit all the others from ``fcgiwrap``'s environment) - no configuration, so you can run several sites off the same ``fcgiwrap`` pool - passes CGI stderr output to ``fcgiwrap``'s stderr or FastCGI stderr stream + - support systemd socket activation, launcher program like spawn-fcgi + is no longer required on systemd-enabled distributions -Installation -============ +Install from source +=================== requirements ------------ @@ -41,9 +44,61 @@ To install:: *fcgiwrap* will be copied to ``/usr/local/sbin/fcgiwrap`` if you did not set ``--prefix`` for configure or ``DESTDIR`` for the makefile. -usage ------ -Most probably you will want ``fcgiwrap`` be launched by `www-servers/spawn-fcgi `_. Or you could use the author's Perl launcher - see the homepage for that. +Install from RPM package +======================== + +requirements +------------ +At the time of writing, the *fcgiwrap* RPM is not included in any public +repository. As a result, You have to build the RPM from scratch by following +the procedure below: +build the RPM package +--------------------- +To install or upgrade RPM build tools:: + + sudo yum install -y autoconf automake fcgi-devel pkgconfig rpm-build + +On systemd enabled OS, you need additional ``systemd-devel`` pacakge:: + + sudo yum install -y systemd-devel + +Then you download appropriate version of the fcgiwrap source tarball from +Github or clone this repository and build the source tarball by using this +command:: + + git archive --format tgz --prefix fcgiwrap-1.1.0/ HEAD > fcgiwrap-1.1.0.tgz + +Then you can kick off the RPM build by running:: + + rpmbuild -ta fcgiwrap-1.1.0.tgz + +and locate the result .rpm file at ~/rpmbuild/RPMS. + +install the RPM package +----------------------- +The RPM package of *fcgiwrap* include the excutable ``/usr/sbin/fcgiwrap`` +and manual page. If you build the RPM package on systemd enabled OS, the +systemd unit files are included in this package as well. To install the +package, run command like below:: + + sudo rpm -Uhv fcgiwrap-1.1.0-1.fc18.armv6hl.rpm + +The exact name of the RPM package file name depends on the OS and +hardware architecture where you build the RPM. + +Usage +===== +If you are on traditional SysV init systems, most probably you will want +``fcgiwrap`` be launched by `www-servers/spawn-fcgi +`_. Or you could use +the author's Perl launcher - see the homepage for that. On the systemd +enabled distributions like Fedora 14+, RHEL 7+, you can take advantage +of systemd socket activation feature instead of the extra launcher like +spawn-fcgi. The systemd unit files ``fcgiwrap.socket`` and +``fcgiwrap.service`` is included in the tarball release under +``systemd`` directory. You can also build the RPM package by following +the instructions aforementioned. The RPM package installs and enables +the socket activation for fcgiwrap automatically on systemd enabled OS. There are two modes of ``fcgiwrap`` operation: - when *SCRIPT_FILENAME* is set, its value is treated as the script name and executed directly. diff --git a/fcgiwrap.spec b/fcgiwrap.spec index 37463e3..f56c4ae 100644 --- a/fcgiwrap.spec +++ b/fcgiwrap.spec @@ -21,6 +21,7 @@ BuildRequires: autoconf automake fcgi-devel pkgconfig %{?with_systemd:BuildRequires: systemd-devel systemd} Requires: fcgi + %description This package provides a simple FastCGI wrapper for CGI scripts with/ following features: @@ -32,15 +33,17 @@ following features: - no configuration, so you can run several sites off the same fcgiwrap pool - passes CGI stderr output to stderr stream of cgiwrap or FastCGI + - support systemd socket activation, launcher program like spawn-fcgi + is no longer required on systemd-enabled distributions %prep %setup -q + %build autoreconf -i %configure - make %{?_smp_mflags} @@ -62,7 +65,30 @@ rm -rf %{buildroot} %{_unitdir}/*.service %{_unitdir}/*.socket } + + +%post +# enable socket activation for fcgiwrap +%{?with_systemd: + /usr/bin/systemctl enable fcgiwrap.socket + /usr/bin/systemctl start fcgiwrap.socket + + cat < - 1.1.0-1 - version 1.1.0 -- First spec file for the fcgiwrap +- Create RPM spec file for the fcgiwrap From fe3c75ff097ee9477c75198b2306ad10e3d419bb Mon Sep 17 00:00:00 2001 From: Justin Zhang Date: Wed, 23 Apr 2014 23:35:04 +0800 Subject: [PATCH 6/7] Fix systemd check code in %post and %preun --- fcgiwrap.spec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fcgiwrap.spec b/fcgiwrap.spec index f56c4ae..8fb8dd1 100644 --- a/fcgiwrap.spec +++ b/fcgiwrap.spec @@ -69,7 +69,7 @@ rm -rf %{buildroot} %post # enable socket activation for fcgiwrap -%{?with_systemd: +if [[ -z $(pkg-config --print-errors libsystemd-daemon 2>&1) ]]; then /usr/bin/systemctl enable fcgiwrap.socket /usr/bin/systemctl start fcgiwrap.socket @@ -78,14 +78,15 @@ rm -rf %{buildroot} FCGI service fcgiwrap is ready!!! ================================================== BANNER -} +fi + %preun # stop and disable socket activation for fcgiwrap -%{?with_systemd: +if [[ -z $(pkg-config --print-errors libsystemd-daemon 2>&1) ]]; then /usr/bin/systemctl stop fcgiwrap.socket /usr/bin/systemctl disable fcgiwrap.socket -} +fi %changelog From bbe0c14b3818f521db8c05513222ae3b3f4b24c8 Mon Sep 17 00:00:00 2001 From: Justin Zhang Date: Thu, 24 Apr 2014 00:08:27 +0800 Subject: [PATCH 7/7] Fix README.rst formatting issue --- README.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 185e058..23d2749 100644 --- a/README.rst +++ b/README.rst @@ -52,9 +52,10 @@ requirements At the time of writing, the *fcgiwrap* RPM is not included in any public repository. As a result, You have to build the RPM from scratch by following the procedure below: + build the RPM package --------------------- -To install or upgrade RPM build tools:: +Install required dependencies RPM build tools:: sudo yum install -y autoconf automake fcgi-devel pkgconfig rpm-build @@ -83,8 +84,8 @@ package, run command like below:: sudo rpm -Uhv fcgiwrap-1.1.0-1.fc18.armv6hl.rpm -The exact name of the RPM package file name depends on the OS and -hardware architecture where you build the RPM. +The exact name of the RPM package file depends on the OS and hardware +architecture where you build the RPM. Usage =====