fpm制作rpm包

1、安装ruby

官网下载地址:下载 Ruby (ruby-lang.org)

cd /usr/local/src/
wget https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.1.tar.gz
tar xf ruby-3.0.1.tar.gz 
cd ruby-3.0.1/
./configure --prefix=/usr/local/
make -j8
make install
ruby -v

Ruby 的默认源更换:

gem source -r https://rubygems.org/
gem source -a https://gems.ruby-china.com/

2、安装fpm

gem install fpm

3、制作rpm包:

源码安装openssl后在使用fpm制作rpm包。
官方网站:下载源码包

创建构建目录

mkdir -p /BUILDROOT/usr/{bin,include,lib,share,ssl} /BUILDROOT/etc/pki/tls/ /BUILD/
cd /BUILDROOT && ln -s usr/bin/ bin && ln -s usr/lib/ lib && ln -s etc/pki/tls/ ssl
[root@x86-01 ~]# ll /BUILDROOT/
总用量 0
lrwxrwxrwx 1 root root  8 6月  30 16:28 bin -> usr/bin/
drwxr-xr-x 3 root root 17 6月  30 16:28 etc
lrwxrwxrwx 1 root root 12 6月  30 16:43 include -> usr/include/
lrwxrwxrwx 1 root root  8 6月  30 16:29 lib -> usr/lib/
lrwxrwxrwx 1 root root 10 6月  30 16:43 share -> usr/share/
lrwxrwxrwx 1 root root 12 6月  30 16:57 ssl -> etc/pki/ssl/
drwxr-xr-x 7 root root 67 6月  30 16:28 usr

源码编译目录:/BUILD/

cd /BUILD/
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar zxvf openssl-1.1.1k.tar.gz -C /BUILD/
cd /BUILD//openssl-1.1.1k/
./configure --prefix=/BUILDROOT/
make -j8
make install

打包openssl目录:/BUILDROOT

fpm -f -s dir -t rpm -n openssl -v 1.1.1k --iteration 1.axs7 -C /BUILDROOT -p /root --verbose \
--provides 'libcrypto.so.1.1()(64bit)  libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) libcrypto.so.1.1(OPENSSL_1_1_1)(64bit) ' \
--after-install install.sh \
--category 'System Environment/Libraries' \
--license 'OpenSSL License and SSLeay License' \
-m 'RedFlag BuildSystem ' \
--vendor RedFlag --url 'https://www.openssl.org/' \
--rpm-summary 'Utilities from the general purpose cryptography library with TLS implementation'  \
--description 'The OpenSSL toolkit provides support for secure communications betweenmachines. 
OpenSSL includes a certificate management tool and sharedlibraries which provide
various cryptographic algorithms and protocols.' --no-rpm-sign usr/bin usr/lib usr/share usr/include etc/pki/ssl/


fpm -f -s dir -t rpm -n openssl-devel -v 1.1.1k --iteration 1.axs7 -C /BUILDROOT -p /root --verbose \
 --after-install install.sh \
--category 'System Environment/Libraries' \
--license 'OpenSSL License and SSLeay License' \
-m 'RedFlag BuildSystem ' \
--vendor RedFlag --url 'https://www.openssl.org/' \
--rpm-summary 'Utilities from the general purpose cryptography library with TLS implementation'  \
--description 'The OpenSSL toolkit provides support for secure communications betweenmachines. 
OpenSSL includes a certificate management tool and sharedlibraries which provide
various cryptographic algorithms and protocols.' --no-rpm-sign usr/share usr/include

# 生成RPM注意usr/bin usr/lib usr/share这些就是需要打包的数据目录

rpm -qpi /root/nodejs-0.10.12-1.el6.x86_64.rpm # 查看RPM包信息

参数含义:
-s 指定INPUT的数据类型
-t 指定需要制作成什么包,可选项有(deb, rpm, solaris, etc)
-n 包名
--iteration 也就是rpm包里面的release
-C 就是打包的相对路径,类似于buildroot。譬如-C /usr/local/openssl而打包机器的数据包路径是/usr/local/openssl/usr/bin/openssl那安装这个rpm包后,在本地的数据就是/usr/bin/openssl
--after-install 安装包后要运行的脚本
--provides 这个包提供了什么

你可能感兴趣的:(fpm制作rpm包)