Making rpm package with fpm package under linux
1. Explanation: the function of fpm is to convert one type of package to another.
Source type packages supported by fpm:
Dir: packages that package directories into the required types for source code compilation and installation
Rpm: converting rpm
Gem: converting rubygem packages
Python: package the python module into the appropriate type
Target type packages supported by fpm:
Rpm: converting to rpm package
Deb: converting to deb package
Solari: converting to solaris package
Puppet: converting to pupper package
Common parameters of fpm:
-s: specify the source type
-t: specify the target type, that is, what package you want to make
-n: specify the name of the package
-v: specify the version number of the package
-c: specify the relative path of packaging
-d: specify which packages to depend on
-f: if an installation package with the same name exists in the directory of the second package, overwrite it
-p: the storage path of the produced rpm installation package, which is located in the current directory if not specified
-- post-install: the script to run after the package has been installed
-- post-uninstall: the script to run after the package has been uninstalled
-- pre-install: the script to run before the package installation is complete
-- pre-uninstall: the script to run before the package is uninstalled
-- prefix: the default installation path for finished rpm packages
Second, install fpm
# yum install-y ruby rubygems ruby-devel # you need to install ruby,rubygem before installing fpm
# remove the native ruby repository and add Taobao ruby repository:
# gem sources-add http://gems.ruby-china.com/-remove http://rubygems.org/
Http://gems.ruby-china.com/ added to sources
Http://rubygems.org/ removed from sources
[root@jump ~] # gem sources-l
* CURRENT SOURCES * *
Http://gems.ruby-china.com/
[root@jump ~] # gem install fpm
ERROR: Error installing fpm:
Ffi requires Ruby version > = 1.90. # this error occurs in the installation. Please install ffi,json first. It is also because the ruby version is too low.
# gem install json-v 1.8.0
# gem install ffi-v 1.9.18
# wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.3.tar.gz
# tar xf ruby-2.5.3.tar.gz
# cd ruby-2.5.3
#. / configure-prefix=/usr/local/ruby
# make & & make install
# echo "export PATH=$PATH:/usr/local/ruby/bin" > > / etc/profile
# source / etc/profile
[root@jump ruby-2.5.3] # gem install fpm # the following error occurred while installing fpm
ERROR: Loading command: install (LoadError)
Cannot load such file-zlib
ERROR: While executing gem... (NoMethodError)
Undefined method `invoke_with_build_args' for nil:NilClass
Checked the information because there is no zlib-devel installed.
Install zlib-devel
# yum install-y zlib-devel
# cd ruby-2.5.3/ext/zlib
# ruby. / extconf.rb # the following error occurs in this step: make: * No rule to make target `/ include/ruby.h', needed by `zlib.o'. Stop. Please do this:
# vim ruby-2.5.3/ext/zlib/Makefile
# zlib.o: $(top_srcdir) / include/ruby.h # replace this line with the following line
Zlib.o:.. /.. / include/ruby.h
# make & & make install
# gem install fpm
Fetching: stud-0.0.23.gem (100%)
Successfully installed stud-0.0.23
Fetching: cabin-0.9.0.gem (100%)
Successfully installed cabin-0.9.0
Fetching: clamp-1.0.1.gem (100%)
Successfully installed clamp-1.0.1
Fetching: mustache-0.99.8.gem (100%)
Successfully installed mustache-0.99.8
Fetching: insist-1.0.0.gem (100%)
Successfully installed insist-1.0.0
Fetching: dotenv-2.5.0.gem (100%)
Successfully installed dotenv-2.5.0
Fetching: pleaserun-0.0.30.gem (100%)
Successfully installed pleaserun-0.0.30
Fetching: ffi-1.9.25.gem (100%)
Building native extensions. This could take a while...
Successfully installed ffi-1.9.25
Fetching: io-like-0.3.0.gem (100%)
Successfully installed io-like-0.3.0
Fetching: ruby-xz-0.2.3.gem (100%)
Successfully installed ruby-xz-0.2.3
Fetching: childprocess-0.9.0.gem (100%)
Successfully installed childprocess-0.9.0
Fetching: arr-pm-0.0.10.gem (100%)
Successfully installed arr-pm-0.0.10
Fetching: backports-3.11.4.gem (100%)
Successfully installed backports-3.11.4
Fetching: json-1.8.6.gem (100%)
Building native extensions. This could take a while...
Successfully installed json-1.8.6
Successfully installed fpm-1.10.2
Parsing documentation for stud-0.0.23
Installing ri documentation for stud-0.0.23
Parsing documentation for cabin-0.9.0
Installing ri documentation for cabin-0.9.0
Parsing documentation for clamp-1.0.1
Installing ri documentation for clamp-1.0.1
Parsing documentation for mustache-0.99.8
Installing ri documentation for mustache-0.99.8
Parsing documentation for insist-1.0.0
Installing ri documentation for insist-1.0.0
Parsing documentation for dotenv-2.5.0
Installing ri documentation for dotenv-2.5.0
Parsing documentation for pleaserun-0.0.30
Installing ri documentation for pleaserun-0.0.30
Parsing documentation for ffi-1.9.25
Installing ri documentation for ffi-1.9.25
Parsing documentation for io-like-0.3.0
Installing ri documentation for io-like-0.3.0
Parsing documentation for ruby-xz-0.2.3
Installing ri documentation for ruby-xz-0.2.3
Parsing documentation for childprocess-0.9.0
Installing ri documentation for childprocess-0.9.0
Parsing documentation for arr-pm-0.0.10
Installing ri documentation for arr-pm-0.0.10
Parsing documentation for backports-3.11.4
Installing ri documentation for backports-3.11.4
Parsing documentation for json-1.8.6
Installing ri documentation for json-1.8.6
Parsing documentation for fpm-1.10.2
Installing ri documentation for fpm-1.10.2
Done installing documentation for stud, cabin, clamp, mustache, insist, dotenv, pleaserun, ffi, io-like, ruby-xz, childprocess, arr-pm, backports, json, fpm after 28 seconds
15 gems installed
So far, fpm has been successfully installed.
3. Packing:
# fpm-s dir-t rpm-n nginx- v 1.14.1-d 'pcre-devel,openssl-devel'-- post-install / server/scripts/nginx_rpm.sh-f / application/nginx-1.14.1/