[nginx/el6] Update to 1.0.13 and spec file cleanup

Jamie Nguyen jamielinux at fedoraproject.org
Wed Mar 7 23:29:39 UTC 2012


commit de56ea84c448e8417e54c6cb2e5f3a53b6fb9ef7
Author: Jamie Nguyen <jamie at tomoyolinux.co.uk>
Date:   Wed Mar 7 23:25:59 2012 +0000

    Update to 1.0.13 and spec file cleanup

 .gitignore      |    1 +
 nginx.conf      |   53 +------------
 nginx.init      |   49 +++++++-----
 nginx.logrotate |    2 +-
 nginx.spec      |  231 ++++++++++++++++++++++++++++++-------------------------
 sources         |    2 +-
 6 files changed, 161 insertions(+), 177 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 6676a0e..db83f73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ x86_64/
 *swp
 *.rpm
 /nginx-1.0.12.tar.gz
+/nginx-1.0.13.tar.gz
diff --git a/nginx.conf b/nginx.conf
index f3dc403..dc8091c 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -62,59 +62,8 @@ http {
 
     #gzip  on;
     
-    #
-    # The default server
-    #
-    server {
-        listen       80;
-        server_name  _;
-
-        #charset koi8-r;
-
-        #access_log  logs/host.access.log  main;
-
-        location / {
-            root   /usr/share/nginx/html;
-            index  index.html index.htm;
-        }
-
-        error_page  404              /404.html;
-        location = /404.html {
-            root   /usr/share/nginx/html;
-        }
-
-        # redirect server error pages to the static page /50x.html
-        #
-        error_page   500 502 503 504  /50x.html;
-        location = /50x.html {
-            root   /usr/share/nginx/html;
-        }
-
-        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
-        #
-        #location ~ \.php$ {
-        #    proxy_pass   http://127.0.0.1;
-        #}
-
-        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
-        #
-        #location ~ \.php$ {
-        #    root           html;
-        #    fastcgi_pass   127.0.0.1:9000;
-        #    fastcgi_index  index.php;
-        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
-        #    include        fastcgi_params;
-        #}
-
-        # deny access to .htaccess files, if Apache's document root
-        # concurs with nginx's one
-        #
-        #location ~ /\.ht {
-        #    deny  all;
-        #}
-    }
-
     # Load config files from the /etc/nginx/conf.d directory
+    # The default server is in conf.d/default.conf
     include /etc/nginx/conf.d/*.conf;
 
 }
diff --git a/nginx.init b/nginx.init
index 670fca5..094fc65 100644
--- a/nginx.init
+++ b/nginx.init
@@ -22,11 +22,14 @@
 nginx="/usr/sbin/nginx"
 prog=$(basename $nginx)
 
+sysconfig="/etc/sysconfig/$prog"
+lockfile="/var/lock/subsys/nginx"
+pidfile="/var/run/${prog}.pid"
+
 NGINX_CONF_FILE="/etc/nginx/nginx.conf"
 
-[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
+[ -f $sysconfig ] && . $sysconfig
 
-lockfile=/var/lock/subsys/nginx
 
 start() {
     [ -x $nginx ] || exit 5
@@ -41,7 +44,7 @@ start() {
 
 stop() {
     echo -n $"Stopping $prog: "
-    killproc $prog
+    killproc -p $pidfile $prog
     retval=$?
     echo
     [ $retval -eq 0 ] && rm -f $lockfile
@@ -49,24 +52,24 @@ stop() {
 }
 
 restart() {
-    configtest_q || configtest || return 6
+    configtest_q || return 6
     stop
     start
 }
 
 reload() {
-    configtest_q || configtest || return 6
+    configtest_q || return 6
     echo -n $"Reloading $prog: "
-    killproc $nginx -HUP
+    killproc -p $pidfile $prog -HUP
     echo
 }
 
 configtest() {
-  $nginx -t -c $NGINX_CONF_FILE
+    $nginx -t -c $NGINX_CONF_FILE
 }
 
 configtest_q() {
-    configtest >/dev/null 2>&1
+    $nginx -t -q -c $NGINX_CONF_FILE
 }
 
 rh_status() {
@@ -79,27 +82,35 @@ rh_status_q() {
 
 # Upgrade the binary with no downtime.
 upgrade() {
-    local pidfile="/var/run/${prog}.pid"
     local oldbin_pidfile="${pidfile}.oldbin"
 
-    configtest_q || configtest || return 6
-    echo -n $"Staring new master $prog: "
-    killproc $nginx -USR2
+    configtest_q || return 6
+    echo -n $"Upgrading $prog: "
+    killproc -p $pidfile $prog -USR2
     retval=$?
-    echo 
     sleep 1
     if [[ -f ${oldbin_pidfile} && -f ${pidfile} ]];  then
-        echo -n $"Graceful shutdown of old $prog: "
-        killproc -p ${oldbin_pidfile} -QUIT
-        retval=$?
+        killproc -p $oldbin_pidfile $prog -QUIT
+        success $"$prog online upgrade"
         echo 
         return 0
     else
-        echo $"Something bad happened, manual intervention required, maybe restart?"
+        failure $"$prog online upgrade"
+        echo
         return 1
     fi
 }
 
+# Tell nginx to reopen logs
+reopen_logs() {
+    configtest_q || return 6
+    echo -n $"Reopening $prog logs: "
+    killproc -p $pidfile $prog -USR1
+    retval=$?
+    echo
+    return $retval
+}
+
 case "$1" in
     start)
         rh_status_q && exit 0
@@ -109,7 +120,7 @@ case "$1" in
         rh_status_q || exit 0
         $1
         ;;
-    restart|configtest)
+    restart|configtest|reopen_logs)
         $1
         ;;
     force-reload|upgrade) 
@@ -128,6 +139,6 @@ case "$1" in
         restart
 	    ;;
     *)
-        echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart}"
+        echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}"
         exit 2
 esac
diff --git a/nginx.logrotate b/nginx.logrotate
index 48c39e1..1c0f42d 100644
--- a/nginx.logrotate
+++ b/nginx.logrotate
@@ -6,7 +6,7 @@
     compress
     sharedscripts
     postrotate
-        [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
+        /etc/init.d/nginx reopen_logs
     endscript
 }
 
diff --git a/nginx.spec b/nginx.spec
index abf7717..1ce182e 100644
--- a/nginx.spec
+++ b/nginx.spec
@@ -1,76 +1,82 @@
-%define nginx_user      nginx
-%define nginx_group     %{nginx_user}
-%define nginx_home      %{_localstatedir}/lib/nginx
-%define nginx_home_tmp  %{nginx_home}/tmp
-%define nginx_logdir    %{_localstatedir}/log/nginx
-%define nginx_confdir   %{_sysconfdir}/nginx
-%define nginx_datadir   %{_datadir}/nginx
-%define nginx_webroot   %{nginx_datadir}/html
-
-Name:           nginx
-Version:        1.0.12
-Release:        1%{?dist}
-Summary:        Robust, small and high performance HTTP and reverse proxy server
-Group:          System Environment/Daemons
-
+%global  nginx_user          nginx
+%global  nginx_group         %{nginx_user}
+%global  nginx_home          %{_localstatedir}/lib/nginx
+%global  nginx_home_tmp      %{nginx_home}/tmp
+%global  nginx_logdir        %{_localstatedir}/log/nginx
+%global  nginx_confdir       %{_sysconfdir}/nginx
+%global  nginx_datadir       %{_datadir}/nginx
+%global  nginx_webroot       %{nginx_datadir}/html
+
+Name:              nginx
+Version:           1.0.13
+Release:           1%{?dist}
+
+Summary:           A high performance web server and reverse proxy server
+Group:             System Environment/Daemons
 # BSD License (two clause)
 # http://www.freebsd.org/copyright/freebsd-license.html
-License:        BSD
-URL:            http://nginx.net/
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
-BuildRequires:      pcre-devel,zlib-devel,openssl-devel,perl-devel,perl(ExtUtils::Embed)
-BuildRequires:      libxslt-devel,GeoIP-devel,gd-devel
-Requires:           pcre,openssl,GeoIP,gd
-Requires:           perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
-# for /usr/sbin/useradd
-Requires(pre):      shadow-utils
-Requires(post):     chkconfig
-# for /sbin/service
-Requires(preun):    chkconfig, initscripts
-Requires(postun):   initscripts
-Provides:           webserver
-
-Source0:    http://nginx.org/download/nginx-%{version}.tar.gz
-Source1:    %{name}.init
-Source2:    %{name}.logrotate
-Source3:    virtual.conf
-Source4:    ssl.conf
-Source5:    %{name}.sysconfig
-Source6:    nginx.conf
-Source7:    default.conf
-Source100:  index.html
-Source101:  poweredby.png
-Source102:  nginx-logo.png
-Source103:  50x.html
-Source104:  404.html
+License:           BSD
+URL:               http://nginx.org/
+
+Source0:           http://nginx.org/download/nginx-%{version}.tar.gz
+Source1:           nginx.init
+Source2:           nginx.logrotate
+Source3:           nginx.conf
+Source4:           default.conf
+Source5:           ssl.conf
+Source6:           virtual.conf
+Source7:           nginx.sysconfig
+Source100:         index.html
+Source101:         poweredby.png
+Source102:         nginx-logo.png
+Source103:         404.html
+Source104:         50x.html
 
 # removes -Werror in upstream build scripts.  -Werror conflicts with
 # -D_FORTIFY_SOURCE=2 causing warnings to turn into errors.
 Patch0:     nginx-auto-cc-gcc.patch
 
+BuildRequires:     GeoIP-devel
+BuildRequires:     gd-devel
+BuildRequires:     libxslt-devel
+BuildRequires:     openssl-devel
+BuildRequires:     pcre-devel
+BuildRequires:     perl-devel
+BuildRequires:     perl(ExtUtils::Embed)
+BuildRequires:     zlib-devel
+BuildRequires:     systemd-units
+Requires:          GeoIP
+Requires:          gd
+Requires:          openssl
+Requires:          pcre
+Requires:          perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+Requires(pre):     shadow-utils
+Requires(post):    chkconfig
+Requires(preun):   chkconfig, initscripts
+Requires(postun):  initscripts
+Provides:          webserver
+
 %description
-Nginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3
-proxy server written by Igor Sysoev.
+Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and
+IMAP protocols, with a strong focus on high concurrency, performance and low
+memory usage.
+
 
 %prep
 %setup -q
-
 %patch0 -p0
 
+
 %build
 # nginx does not utilize a standard configure script.  It has its own
 # and the standard configure options cause the nginx configure script
 # to error out.  This is is also the reason for the DESTDIR environment
-# variable.  The configure script(s) have been patched (Patch1 and
-# Patch2) in order to support installing into a build environment.
+# variable.
 export DESTDIR=%{buildroot}
 ./configure \
-    --user=%{nginx_user} \
-    --group=%{nginx_group} \
     --prefix=%{nginx_datadir} \
-    --sbin-path=%{_sbindir}/%{name} \
-    --conf-path=%{nginx_confdir}/%{name}.conf \
+    --sbin-path=%{_sbindir}/nginx \
+    --conf-path=%{nginx_confdir}/nginx.conf \
     --error-log-path=%{nginx_logdir}/error.log \
     --http-log-path=%{nginx_logdir}/access.log \
     --http-client-body-temp-path=%{nginx_home_tmp}/client_body \
@@ -78,8 +84,12 @@ export DESTDIR=%{buildroot}
     --http-fastcgi-temp-path=%{nginx_home_tmp}/fastcgi \
     --http-uwsgi-temp-path=%{nginx_home_tmp}/uwsgi \
     --http-scgi-temp-path=%{nginx_home_tmp}/scgi \
-    --pid-path=%{_localstatedir}/run/%{name}.pid \
-    --lock-path=%{_localstatedir}/lock/subsys/%{name} \
+    --pid-path=%{_localstatedir}/run/nginx.pid \
+    --lock-path=%{_localstatedir}/lock/subsys/nginx \
+    --user=%{nginx_user} \
+    --group=%{nginx_group} \
+    --with-file-aio \
+    --with-ipv6 \
     --with-http_ssl_module \
     --with-http_realip_module \
     --with-http_addition_module \
@@ -97,47 +107,52 @@ export DESTDIR=%{buildroot}
     --with-http_stub_status_module \
     --with-http_perl_module \
     --with-mail \
-    --with-file-aio \
     --with-mail_ssl_module \
-    --with-ipv6 \
     --with-cc-opt="%{optflags} $(pcre-config --cflags)" \
     --with-ld-opt="-Wl,-E" # so the perl module finds its symbols
+
 make %{?_smp_mflags} 
 
+
 %install
-rm -rf %{buildroot}
 make install DESTDIR=%{buildroot} INSTALLDIRS=vendor
-find %{buildroot} -type f -name .packlist -exec rm -f {} \;
-find %{buildroot} -type f -name perllocal.pod -exec rm -f {} \;
-find %{buildroot} -type f -empty -exec rm -f {} \;
-find %{buildroot} -type f -exec chmod 0644 {} \;
-find %{buildroot} -type f -name '*.so' -exec chmod 0755 {} \;
-chmod 0755 %{buildroot}%{_sbindir}/nginx
-%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}
-%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
-%{__install} -p -D -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
-%{__install} -p -d -m 0755 %{buildroot}%{nginx_confdir}/conf.d
-%{__install} -p -m 0644 %{SOURCE3} %{SOURCE4} %{SOURCE7} %{buildroot}%{nginx_confdir}/conf.d
-%{__install} -p -m 0644 %{SOURCE6} %{buildroot}%{nginx_confdir}
-%{__install} -p -d -m 0755 %{buildroot}%{nginx_home_tmp}
-%{__install} -p -d -m 0755 %{buildroot}%{nginx_logdir}
-%{__install} -p -d -m 0755 %{buildroot}%{nginx_webroot}
-%{__install} -p -m 0644 %{SOURCE100} %{SOURCE101} %{SOURCE102} %{SOURCE103} %{SOURCE104} %{buildroot}%{nginx_webroot}
-
-# convert to UTF-8 all files that give warnings.
-for textfile in CHANGES
-do
-    mv $textfile $textfile.old
-    iconv --from-code ISO8859-1 --to-code UTF-8 --output $textfile $textfile.old
-    rm -f $textfile.old
-done
-
-%clean
-rm -rf %{buildroot}
+
+find %{buildroot} -type f -name .packlist -exec rm -f '{}' \;
+find %{buildroot} -type f -name perllocal.pod -exec rm -f '{}' \;
+find %{buildroot} -type f -empty -exec rm -f '{}' \;
+find %{buildroot} -type f -iname '*.so' -exec chmod 0755 '{}' \;
+
+install -p -D -m 0755 %{SOURCE1} \
+    %{buildroot}%{_initrddir}/nginx
+install -p -D -m 0644 %{SOURCE2} \
+    %{buildroot}%{_sysconfdir}/logrotate.d/nginx
+install -p -D -m 0644 %{SOURCE7} \
+    %{buildroot}%{_sysconfdir}/sysconfig/nginx
+
+install -p -d -m 0755 %{buildroot}%{nginx_confdir}/conf.d
+install -p -d -m 0755 %{buildroot}%{nginx_home_tmp}
+install -p -d -m 0755 %{buildroot}%{nginx_logdir}
+install -p -d -m 0755 %{buildroot}%{nginx_webroot}
+
+install -p -m 0644 %{SOURCE3} \
+    %{buildroot}%{nginx_confdir}
+install -p -m 0644 %{SOURCE4} %{SOURCE5} %{SOURCE6} \
+    %{buildroot}%{nginx_confdir}/conf.d
+install -p -m 0644 %{SOURCE100} \
+    %{buildroot}%{nginx_webroot}
+install -p -m 0644 %{SOURCE101} %{SOURCE102} \
+    %{buildroot}%{nginx_webroot}
+install -p -m 0644 %{SOURCE103} %{SOURCE104} \
+    %{buildroot}%{nginx_webroot}
+
 
 %pre
-if [ $1 == 1 ]; then
-    %{_sbindir}/useradd -c "Nginx user" -s /bin/false -r -d %{nginx_home} %{nginx_user} 2>/dev/null || :
+if [ $1 -eq 1 ]; then
+    getent group %{nginx_group} > /dev/null || groupadd -r %{nginx_group}
+    getent passwd %{nginx_user} > /dev/null || \
+        useradd -r -d %{nginx_home} -g %{nginx_group} \
+        -s /sbin/nologin -c "Nginx web server" %{nginx_user}
+    exit 0
 fi
 
 %post
@@ -157,41 +172,49 @@ if [ $1 == 2 ]; then
 fi
 
 %files
-%defattr(-,root,root,-)
 %doc LICENSE CHANGES README
 %{nginx_datadir}/
-%{_sbindir}/%{name}
-%{_mandir}/man3/%{name}.3pm.gz
-%{_initrddir}/%{name}
+%{_sbindir}/nginx
+%{_mandir}/man3/nginx.3pm.gz
+%{_initrddir}/nginx
 %dir %{nginx_confdir}
 %dir %{nginx_confdir}/conf.d
 %dir %{nginx_logdir}
-%config(noreplace) %{nginx_confdir}/conf.d/*.conf
-%config(noreplace) %{nginx_confdir}/win-utf
-%config(noreplace) %{nginx_confdir}/%{name}.conf.default
-%config(noreplace) %{nginx_confdir}/mime.types.default
 %config(noreplace) %{nginx_confdir}/fastcgi.conf
 %config(noreplace) %{nginx_confdir}/fastcgi.conf.default
 %config(noreplace) %{nginx_confdir}/fastcgi_params
 %config(noreplace) %{nginx_confdir}/fastcgi_params.default
+%config(noreplace) %{nginx_confdir}/koi-utf
+%config(noreplace) %{nginx_confdir}/koi-win
+%config(noreplace) %{nginx_confdir}/mime.types
+%config(noreplace) %{nginx_confdir}/mime.types.default
+%config(noreplace) %{nginx_confdir}/nginx.conf
+%config(noreplace) %{nginx_confdir}/nginx.conf.default
 %config(noreplace) %{nginx_confdir}/scgi_params
 %config(noreplace) %{nginx_confdir}/scgi_params.default
 %config(noreplace) %{nginx_confdir}/uwsgi_params
 %config(noreplace) %{nginx_confdir}/uwsgi_params.default
-%config(noreplace) %{nginx_confdir}/koi-win
-%config(noreplace) %{nginx_confdir}/koi-utf
-%config(noreplace) %{nginx_confdir}/%{name}.conf
-%config(noreplace) %{nginx_confdir}/mime.types
-%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
-%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
-%dir %{perl_vendorarch}/auto/%{name}
-%{perl_vendorarch}/%{name}.pm
-%{perl_vendorarch}/auto/%{name}/%{name}.so
+%config(noreplace) %{nginx_confdir}/win-utf
+%config(noreplace) %{nginx_confdir}/conf.d/*.conf
+%config(noreplace) %{_sysconfdir}/logrotate.d/nginx
+%config(noreplace) %{_sysconfdir}/sysconfig/nginx
+%dir %{perl_vendorarch}/auto/nginx
+%{perl_vendorarch}/nginx.pm
+%{perl_vendorarch}/auto/nginx/nginx.so
 %attr(-,%{nginx_user},%{nginx_group}) %dir %{nginx_home}
 %attr(-,%{nginx_user},%{nginx_group}) %dir %{nginx_home_tmp}
 
 
 %changelog
+* Tue Mar 03 2012 Jamie Nguyen <jamie at tomoyolinux.co.uk> - 1.0.13-1
+- update to upstream release 1.0.13
+- general spec file cleanup to match rawhide (for easier diff), including:
+- replace %%define with %%global
+- amend nginx.init and nginx.conf
+- amend %%pre scriptlet to match with guidelines
+- remove obsolete BuildRoot tag, %%clean section and %%defattr
+- remove various unnecessary commands
+
 * Sun Feb 19 2012 Jeremy Hinegardner <jeremy at hinegardner dot org> - 1.0.12-1
 - Update to 1.0.12
 
diff --git a/sources b/sources
index 4f149b1..3242b66 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-d0ceefeb2a68ecb19e78ee894a5b52a3  nginx-1.0.12.tar.gz
+58360774e4875e8fc4c4286448cb54d0  nginx-1.0.13.tar.gz


More information about the scm-commits mailing list