dir Pack the directory into the required type. Can be used to compile and install software packages from source code
FPM installation process
Install ruby support module
yum install ruby rubygems ruby-devel -y
Add Alibaba Cloud's rubygems warehouse, foreign sources are slower
gem sources - a
Remove the source ruby repository
gem sources --remove
Install fpm
gem install fpm -v 1.4.0
ERROR: Error installing fpm:
json requires Ruby version >= 1.9. 3.
Similar to this kind of error, many netizens recommend upgrading ruby. I have also tried it, saying that there are many pitfalls and not recommended.
is actually not fpm or ruby. The problem is that the default version of json in the system is too high, causing ruby 1.8.7 to be unable to support it. The json version needs to be lowered
gem install json -v 1.8.3
After installing json, just install fpm
In addition, the default ruby version in centos7.x is higher and there is no such problem
fpm command
Common parameters:
-s specifies the source type, such as dir
-t specifies the target type, such as rpm
-n specifies the package name
-v specifies the version number of the package
-C specifies the relative path of the package
-d specifies which packages it depends on
-f If there is a package with the same name in the directory when packaging for the second time, it will be overwritten
-p Output the directory of the installation package, if not specified, it will be the current one Directory
--post-install The script to be executed after the software package is installed is the same as: --after-install
--pre-install The script to be executed before the software package is installed. Same as: --before-install
--post-uninstall The script to be executed after the software package is uninstalled is the same as: --after-remove
--pre-uninstall The software package is uninstalled The script to be executed before is the same as: --before-remove
The fpm command actually encapsulates the rpmbuild command. In fact, the lower level is still the rpmbuild command, so the system must have the rpmbuild command.
If the fpm command cannot run, you can check whether rpm-build is installed. yum install rpm-build -y
Packaging command example:
fpm -s dir -t rpm -n nginx -v 1.6.3 -d 'pcre-devel,openssl-devel' --post-install /home/root/scripts/nginx.sh /usr/local/nginx-1.6.3/
/usr/local/nginx-1.6.3/ 为nginx的安装目录
/home/root/scripts/nginx.sh 为nginx安装后要执行的脚本,如创建用户、创建软链接
Notes:
1. Packaging path, absolute path is recommended
2. It is recommended to package the actual path. When packaging a soft link, there must be / after it. Without /, it refers to the soft link file. Adding / refers to the directory