使用zabbix 源码包 制作rpm 的例子:
下面是 .spec 文件
# Example spec file for zabbix
Summary: A Monitoring program
Name: ppszabbix
Version: 2.0.5
Release: 1
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,
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires(post): chkconfig
%description
The ppszabbix is a distributed monitoring and control system
%prep
#%setup -q
rm -rf $RPM_BUILD_DIR/zabbix-2.0.5
zcat $RPM_SOURCE_DIR/ppszabbix-2.0.5.tar.gz | tar -xvf -
%build
cd zabbix-2.0.5
./configure --prefix=/opt/zabbix --enable-agent
make
%install
cd zabbix-2.0.5
make install DESTDIR=$RPM_BUILD_ROOT 虚拟的安装目录
mkdir -p $RPM_BUILD_ROOT/opt/zabbix/script
cp zabbix_agentd $RPM_BUILD_ROOT/opt/zabbix/script/
%pre
killall zabbix_agentd
groupadd zabbix
useradd zabbix -g zabbix -s /sbin/nologin
mkdir -p /var/run/zabbix
mkdir -p /var/log/zabbix
chown -R zabbix:zabbix /var/run/zabbix
chown -R zabbix:zabbix /var/log/zabbix
%preun
if test $(pgrep -f zabbix_agentd | wc -l) -ne 0; then
killall zabbix_agentd ;
fi
chkconfig --del zabbix_agentd
%post
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
#cd /opt/zabbix/etc/
#rm -fr zabbix_agentd.conf
%postun
userdel -r zabbix
rm -rf /tmp/zabbix_agentd.log
echo "success uninstall"
%clean
rm -rf $RPM_BUILD_ROOT
%files
/opt/zabbix/
%changelog
* Thu Aug 29 2013 xbz <[email protected]>
- Add rpm package
本文出自 “xbzy” 博客,谢绝转载!