Linux 的源码安装工具 CheckInstall

Checkinstall 是一个能从 tar.gz 类的

https://www.ibm.com/developerworks/cn/linux/l-cn-checkinstall/

Linux 的源码安装工具 CheckInstall

Checkinstall 是一个能从 tar.gz 类的源代码自动生成 RPM/Debian 或Slackware 安装包的程序。通过 CheckInstall,你就能用几乎所有的 tar.gz 类的源代码来生成“干净”的安装或者卸载包。

2 评论

王 丽娜 (wanglina@cn.ibm.com), 软件工程师, IBM 中国软件开发中心

2008 年 12 月 11 日

  • 内容

在 IBM Bluemix 云平台上开发并部署您的下一个应用。

开始您的试用

引言

经常出现这样的问题:很想试用的程序只有源代码(比如 tar.gz )可用,没人提供 RPM 或者Debian 包。你只好下载源代码,解压,然后手动编译。到目前为止,一切正常。然而,当你想删除它的时候呢?

Makefile 文件只包括了很少情况下的卸载例程。当然,你可以把程序安装到临时文件夹,然后记下所有由程序生成或修改的文件,最后删除他们。但是如果这个程序要经常重新编译,这样做是非常痛苦的,工作量也相当大。Felipe Eduardo 所写的 CheckInstall 就是用来解决这个问题的。

 

回页首

用 GNU Autoconf 安装程序

一般说来,我们编译安装一个由 GNU Autoconf 配置的程序是采用如下的步骤:

./configure && make && make install

这个 configure 脚本文件是用来“猜”出一系列系统相关的变量,这些变量是在后面的编译过程要用到的。它将检查系统变量值是否满足编译要求,然后使用这些变量在程序包内每个文件夹下生成 Makefile。此外,configure 脚本还会生成其它文件:

  • 每个文件夹/子文件夹下的一个或多个 Makefile(s)
  • 一个名叫 config.status 的脚本
  • 一个文本文件 config.log

Configure 脚本文件成功运行之后, 你会输入 make 来编译程序,得到你需要的可执行文件。如果 make 成功的完成,你可以使用 make install 来安装这个程序。

 

回页首

用 CheckInstall 安装程序

上节我们采用 GNU Autoconf 来编译程序,现在该是换一种方式的时候了。你可以使用CheckInstall 工具。它采用自己的指令 checkinstall 来代替 make install。其他两个指令保留下来跟以前一样,因此,现在这个指令序列使用 CheckInstall 变成:

./configure && make && checkinstall

指令 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 带着很多参数运行。

图 1. 运行命令“checkinstall –h”显示所有可用的子参数

 

这些子参数大致分为:

  • 安装选项(Install options)
  • 脚本处理选项(Scripting options)
  • 信息显示选项(Info display options)
  • 安装包选项(Package tuning options)
  • 清除选项(Cleanup options)
  • 关于 CheckInstall (About CheckInstall)。

如果 CheckInstall 带着这些参数运行,它会使用这些参数值来代替配置文件 checkinstallrc 中相应的值。

CheckInstall 也有自己的局限之处。它不能处理静态连接的程序,因为这样 Installwatch 就不能监测到安装过程中修改过文件了。总体说来,有两类连接库:动态的和静态的。这些连接库通过 include 指令整合到程序中。静态连接过的程序已经包含了所有需要的库文件,运行时也就不需要再将这些库载入内存中。这种程序与安装在系统中的连接库无关,因为所谓的连接器(Linker)已经在编译时把这些库内置到可执行程序里了。

 

回页首

CheckInstall 的安装

我们可以在 CheckInstall 的主页上下载各种预编译好的安装包或者合适的源码包。下面将展示安装最新的源代码 checkinstall-1.6.1.tgz 的全过程。这会安装上 CheckInstall、Installwatch和 makepak,其中 makepak 是 makepkg 的修改版。如果你对新版本的改进感兴趣,请参看Release Notes 和 Changelog。

清单 1. 生成 checkinstall 的 rpm 安装包
# tar xzf checkinstall-1.6.1.tgz
# cd checkinstall-1.6.1
checkinstall-1.6.1# make
checkinstall-1.6.1# make install
checkinstall-1.6.1# checkinstall
图 2. 运行命令“checkinstall”生成 rpm 包的图示过程

图 2.1. 过程一

图 2.2. 过程二

图 2.3. 过程三

checkinstall-1.6.1 的 rpm 包已经生成,我们用 rpm 来安装它。

