kopug memo

名古屋で働くとあるWebエンジニアの覚書。

CentOS5.5 x86_64 で 最新のnginx を rpmbuildする

EPELで実はnginxのrpmがあるんだけども、versionが0.6で止まっている。
なので、EPELからsrc.rpmを落としてきてそいつに最新のnginxをつっこんでbuildした。

EPELからnginxのsrc.rpmをダウンロードし、インストールする

# wget http://ftp.iij.ad.jp/pub/linux/fedora/epel/5/SRPMS/nginx-0.6.39-5.el5.src.rpm
# rpm -i nginx-0.6.39-5.el5.src.rpm

最新のnginxをDLし、SPECファイルを編集する

# cd /usr/src/redhat/SOURCES
# wget http://nginx.org/download/nginx-0.8.50.tar.gz
# cd ../SPECS/
# vi nginx.spec

versionを変更する

Version:        0.8.50

patchを当てないようにする

#Patch0:     nginx-auto-cc-gcc.patch
#Patch1:     nginx-cve-2009-3555.patch

#%patch0 -p0
#%patch1 -p0

LANG=C だとmakeでこけてしまうので、LANGを上書きする

%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.
export LANG='ja_JP.UTF-8'                                      <- 追加
export DESTDIR=%{buildroot}

TODO: rpmの仕様なのか、configureする前にLANG=Cにするみたいなので、上書きしているけど対応方法が強引すぎるため要調査

エラー内容は以下

make -f objs/Makefile
make[1]: Entering directory `/usr/src/redhat/BUILD/nginx-0.8.50'
gcc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/nginx.o \
                src/core/nginx.c
cc1: warnings being treated as errors
src/core/nginx.c: In function 'ngx_set_user':
src/core/nginx.c:1101: warning: unused parameter 'cmd'
src/core/nginx.c: In function 'ngx_set_env':
src/core/nginx.c:1164: warning: unused parameter 'cmd'
src/core/nginx.c: In function 'ngx_set_priority':
src/core/nginx.c:1194: warning: unused parameter 'cmd'
src/core/nginx.c: In function 'ngx_set_cpu_affinity':
src/core/nginx.c:1234: warning: unused parameter 'cmd'
make[1]: *** [objs/src/core/nginx.o] Error 1
make[1]: Leaving directory `/usr/src/redhat/BUILD/nginx-0.8.50'
make: *** [build] Error 2
+ mv nginx-upstream-fair/README nginx-upstream-fair/README.nginx-upstream-fair
mv: cannot stat `nginx-upstream-fair/README': No such file or directory
+ exit 0

パッケージにファイルが含まれてないといわれるので、無視するようにする

%define _unpackaged_files_terminate_build 0

※ %filesに含めたほうがいいかも。

buildする。src.rpmも作成しておく

# rpmbuild -ba nginx.spec

これで無事rpmが完成するのでインストール

# rpm -i /usr/src/redhat/RPMS/x86_64/nginx-0.8.50-5.x86_64.rpm