Chinaunix首页 | 论坛 | 博客
  • 博客访问: 325184
  • 博文数量: 53
  • 博客积分: 1132
  • 博客等级: 少尉
  • 技术积分: 451
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-18 14:22
文章分类

全部博文(53)

文章存档

2014年(1)

2013年(11)

2012年(17)

2011年(16)

2010年(8)

分类: LINUX

2012-01-18 16:06:55

一直以来都是采用tar包编译安装程序,出现一次大批量安装服务器就over了,还是深入研究了下RPM的打包机制,做个记录,方便以后自己查询。 keepalived-1.2.1-el5.src.rpm.rar   
  1. %define keepalived_prefix /usr/local/keepalived
  2. %define Config        keepalived.conf
  3. %define    read_name    keepalived
  4. ####自定义函数

  5. Summary: HA monitor built upon LVS, VRRP and services poller
  6. ####软件包内容提要
  7. Name: keepalived
  8. ####软件包名
  9. Version: 1.2.1
  10. ####版本号
  11. Release: el5
  12. ####软件发布序列号
  13. License: GPL
  14. ####软件授权方式,通常就是GPL
  15. Group: Applications/System
  16. ####软件分组
  17. URL: http://www.keepalived.org/
  18. ####软件的主页
  19. Packager: Liao Fayou
  20. ####打包者的信息
  21. Vendor:    Linux Lovers
  22. ####发行商或者打包者组织信息

  23. Source0: http://www.keepalived.org/software/keepalived-%{version}.tar.gz
  24. Source1: keepalived.conf
  25. Source2: check_server.sh
  26. ####源代码包
  27. Patch0: keepalived.init.patch
  28. Patch1: keepalived.sysconfig.patch
  29. ####补丁源码

  30. BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
  31. ####构建rpm包时,使用的虚拟跟目录
  32. Prefix: %{keepalived_prefix}%{_prefix}
  33. Prefix: %{keepalived_prefix}%{_sysconfdir}
  34. ####这个主要是为了解决今后安装rpm包时,并不一定把软件安装到rpm中打包的目录的情况。这样,必须在这里定义该标识,并在编写%install脚本的时候引用,才能实现rpm安装时重新指定位置的功能

  35. BuildRequires: openssl-devel
  36. Requires(post): /sbin/chkconfig
  37. Requires(preun): /sbin/service, /sbin/chkconfig
  38. Requires(postun): /sbin/service
  39. ####该RPM包必须依赖的软件,可以使用>=或者<= 来表示特定版本,还有例如PreReq、Requires(pre)、Requires(post)、Requires(preun)、Requires(postun)、BuildRequires等都是针对不同阶段的依赖指定

  40. #%description -l zh_CN
  41. #可写中文说明
  42. %description
  43. ####软件详细说明
  44. The main goal of the keepalived project is to add a strong & robust keepalive
  45. facility to the Linux Virtual Server project. This project is written in C with
  46. multilayer TCP/IP stack checks. Keepalived implements a framework based on
  47. three family checks : Layer3, Layer4 & Layer5/7. This framework gives the
  48. daemon the ability to check the state of an LVS server pool. When one of the
  49. servers of the LVS server pool is down, keepalived informs the linux kernel via
  50. a setsockopt call to remove this server entry from the LVS topology. In
  51. addition keepalived implements an independent VRRPv2 stack to handle director
  52. failover. So in short keepalived is a userspace daemon for LVS cluster nodes
  53. healthchecks and LVS directors failover.

  54. %prep
  55. ####预处理脚本
  56. %setup
  57. ####解压源代码包
  58. %patch0 -p0
  59. %patch1 -p0
  60. ####打补丁

  61. %build
  62. #%{?el3:export CPPFLAGS="-I/usr/kerberos/include"}
  63. %configure --disable-lvs-syncd --disable-lvs
  64. #%{?el3:--includedir="/usr/kerberos/include"}
  65. # --with-kernel-dir="/lib/modules/%{kernel}/build"
  66. %{__make} %{?_smp_mflags} STRIP=/bin/true
  67. ####开始构建安装包,也就是源码编译时的./configure ;make

  68. %install
  69. %{__rm} -rf %{buildroot}
  70. #%{__make} install DESTDIR=$RPM_BUILD_ROOT%{keepalived_prefix}
  71. %{__make} install DESTDIR=%{buildroot}%{keepalived_prefix}
  72. # Remove "samples", as we include them in %%doc
  73. %{__install} -p -d -m 0755 %{buildroot}%{keepalived_prefix}%{_docdir}/%{name}-%{version}
  74. %{__install} -p -m 0644 AUTHOR CONTRIBUTORS COPYING ChangeLog README TODO %{buildroot}%{keepalived_prefix}%{_docdir}/%{name}-%{version}
  75. %{__install} -p -m 0644 doc/keepalived.conf.SYNOPSIS %{buildroot}%{keepalived_prefix}%{_docdir}/%{name}-%{version}
  76. %{__install} -p -D -m 0755 %{name}%{_sysconfdir}/init.d/keepalived.init %{buildroot}%{_initrddir}/%{name}
  77. %{__mv} %{buildroot}%{keepalived_prefix}%{_sysconfdir}/%{name}/%{Config} %{buildroot}%{keepalived_prefix}%{_sysconfdir}/%{name}/%{Config}.default
  78. %{__install} -p -m 0644 %{SOURCE1} %{buildroot}%{keepalived_prefix}%{_sysconfdir}/%{name}
  79. %{__install} -p -m 0755 %{SOURCE2} %{buildroot}%{keepalived_prefix}%{_sysconfdir}/%{name}
  80. %{__rm} -rf %{buildroot}%{_sysconfdir}/keepalived/samples/
  81. ####安装编译好的软件到虚拟跟目录

  82. %check
  83. # A build could silently have LVS support disabled if the kernel includes can't
  84. # be properly found, we need to avoid that.
  85. ## 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.

阅读(1840) | 评论(0) | 转发(0) |
0

上一篇:IPMI 使用

下一篇:SPEC 文件详解

给主人留下些什么吧!~~