清单 2. 用生成的 rpm 包安装 checkinstall
checkinstall-1.6.1# cd /usr/src/redhat/RPMS/i386/
i386# rpm -i checkinstall-1.6.1.rpm

checkinstall-1.6.1 安装完毕。使用包管理程序的查询语句,你可以检查安装包中文件是否完全在程序库中记录了,还可以查看安装包头部的一些额外信息。

图 3. 检查 checkinstall 的 RPM 包

 

回页首

CheckInstall 的配置

你可以通过修改配置文件 /usr/local/lib/checkinstall/checkinstallrc 来改变 CheckInstall 的默认配置。

文件值得注意的变量有 INSTYPE,INSTALL 和 PAK_DIR。

INSTYPE 变量决定生成何种类型安装包。

图 4. 查看变量 INSTYPE

PAK_DIR 变量决定安装包的存储目录。

图 5. 查看变量 PAK_DIR

INSTALL 变量决定是只生成安装包还是一起将这个包马上安装。

0-只生成安装包

1-不仅生成安装包,还将包立即安装

图 6. 查看变量 INSTALL

 

回页首

用 CheckInstall 制作 RPM 包实例

上两节我们把 Checkinstall 安装配置完成,这节以 squid-2.6.STABLE12.tar.bz2 为例,说明用checkinstall 制作编译成 squid-2.6.STABLE12-1.i386.rpm 包的具体方法。

清单 3. 生成 squid-2.6.STABLE12 的 rpm 安装包
# tar jxvf squid-2.6.STABLE12.tar.bz2
# cd squid-2.6.STABLE12
squid-2.6.STABLE12# ./configure --prefix=/usr/local/squid --sysconfdir=/etc \
--enable-arp-acl --enable-linux-netfilter -enable-err-language="Simplify_Chinese" \
--enable-storeio=ufs --enable-default-err-language="Simplify_Chinese" \
--enable-auth="basic" --enable-baisc-auth-helpers="NCSA" --enable-underscore
squid-2.6.STABLE12# make
squid-2.6.STABLE12# checkinstall

生成 rpm 包期间会出现一些选项,选择默认的即可。

图 7. 运行命令“checkinstall”生成 rpm 包的图示过程

图 7.1. 过程一

图 7.2. 过程二

图 7.3. 过程三

图 7.4. 过程四

清单 4. 用生成的 rpm 包安装 squid-2.6.STABLE12
squid-2.6.STABLE12# cd /usr/src/redhat/RPMS/i386/
i386# rpm -ivh squid-2.6.STABLE12-1.i386.rpm
图 8. 检查 squid-2.6.STABLE12 的 RPM 包

 

回页首

结束

CheckInstall 是一款优秀的源码安装软件,它使得 Linux 软件管理更加方便。特别是在源码需要经常重复编译的情况下,CheckInstall 可以让你丝毫不破坏系统一致性的前提下完全的卸载程序。而且,你还可以使用这些编译好的安装包直接在其他的机器上安装无须再重新编译。

使用checkinstall 生成rpm报错

http://shugao.blog.51cto.com/2396914/1360193/

1编译报 msgfmt not found,解决方法

此问题的解决方法:只需要安装gettext包即可

2 make报错


  1. installwatch.c:2942: error: conflicting types for 'readlink'

  2. /usr/include/unistd.h:828: note: previous declaration of 'readlink' was here

  3. installwatch.c:3080: error: conflicting types for 'scandir'

  4. /usr/include/dirent.h:252: note: previous declaration of 'scandir' was here

  5. installwatch.c:3692: error: conflicting types for 'scandir64'

  6. /usr/include/dirent.h:275: note: previous declaration of 'scandir64' was here

vim installwatch/installwatch.c

at line 101, change: 
static int (*true_scandir)( const char *,struct dirent ***,
   int (*)(const struct dirent *),
   int (*)(const void *,const void *));

to: 
static int (*true_scandir)( const char *,struct dirent ***,
   int (*)(const struct dirent *),
   int (*)(const struct dirent **,const struct dirent **));

at line 121, change: 
static int (*true_scandir64)( const char *,struct dirent64 ***,
   int (*)(const struct dirent64 *),
   int (*)(const void *,const void *));

to: 
static int (*true_scandir64)( const char *,struct dirent64 ***,
   int (*)(const struct dirent64 *),
   int (*)(const struct dirent64 **,const struct dirent64 **));

