rpm 安装包制作

rpm 安装包制作

思路 参照系统自带 etcd 解压-》替换掉执行文件-》打包

1 预备安装工具

下载工具 yumloader
#yum install -y yum-utils

解压工具 rmp
打包工具 fpm
yum -y install ruby rubygems ruby-devel
安装fpm
gem install fpm

2 下载

yumdownloader etcd
etcd-2.3.7-4.el7.x86_64.rpm

3 解压

3.1 抽取脚本
rpm -qp --scripts etcd-2.3.7-4.el7.x86_64.rpm

preinstall scriptlet (using /bin/sh):
getent group etcd >/dev/null || groupadd -r etcd
getent passwd etcd >/dev/null || useradd -r -g etcd -d /var/lib/etcd \
-s /sbin/nologin -c "etcd user" etcd
postinstall scriptlet (using /bin/sh): if [ $ -eq ] ; then
# Initial installation
systemctl preset etcd.service >/dev/null >& || :
fi
preuninstall scriptlet (using /bin/sh): if [ $ -eq ] ; then
# Package removal, not upgrade
systemctl --no-reload disable etcd.service > /dev/null >& || :
systemctl stop etcd.service > /dev/null >& || :
fi
postuninstall scriptlet (using /bin/sh): systemctl daemon-reload >/dev/null >& || : #define license tag if not already defined

分别对应生成4个shell文件

postinstall.sh postuninstall.sh preinstall.sh preuninstall.sh

3.2 解压 rpm

mkdir rpmfiles
cp etcd-2.3.7-4.el7.x86_64.rpm rpmfiles
cd rpmfiles
rpm2cpio etcd-2.3.7-4.el7.x86_64.rpm | cpio -idmv

4 替换可执行文件

5 打包

fpm -s dir -t rpm -n "etcd" -v $version --pre-install preinstall.sh --post-install postinstall.sh --pre-uninstall preuninstall.sh --post-uninstall postuninstall.sh etc usr var

上一篇:常用命令(过滤、管道、重定向、ping 命令、netstat 命令、ps命令)


下一篇:【Linux】ping命令详解