kopug memo

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

VirtualBox で イメージの複製

vboxmanage clonehd D:\vm\centos5\Base.vdi D:\vm\centos5\NewHardDisk02.vdi 

絶対パスでファイルを指定しないとERRORになった。

ERROR: Cannot register the hard disk 'D:\vm\centos5\Base.vdi' with UUID
 {*******-****-****-****-************} because a hard disk 'D:\vm\centos5\Base.vdi'
 with UUID {*******-****-****-****-************} already exists in
 the media registry ('C:\Users\kopug/.VirtualBox\VirtualBox.xml')
Details: code E_INVALIDARG (0x80070057), component VirtualBox, interface IVirtua
lBox, callee IUnknown
Context: "OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""
), false, Bstr(""), srcDisk.asOutParam())" at line 633 of file VBoxManageDisk.cp
p

VBoxManage コマンドは デフォルトインストールだとこちらに。
C:\Program Files\Oracle\VirtualBox\

CentOS 5.5 x86_64 に checkinstall を入れてみる

以前はrpmforgeにパッケージがあったと思ったけど、どうやら無くなっている?
仕方が無いので、ソースからインストールし、その後checkinstallを使ってrpmにする。

# cd /usr/local/src
# wget http://www.asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.2.tar.gz
# tar zxf checkinstall-1.6.2.tar.gz
# cd checkinstall-1.6.2
# make
# make install

x86_64なので、本来installwatch.so は lib64に入ってほしいんだけど、libに入っている。
makefileを書き直してもいいけど、今回はシンボリックリンクで対応。

# ln -s /usr/local/lib/installwatch.so /usr/local/lib64/installwatch.so
# checkinstall

適当に質問に答えていき、rpmができたらそいつをインストールしておく

# rpm -i /usr/src/redhat/RPMS/x86_64/checkinstall-1.6.2-1.x86_64.rpm
# rpm -qi checkinstall
Name        : checkinstall                 Relocations: (not relocatable)
Version     : 1.6.2                             Vendor: (none)
Release     : 1                             Build Date: 2010年09月18日 18時18分48秒
Install Date: 2010年09月18日 18時19分01秒      Build Host: rpmbuilder
Group       : Applications/System           Source RPM: checkinstall-1.6.2-1.src.rpm
Size        : 457305                           License: GPL
Signature   : (none)
Packager    : checkinstall-1.6.2
Summary     : CheckInstall installations tracker, version 1.6.2
Description :
CheckInstall installations tracker, version 1.6.2

CheckInstall  keeps  track of all the files created  or
modified  by your installation  script  ("make install"
"make install_modules",  "setup",   etc),   builds    a
standard   binary   package and  installs  it  in  your
system giving you the ability to uninstall it with your
distribution's  standard package management  utilities.

これで完成。

よく使うyumリポジトリ

言わずと知れたRPMforge

# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
# rpm -i rpmforge-release-0.5.1-1.el5.rf.*.rpm

CentOS(RHEL)でもFedoraのパッケージが使いたいときはEPEL

# rpm --import http://ftp.iij.ad.jp/pub/linux/fedora/epel/RPM-GPG-KEY-EPEL
# rpm -i epel-release-5-3.noarch.rpm

PHPMySQLの最新版を使いたい。どこよりも早く、最新のバージョンをパッケージングしてくれるremi

# wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
# rpm -i remi-release-5.rpm
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi

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