Linux 如何查看安装rpm包时执行了哪些操作

时间:2019-11-20 08:52:46  来源:igfitidea点击:

CentOS 安装rpm软件包时,如何查看执行了哪些操作?
Linux如何查看安装软件包时,执行了哪些脚本?

解决方案

Linux 查看rpm软件包安装时运行的脚本:

rpm -qp --scripts filename.rpm

例如,要列出memcached-1.2.8-1.el5.x86_64.rpm的所有脚本,请输入:

$ rpm -qp --scripts nginx-1.8.1-1.el7.ngx.x86_64.rpm

输出示例:

preinstall scriptlet (using /bin/sh):
# Add the "nginx" user
getent group nginx >/dev/null || groupadd -r nginx
getent passwd nginx >/dev/null || \
    useradd -r -g nginx -s /sbin/nologin \
    -d /var/cache/nginx -c "nginx user"  nginx
exit 0
postinstall scriptlet (using /bin/sh):
# Register the nginx service
if [  -eq 1 ]; then
    /usr/bin/systemctl preset nginx.service >/dev/null 2>&1 ||:
    # print site info
    cat <<BANNER
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------
BANNER

    # Touch and set permisions on default log files on installation

    if [ -d /var/log/nginx ]; then
        if [ ! -e /var/log/nginx/access.log ]; then
            touch /var/log/nginx/access.log
            /usr/bin/chmod 640 /var/log/nginx/access.log
            /usr/bin/chown nginx:adm /var/log/nginx/access.log
        fi

        if [ ! -e /var/log/nginx/error.log ]; then
            touch /var/log/nginx/error.log
            /usr/bin/chmod 640 /var/log/nginx/error.log
            /usr/bin/chown nginx:adm /var/log/nginx/error.log
        fi
    fi
fi
preuninstall scriptlet (using /bin/sh):
if [  -eq 0 ]; then
    /usr/bin/systemctl --no-reload disable nginx.service >/dev/null 2>&1 ||:
    /usr/bin/systemctl stop nginx.service >/dev/null 2>&1 ||:
fi
postuninstall scriptlet (using /bin/sh):
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
if [  -ge 1 ]; then
    /sbin/service nginx status  >/dev/null 2>&1 || exit 0
    /sbin/service nginx upgrade >/dev/null 2>&1 || echo \
        "Binary upgrade failed, please check nginx's error.log"
fi

可以看到安装前,安装后,卸载前,卸载后执行的脚本: preinstall,postinstall,preuninstall,postuninstall

要查看已安装软件包的脚本,请输入:

# rpm -q --scripts packageName
# rpm -q --scripts httpd