at line 2941, change:
#if (GLIBC_MINOR <= 4)
to:
#if (0) 
at line 3080, change: 
int scandir( const char *dir,struct dirent ***namelist,
 int (*select)(const struct dirent *),
 int (*compar)(const void *,const void *) ) {

to: 
int scandir( const char *dir,struct dirent ***namelist,
 int (*select)(const struct dirent *),
 int (*compar)(const struct dirent **,const struct dirent **) ) {

at line 3692, change: 
int scandir64( const char *dir,struct dirent64 ***namelist,
 int (*select)(const struct dirent64 *),
 int (*compar)(const void *,const void *) ) {

to: 
int scandir64( const char *dir,struct dirent64 ***namelist,
 int (*select)(const struct dirent64 *),
 int (*compar)(const struct dirent64 **,const struct dirent64 **) ) {
完成后make
直接make install 虽然不会报错但是在使用checkinstall 的时候,会报错
“checkinstall error: File not found: /root/rpmbuild/BUILDROOT/”这种蛋疼的错误;

vim checkinstall
at line 495, change: CHECKINSTALLRC=${CHECKINSTALLRC:-${INSTALLDIR}/checkinstallrc}
to:
CHECKINSTALLRC=${CHECKINSTALLRC:-${INSTALLDIR}/lib/checkinstall/checkinstallrc}

at line 2466, change: $RPMBUILD -bb ${RPM_TARGET_FLAG}${ARCHITECTURE} "$SPEC_PATH" &> ${TMP_DIR}/rpmbuild.log
to:
$RPMBUILD -bb ${RPM_TARGET_FLAG}${ARCHITECTURE} --buildroot $BROOTPATH "$SPEC_PATH" &> ${TMP_DIR}/rpmbuild.log 
Now, as root, run:
make install

在使用makeinstall 的时候如果报“/root/rpmbuild has no SOURCES driectory”的错误,执行mkdir -p /root/rpmbuild/SOURCES命令;

转载:http://thinkman.blog.51cto.com/4217028/1135049

rpm-build安装以及打包

http://blog.csdn.net/wisgood/article/details/42988235

1,查找rpm-build,并安装

 
1)yum 安装
 
yum list |grep rpm-build 查找合适的rpm-build包
yum install -y rpm-build.x86_64 
 
2)非yum 安装 
如果没有yum源,可以先将rpm-build.rpm 下载到本地,下载rpm-build的时候,需要安装和操作系统版本一致的。否则会提示错误。比如我的系统如下: 
 
Linux sjs_78_213 2.6.32-220.17.1.el6.x86_64 #1 SMP Thu Apr 26 13:37:13 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux 
 
对应的rpm包是 :rpm-build-4.8.0-19.el6_2.1.x86_64.rpm  。
查找rpm包可以到 http://rpm.pbone.net/  
 
下载rpm包 : 
 
 
 
2,创建一个普通用户,以普通用户打包
最好以普通用户打包,否则会有一些稀奇古怪的问题。
adduser wang 
su - wang
mkdir -p /home/wang/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
 
echo "%_topdir  /home/wang/rpmbuild" >~/.rpmmacros  
 
rpmbuild --showrc|grep _topdir
 
cd  /home/wang/rpmbuild/SPECS 
rpmbuild -ba  dteworker-client.spec  
 
一个完整的rpmbuild目录可以下载http://download.csdn.net/detail/wisgood/8384763,然后解压,打包即可。

参考:

CheckInstall安装与使用指南

https://www.aliyun.com/zixun/content/3_12_513777.html

Centos使用checkinstall制作RPM包的方法

http://www.111cn.net/sys/CentOS/61169.htm

Linux下轻松实现源码打包安装
本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2011-04/34144.htm

(转载)Linux如何编译安装源码包软件

http://www.cnblogs.com/pudao/p/5129513.html

Linux 环境下源码打包RPM过程记录

http://blog.sina.com.cn/s/blog_4535337e0102v43t.html

CentOS下将软件源码打包为RPM的方法
详细请参考:http://www.codesky.net/article/201703/182431.html

源码下载url:

checkinstall-1.6.2-8.1 RPM for x86_64

http://rpmfind.net/linux/RPM/opensuse/11.4/x86_64/checkinstall-1.6.2-8.1.x86_64.html

rpm-build-5.4.10-10 RPM for x86_64

http://rpmfind.net/linux/RPM/mandriva/devel/cooker/x86_64/media/main/release/rpm-build-5.4.10-10.x86_64.html

http://asic-linux.com.mx/~izto/checkinstall/download.php

http://www.slackware.com/~alien/slackbuilds/checkinstall/build/

Linux 的源码安装工具 CheckInstall的更多相关文章

  1. Atitit. 查找linux 项目源码位置

    Atitit. 查找linux 项目源码位置 1. netstat   -anp |grep 801 1.1. 1.3 启动关闭nginx3 1.2. 找到nginx配置文件4 1.3. ./etc/ ...

  2. SourceInsight 精确导入Linux kernel源码的方法

    相信有很多人用 SourceInsight 查看 Linux Kernel 源码,但导入源码时会遇到一些问题.1.如果把整个源码树都导入进去,查看符号定义的时候,会发现有大量重复定义,很难找到正确的位 ...

  3. Linux内核源码分析方法

    一.内核源码之我见 Linux内核代码的庞大令不少人“望而生畏”,也正因为如此,使得人们对Linux的了解仅处于泛泛的层次.如果想透析Linux,深入操作系统的本质,阅读内核源码是最有效的途径.我们都 ...

  4. linux内核源码注解

    轻松学习Linux操作系统内核源码的方法 针对好多Linux 爱好者对内核很有兴趣却无从下口,本文旨在介绍一种解读linux内核源码的入门方法,而不是解说linux复杂的内核机制:一.核心源程序的文件 ...

  5. ubuntu下linux内核源码阅读工具和调试方法总结

    http://blog.chinaunix.net/uid-20940095-id-66148.html 一 linux内核源码阅读工具 windows下当然首选source insight, 但是l ...

  6. Linux基础系列—Linux内核源码目录结构

    /** ****************************************************************************** * @author    暴走的小 ...

  7. Linux内核源码分析--内核启动之(3)Image内核启动(C语言部分)(Linux-3.0 ARMv7)

    http://blog.chinaunix.net/uid-20543672-id-3157283.html Linux内核源码分析--内核启动之(3)Image内核启动(C语言部分)(Linux-3 ...

  8. Linux内核源码分析 day01——内存寻址

    前言 Linux内核源码分析 Antz系统编写已经开始了内核部分了,在编写时同时也参考学习一点Linux内核知识. 自制Antz操作系统 一个自制的操作系统,Antz .半图形化半命令式系统,同时嵌入 ...

  9. linux内存源码分析 - 零散知识点

    本文为原创,转载请注明:http://www.cnblogs.com/tolimit/ 直接内存回收中的等待队列 内存回收详解见linux内存源码分析 - 内存回收(整体流程),在直接内存回收过程中, ...

随机推荐

  1. lua敏感词过滤

    --过滤敏感词(如果onlyKnowHas为true,表示只想知道是否存在敏感词,不会返回过滤后的敏感词,比如用户注册的时候,我们程序是只想知道用户取的姓名是否包含敏感词的(这样也能提高效率,检测到有 ...

  2. 九度OJ--Q1473

    import java.util.ArrayList;import java.util.Scanner; /* * 题目描述: * 大家都知道,数据在计算机里中存储是以二进制的形式存储的. * 有一天 ...

  3. winform 控件大小随着窗体自适应

    3个方法: #region 控件缩放变量        double formWidth;//窗体原始宽度        double formHeight;//窗体原始高度        doubl ...

  4. 【南开OJ2264】节操大师(贪心+二分+并查集/平衡树)

    好久没更新了,今天就随便写一个吧 题目内容 MK和他的小伙伴们(共n人,且保证n为2的正整数幂)想要比试一下谁更有节操,于是他们组织了一场节操淘汰赛.他们的比赛规则简单而暴力:两人的节操正面相撞,碎的 ...

  5. [Leetcode] Path Sum路径和

    Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...

  6. 【BZOJ 1724】[Usaco2006 Nov]Fence Repair 切割木板 堆+贪心

    堆对于stl priority_queue ,我们自己定义的类自己重载<,对于非自定义类我们默认大根堆,如若改成小根堆则写成std::priority<int,vector<int& ...

  7. JQuery队列queue与原生模仿其实现

    jQuery中的queue和dequeue是一组很有用的方法,他们对于一系列需要按次序运行的函数特别有用.特别animate动画,ajax,以及timeout等需要一定时间的函数. queue() 方 ...

  8. Why is the ibdata1 file continuously growing in MySQL?

    We receive this question about the ibdata1 file in MySQL very often in Percona Support. The panic st ...

  9. nginx,docker反向代理

    1. [root@javanginx ~]# cat /etc/nginx/nginx.conf user root root;worker_processes 4;error_log /var/lo ...

  10. idea使用(一)

    基本上正式开发的常用工具基本都集成了,而且基本都在你非常容易触到的位置.说说我比较常用的: 1.ant 你懂的 2.maven你也懂的 3.SVN相比之下,IDEA的SVN的提交提供了更多的选项和功能 ...