分享

rpm包制作工具checkinstall

 jas0n_liu 2012-07-12
软件下载地址:
http:///~izto/checkinstall/download.php
本文环境介绍:本文的示例程序是nagios的插件,目的是把nagios的插件编译安装好后压成一个rpm包,便于安装和卸载
1. 首先安装checkinstall程序
[root@localhost ~]# tar zvxf checkinstall-1.6.2.tar.gz
[root@localhost ~]# cd checkinstall-1.6.2
[root@localhost checkinstall-1.6.2]# make
[root@localhost checkinstall-1.6.2]# make install
2.编译安装nagios的插件
[root@localhost srv]# tar zvxf nagios-plugins-1.4.14.tar.gz
[root@localhost srv]# cd nagios-plugins-1.4.14
[root@localhost nagios-plugins-1.4.14]# ./configure --prefix=/usr/local/nagios  --with-named-curses-libs=/usr/lib/libncursesw.so.5
[root@localhost nagios-plugins-1.4.14]# make
3.到此呢,一般编译安装源码包的时候下一就是make install了,此处不用,下一步是运行checkinstall,它会完成make install(默认),可以通过修改配置文件 /usr/local/lib/checkinstall/checkinstallrc 来改变 CheckInstall 的默认配置。INSTYPE 变量决定生成何种类型安装包。INSTALL 变量决定是只生成安装包还是一起将这个包马上安装:0-只生成安装包1-不仅生成安装包,还将包立即安装同时呢,会有一些交互信息,主要的就是叫你选择压制包的格式,有RPM /Debian 或Slackware,记住一定要用sudo即使你是root用户
[root@localhost nagios-plugins-1.4.14]# checkinstall -R --fstrans=no --inspect --review-spec --review-control
交互信息:
     第一步:选择是---y创建默认的软件包描述文件
      第二步:选择R也就是压制成rpm格式的安装包
     第三步:输入一个描述,可以直接回车下一步
     第四步:叫你选择要更改的一些软件包的描述信息,按标号修改响应的设置,如果没有修改直接回车下一步,接下来就是开始make install的过程同时压制rpm包(略)
     第五步:打印出安装的结果,即RPM包的路径和安装方式
4. 进入RPM包的路径看是否打包完成
[root@localhost nagios-plugins-1.4.14]# ls  /usr/src/redhat/RPMS/i386/nagios-plugins-1.4.14.i386.rpm
5.安装rpm包
[root@localhost i386]# rpm -ivh nagios-plugins-1.4.14-1.i386.rpm
6. 查看安装是否完整,打印文件列表
[root@localhost i386]# rpm -ql nagios-plugins-1.4.14-1.i386.rpm
7. 卸载掉安装的rpm包
[root@localhost ~]# rpm -qa |grep nagios
nagios-plugins-1.4.14-1
[root@localhost ~]# rpm -e nagios-plugins

常见错误:
**报错1、:**
*** The "rpmbuild" program is not in your PATH!
解决方法  yum install -y rpm-build
rpm-build 包和  /usr/src/RedHat ,这些 rpm build 的程序是要靠 spec 文件的控制。它是配置指定安装到另外的机器上的,用来指示转换的源码补丁编译成二进制文件的包。默认编译操作是在下面的目录中,它是编译源码的相关动作操作的位置。如果不指定其它的地方,那么 rpm building 的地方是主要在 /usr/src/RedHat 的目录,目录的架构如下,这就是为 rpm-build 提供的目录结构.
如果系统是centos6,2的话需要安装此软件:因为6.2安装rom-build以后不会在/usr/src/下生成RedHat目录
#yum install rpmdevtools
并执行#rpmdev-setuptree  来建立rpm包的存放路径

**报错2、:**
使用rpm -ivh安装生成的rpm包时报错,因为使用 Checkinstall 目前存在的BUG:
*MD5验证的时候会发生错误:
 error: unpacking of archive failed on file /usr/bin/make;4a2ba7ce: cpio:** MD5 sum mismatch**
解决方法:
 rpm -ivh --nomd5 xxxx.rpm

**报错3、:**
注意:对于 64位的系统,制作过程中可能会出现如下错误:
=========================================================
Error with checkinstall on 64 bit system
By jbayer - Last updated: Friday, July 15, 2011
The following error can occur on 64 bit systems when trying to use the checkinstall program:
ERROR: ld.so: object '/usr/local/lib64/installwatch.so’ from LD_PRELOAD cannot be preloaded: ignored.
The problem occurs because the loader can’t find the shared object file.  The solution is very simple.  Assuming that the installwatch.so is
解决方法如下:
located in /usr/local/lib, just type the following commands:
#echo "/usr/local/lib64" >/etc/ld.so.conf.d/installwatch.conf
#dconfig
#ln -s /usr/local/lib/installwatch.so /usr/local/lib64/installwatch.so

**报错5、:**
修改配置文件:
vim /usr/local/lib/checkinstall/checkinstallrc
PAK_DIR="/home/liuyu"        制作后的RPM包存放位置
EXCLUDE="/selinux"             加个注释。否则报错: /selinux/context;48770513: cpio: open failed - Permission denied

报错6、
Building RPM package... FAILED!
*** Failed to build the package
Do you want to see the log file?  [y]: y
error: line 3: Empty tag: Version:
Building target platforms: x86_64
Building for target x86_64
未填写软件版本
Press ENTER to continue.  在此处回车后自己写个版本
Summary:   Package created with checkinstall 1.6.2
Name:      x264
Version:    12312


拓展:
指令 checkinstall 不仅默认运行了 make install,而且还监测所有安装过程中的写操作。为此,CheckInstall 使用了 Pancrazio de Mauro 所写的程序 Installwatch。在 make install 成功完成之后,CheckInstall 会产生一个 Slackware-,Debian- 或RPM- 安装包,然后按照软件包的默认配置来安装程序,并在当前目录(或标准安装包存储目录)留下一个生成的安装包。你可以通过修改变量 PAK_DIR 来修改这个保存目录。
CheckInstall 并不只是使用 make install,它还可以与其他安装指令相协调。例如,如果安装指令为 setup.sh,那么安装指令序列变成:
./configure && make && checkinstall setup.sh 
运行命令“checkinstall –h”显示所有可用的子参数
这些子参数大致分为:
安装选项(Install options) 脚本处理选项(Scripting options) 信息显示选项(Info display options) 安装包选项(Package tuning options) 清除选项(Cleanup options) 关于 CheckInstall (About CheckInstall)。
如果 CheckInstall 带着这些参数运行,它会使用这些参数值来代替配置文件 checkinstallrc 中相应的值。
CheckInstall 也有自己的局限之处。它不能处理静态连接的程序,因为这样 Installwatch 就不能监测到安装过程中修改过文件了。总体说来,有两类连接库:动态的和静态的。这些连接库通过 include 指令整合到程序中。静态连接过的程序已经包含了所有需要的库文件,运行时也就不需要再将这些库载入内存中。这种程序与安装在系统中的连接库无关,因为所谓的连接器(Linker)已经在编译时把这些库内置到可执行程序里了。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多