一.需求分析
一直以来都有这么个想法:如何才能把压缩包文件,如tar.gz等的源代码自动转换
为RPM形式的安装包程序呢?这样做的好处是可以节省很长的工具编译时间。
二.测试环境
CentOS 5.3 i386
三.制作过程
在网上查了些资料,发现可以使用checkinstall 工具来实现此功能,在本例子中将把
nagios 的插件编译安装好后压成一个rpm包,便于安装和卸载。
1.安装工具
root@test ~: tar zxf checkinstall-1.6.2.tar.gz
root@test ~: cd checkinstall-1.6.2/
root@test ~: make && make install
2.编译安装插件
root@test ~: tar zxf nagios-plugins-1.4.14.tar.gz
root@test ~: cd nagios-plugins-1.4.14 /
root@test ~: ./configure – - prefix=/usr/local/nagios
root@test ~: make
到此呢,一般编译安装源码包的时候下一步就是make install 了,此处不需要,这里运
行checkinstall ,它会完成make install ,同时会有一些交互信息,主要就是叫你选择压缩
包的格式,有RPM/Debian/Slackware。
备注:
这里要记住的是一定要用sudo 即使你是root用户。由于此程序需要调用rpm-build
程序,如果系统没安装此工具,请执行yum install rpm-build进行安装
如下所示:
root@test ~: sudo checkinstall
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.
The checkinstallrc file was not found at:
/usr/local/sbin/../checkinstallrc
Assuming default values.
The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]: y
Preparing package documentation...OK
Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? R
Please write a description for the package.
End your description with an empty line or EOF.
>> This is the nagios plugins
**************************************
**** RPM package creation selected ***
**************************************
This package will be built according to these values:
1 - Summary: [ This is the nagios plugins ]
2 - Name: [ nagios-plugins ]
3 - Version: [ 1.4.14 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ nagios-plugins-1.4.14 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ nagios-plugins ]
Enter a number to change any of them or press ENTER to continue:
你可以选择修改软件包的描述信息,如果没有修改的话可以直接回车下一步,接下来
就是开始make install 的过程同时制作rpm包。
直到出现下面的信息才说明rpm包制作完成了:
Done. The new package has been saved to
/usr/src/redhat/RPMS/i386/nagios-plugins-1.4.14-1.i386.rpm
You can install it in your system anytime using:
rpm -i nagios-plugins-1.4.14-1.i386.rpm
3.验证包完整性
root@test ~: cd /usr/src/redhat/RPMS/i386/
root@test ~: ls -l
-rw-r--r-- 1 root root 655298 Sep 25 12:23 nagios-plugins-1.4.14-1.i386.rpm
安装RPM包:
root@test ~: rpm -ivh nagios-plugins-1.4.14-1.i386.rpm
验证包完整性:
root@test ~: rpm -ql nagios-plugins
卸载安装包:
root@test ~: rpm -e nagios-plugins
阅读(2682) | 评论(0) | 转发(0) |