一直以来都是采用tar包编译安装程序,出现一次大批量安装服务器就over了,还是深入研究了下RPM的打包机制,做个记录,方便以后自己查询。
keepalived-1.2.1-el5.src.rpm.rar - %define keepalived_prefix /usr/local/keepalived
-
%define Config keepalived.conf
-
%define read_name keepalived
-
####自定义函数
-
-
Summary: HA monitor built upon LVS, VRRP and services poller
-
####软件包内容提要
-
Name: keepalived
-
####软件包名
-
Version: 1.2.1
-
####版本号
-
Release: el5
-
####软件发布序列号
-
License: GPL
-
####软件授权方式,通常就是GPL
-
Group: Applications/System
-
####软件分组
-
URL: http://www.keepalived.org/
-
####软件的主页
-
Packager: Liao Fayou
-
####打包者的信息
-
Vendor: Linux Lovers
-
####发行商或者打包者组织信息
-
-
Source0: http://www.keepalived.org/software/keepalived-%{version}.tar.gz
-
Source1: keepalived.conf
-
Source2: check_server.sh
-
####源代码包
-
Patch0: keepalived.init.patch
-
Patch1: keepalived.sysconfig.patch
-
####补丁源码
-
-
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-
####构建rpm包时,使用的虚拟跟目录
-
Prefix: %{keepalived_prefix}%{_prefix}
-
Prefix: %{keepalived_prefix}%{_sysconfdir}
-
####这个主要是为了解决今后安装rpm包时,并不一定把软件安装到rpm中打包的目录的情况。这样,必须在这里定义该标识,并在编写%install脚本的时候引用,才能实现rpm安装时重新指定位置的功能
-
-
BuildRequires: openssl-devel
-
Requires(post): /sbin/chkconfig
-
Requires(preun): /sbin/service, /sbin/chkconfig
-
Requires(postun): /sbin/service
-
####该RPM包必须依赖的软件,可以使用>=或者<= 来表示特定版本,还有例如PreReq、Requires(pre)、Requires(post)、Requires(preun)、Requires(postun)、BuildRequires等都是针对不同阶段的依赖指定
-
-
#%description -l zh_CN
-
#可写中文说明
-
%description
-
####软件详细说明
-
The main goal of the keepalived project is to add a strong & robust keepalive
-
facility to the Linux Virtual Server project. This project is written in C with
-
multilayer TCP/IP stack checks. Keepalived implements a framework based on
-
three family checks : Layer3, Layer4 & Layer5/7. This framework gives the
-
daemon the ability to check the state of an LVS server pool. When one of the
-
servers of the LVS server pool is down, keepalived informs the linux kernel via
-
a setsockopt call to remove this server entry from the LVS topology. In
-
addition keepalived implements an independent VRRPv2 stack to handle director
-
failover. So in short keepalived is a userspace daemon for LVS cluster nodes
-
healthchecks and LVS directors failover.
-
-
%prep
-
####预处理脚本
-
%setup
-
####解压源代码包
-
%patch0 -p0
-
%patch1 -p0
-
####打补丁
-
-
%build
-
#%{?el3:export CPPFLAGS="-I/usr/kerberos/include"}
-
%configure --disable-lvs-syncd --disable-lvs
-
#%{?el3:--includedir="/usr/kerberos/include"}
-
# --with-kernel-dir="/lib/modules/%{kernel}/build"
-
%{__make} %{?_smp_mflags} STRIP=/bin/true
-
####开始构建安装包,也就是源码编译时的./configure ;make
-
-
%install
-
%{__rm} -rf %{buildroot}
-
#%{__make} install DESTDIR=$RPM_BUILD_ROOT%{keepalived_prefix}
-
%{__make} install DESTDIR=%{buildroot}%{keepalived_prefix}
-
# Remove "samples", as we include them in %%doc
-
%{__install} -p -d -m 0755 %{buildroot}%{keepalived_prefix}%{_docdir}/%{name}-%{version}
-
%{__install} -p -m 0644 AUTHOR CONTRIBUTORS COPYING ChangeLog README TODO %{buildroot}%{keepalived_prefix}%{_docdir}/%{name}-%{version}
-
%{__install} -p -m 0644 doc/keepalived.conf.SYNOPSIS %{buildroot}%{keepalived_prefix}%{_docdir}/%{name}-%{version}
-
%{__install} -p -D -m 0755 %{name}%{_sysconfdir}/init.d/keepalived.init %{buildroot}%{_initrddir}/%{name}
-
%{__mv} %{buildroot}%{keepalived_prefix}%{_sysconfdir}/%{name}/%{Config} %{buildroot}%{keepalived_prefix}%{_sysconfdir}/%{name}/%{Config}.default
-
%{__install} -p -m 0644 %{SOURCE1} %{buildroot}%{keepalived_prefix}%{_sysconfdir}/%{name}
-
%{__install} -p -m 0755 %{SOURCE2} %{buildroot}%{keepalived_prefix}%{_sysconfdir}/%{name}
-
%{__rm} -rf %{buildroot}%{_sysconfdir}/keepalived/samples/
-
####安装编译好的软件到虚拟跟目录
-
-
%check
-
# A build could silently have LVS support disabled if the kernel includes can't
-
# be properly found, we need to avoid that.
-
## if ! grep -q "IPVS_SUPPORT='_WITH_LVS_'" config.log; then
## echo "ERROR: We do not want keeepalived lacking LVS support."
## exit 1
## fi
%clean
%{__rm} -rf %{buildroot}
%{__rm} -rf $RPM_BUILD_DIR/%{name}-%{version}
####清理临时文件
%post
/sbin/chkconfig --add keepalived
####RPM包安装后要执行的操作
%preun
if [ $1 -eq 0 ]; then
/sbin/service keepalived stop &>/dev/null || :
/sbin/chkconfig --del keepalived
fi
####RPM包卸载前要执行的操作
%postun
if [ $1 -ge 1 ]; then
/sbin/service keepalived condrestart &>/dev/null || :
fi
####RPM包卸载后要执行的操作
%files
%defattr(-, root, root, 0755)
%doc %{keepalived_prefix}%{_docdir}/%{name}-%{version}/*
%doc %{keepalived_prefix}%{_sysconfdir}/keepalived/samples/*
%dir %{keepalived_prefix}%{_sysconfdir}/keepalived/
%attr(0600, root, root) %config(noreplace) %{keepalived_prefix}%{_sysconfdir}/keepalived/keepalived.conf
%attr(0600, root, root) %config(noreplace) %{keepalived_prefix}%{_sysconfdir}/keepalived/%{Config}.default
%attr(0755, root, root) %config(noreplace) %{keepalived_prefix}%{_sysconfdir}/keepalived/check_server.sh
%attr(0600, root, root) %config(noreplace) %{keepalived_prefix}%{_sysconfdir}/sysconfig/keepalived
%{_initrddir}/%{name}
%{keepalived_prefix}%{_sysconfdir}/rc.d/init.d/keepalived
%{keepalived_prefix}%{_bindir}/genhash
%{keepalived_prefix}%{_sbindir}/keepalived
%{keepalived_prefix}%{_mandir}/man1/genhash.1*
%{keepalived_prefix}%{_mandir}/man5/keepalived.conf.5*
%{keepalived_prefix}%{_mandir}/man8/keepalived.8*
####要打包到RPM包中的文件
%changelog
#### 变更日志
* Thu Sep 13 2007 Alexandre Cassen 1.1.14
- Merge work done by freshrpms.net... Thanks guys !!! ;)
* Wed Feb 14 2007 Matthias Saou < 1.1.13-5
- Add missing scriplet requirements.
阅读(1865) | 评论(0) | 转发(0) |