您的位置:首页 > 产品设计 > 产品经理

自己动手源码包制作rpm 包 (二)

2013-09-13 21:23 399 查看
rpm 包制作2013 -9 -12 更新
比之前增加升级部分
#########################################
# Example spec file for zabbix
Summary: A Monitoring program
Name: ppszabbix
Version: 2.0.8
Release: 2
License: GPL
Group: Applications/Server
Source0: %{name}-%{version}.tar.gz
Source1: zabbix_agentd
URL: http://zabbix.org/ Packager: xbz
BuildPreReq: gcc,make
BuildRequires: /bin/cp,/bin/mkdir,/bin/rm
Requires:/bin/bash,/bin/sh
#Autoreq: 0 (如果不需要自动依赖就去掉注释)
#Autoreq: 0 #这里使用 0 关闭了自动标注本软件包需要的依赖关系的功能,使用 1 或者不写此行(默认)就是开启自动标注依赖关系的功能。自动依赖校验只会通过 pkgconfig 找出依赖的 .so 文件,而绝对不是软件包!可以通过命令反查生成的 rpm 包所依赖的这些 .so 文件属于哪个包,再把这些依赖的包的名称写进 spec,最后重新编译就行了。
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires(post): chkconfig

###注意定义路时一定不能有特殊字符
%define zabbixpath /opt/zabbix

%description
The ppszabbix is a distributed monitoring and control system
List of Improvements included into 2.0.8
added IP to the warning about ignored messages because of their size
updated Dutch translation; thanks to Zabbix translators
Complete List of Bug Fixes and Improvements included into 2.0.8
fixed processing of availability data by the server
added IP to the warning about ignored messages because of their size
updated Dutch translation; thanks to Zabbix translators
fixed template linking to proxy if the agent with the same name is auto-registered
fixed undefined indexes for triggers in Monitoring > Maps and Dashboard
fixed windows agent performance counters being capped to 100
fixed webtest item conversion in 1.8->2.0 database upgrade patch for mysql
fixed proc.mem calculations with getprocs() for AIX
fixed curl verify host option setting in ez texting
improved error messages from UnixODBC library for Database Monitor items
added configurable ODBC login timeout
%prep
#%setup -q
rm -rf $RPM_BUILD_DIR/zabbix-2.0.8
zcat $RPM_SOURCE_DIR/ppszabbix-2.0.8.tar.gz | tar -xvf -
%build
cd zabbix-2.0.8
./configure --prefix=/opt/zabbix --enable-agent
make
%install
cd zabbix-2.0.8
make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/opt/zabbix/script
cp zabbix_agentd $RPM_BUILD_ROOT/opt/zabbix/script/
%pre
rm -rf %{zabbixpath}

%preun
if [ $1 == 0 ];then
if test $(pgrep -f zabbix_agentd | wc -l) -ne 0; then
/etc/init.d/zabbix_agentd stop
fi
fi
%post
USZA=`cat /etc/passwd|grep zabbix`
if [ -z $USZA ]
then
groupadd zabbix
useradd zabbix -g zabbix -s /sbin/nologin
fi
unset USZA
#mkdir -p /var/run/zabbix
#mkdir -p /var/log/zabbix
#chown -R zabbix:zabbix /var/run/zabbix
#chown -R zabbix:zabbix /var/log/zabbix
cp /opt/zabbix/script/zabbix_agentd /etc/init.d/
chmod 755 /etc/init.d/zabbix_agentd
chkconfig --add zabbix_agentd
chkconfig --level 35 zabbix_agentd on
/etc/init.d/zabbix_agentd start

%postun
if [ $1 == 0 ];then
echo "success uninstall"
fi
%clean
rm -rf $RPM_BUILD_ROOT
rm -rf %{_builddir}/%{name}-%{version}
%files
%{zabbixpath}
%changelog
* Thu Sep 12 2013 xbz <xuebaiji@qiyi.com>
- Add rpm package

%config(noreplace) /etc/yp.conf
#该配置文件不会覆盖已存在文件(被修改)覆盖已存在文件(没被修改),创建新的文件加上扩展后缀.rpmnew(被修改)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  rpm 包制作