Package compiled commands, you can directly install and use
#使用yum可解决依赖问题
[root@localhost ~]# yum -y localinstall *.rpm
First, use the tool directly fpm package.
Fpm installation
fpm is written in ruby, ruby required system environment, and greater than the ruby version 1.8.5
[root@localhost ~]# yum -y install ruby rubygems ruby-devel
View current rubygem warehouse
[root@localhost ~]# gem sources list
Installation fpm, gem like install software from rubygem warehouse yum install.
#CentOS 6 安装方式
[root@localhost ~]# gem install json -v 1.8.3
[root@localhost ~]# gem install fpm -v 1.3.3
#CentOS 7 安装方式
[root@localhost ~]# gem install fpm
fpm common parameters, details see man help.
-s to specify the type of source
-t target type, that is what you want to make package
-n specifies the name of the package
-v specifies the version number of the package
Specify the relative path packaged -C
-d specified which depends on the package
Packaging examples
#把编译好的文件按绝对路径创建相应的目录,并移动到位,如htop命令的目录结构如下
./htop/
└── usr
├── local
│ └── bin
│ └── htop
└── share
├── applications
│ └── htop.desktop
├── man
│ └── man1
│ └── htop.1
└── pixmaps
└── htop.png
#切换目录
[root@localhost ~]# cd htop
#执行fpm打包命令
[root@localhost htop]# fpm -s dir -t rpm -n htop -v 2.2.0 ./usr/
Created package {:path=>"htop-2.2.0-1.x86_64.rpm"}
Rpm package will be generated, in the current directory
[root@localhost htop]# ls
htop-2.2.0-1.x86_64.rpm usr
Use the rpm command to install the package on another server
[root@localhost ~]# rpm -vhi htop-2.2.0-1.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:htop-2.2.0-1 ################################# [100%]
Second, the use rpmbuild tool production
Installation Tools
[root@localhost ~]# yum install rpmdevtools
Performing rpmdev-setuptree generated following working directory rpmbuild
[root@localhost ~]# rpmdev-setuptree
Check the working directory
[root@localhost ~]# tree rpmbuild/
rpmbuild/
├── BUILD #打包过程中的工作目录
├── RPMS #存放生成的二进制包
├── SOURCES #放置打包资源,包括源码打包文件和补丁文件等
├── SPECS #放置SPEC文档
└── SRPMS #存放生成的源码包
Change directory
[root@localhost ~]# cd ~/rpmbuild/SPECS/
Will automatically generate a template, you can modify
[root@localhost SPECS]# vim myrpm.spec
Create a template file subsequent updates.
Package command execution
[root@localhost ~]# rpmbuild -bb htop2.2.0.spec