我们使用RPM来打包和部署我们的产品。 我们的产品依赖于其他组件,如postgresql数据库等,这是在我们的.spec文件中指定的。 比方说,第三方组件的configuration文件之一必须在我们的产品安装之前进行修补(并在卸载后恢复)。 这样做的正确程序是什么? 有什么RPM包的例子可以做同样的事吗?
谢谢!
RPM规格文件支持在安装RPM软件包之前更新任何系统configuration的每个安装( %pre )和安装后( %post )或卸载前( %preun )和卸载后( %postun )脚本或者当它被删除。
你可以检查httpd包的例子,在%pre部分定义添加apache用户, %post部分被定义为在启动时启用httpd服务。
rpm -q --scripts httpd preinstall scriptlet (using /bin/sh): # Add the "apache" user getent group apache >/dev/null || groupadd -g 48 -r apache getent passwd apache >/dev/null || \ useradd -r -u 48 -g apache -s /sbin/nologin \ -d /var/www -c "Apache" apache exit 0 postinstall scriptlet (using /bin/sh): # Register the httpd service /sbin/chkconfig --add httpd /sbin/chkconfig --add htcacheclean preuninstall scriptlet (using /bin/sh): if [ $1 = 0 ]; then /sbin/service httpd stop > /dev/null 2>&1 /sbin/chkconfig --del httpd /sbin/service htcacheclean stop > /dev/null 2>&1 /sbin/chkconfig --del htcacheclean fi posttrans scriptlet (using /bin/sh): test -f /etc/sysconfig/httpd-disable-posttrans || \ /sbin/service httpd condrestart >/dev/null 2>&1 || :
以下是httpd软件包的SPEC文件中的相关部分:
%pre # Add the "apache" user getent group apache >/dev/null || groupadd -g 48 -r apache getent passwd apache >/dev/null || \ useradd -r -u 48 -g apache -s /sbin/nologin \ -d %{contentdir} -c "Apache" apache exit 0 %post # Register the httpd service /sbin/chkconfig --add httpd
我最大的RPM指南是如何做这个东西的权威信息来源。