Board logo

标题: rpm、yum、编译安装轻松管理centos7程序包(9) [打印本页]

作者: look_w    时间: 2019-2-18 20:19     标题: rpm、yum、编译安装轻松管理centos7程序包(9)

8、查询某包安装或卸载时执行脚本;

            rpm -q --scripts PACKAGE_NAME

# rpm -q --scripts zsh
\postinstall scriptlet (using /bin/sh):
if [ "$1" = 1 ]; then
  if [ ! -f /etc/shells ] ; then
    echo "/usr/bin/zsh" > /etc/shells
    echo "/bin/zsh" >> /etc/shells
  else
    grep -q "^/usr/bin/zsh$" /etc/shells || echo "/usr/bin/zsh" >> /etc/shells
    grep -q "^/bin/zsh$" /etc/shells || echo "/bin/zsh" >> /etc/shells
  fi
fi

if [ -f /usr/share/info/zsh.info.gz ]; then
# This is needed so that --excludedocs works.
/sbin/install-info /usr/share/info/zsh.info.gz /usr/share/info/dir \
  --entry="* zsh: (zsh).            An enhanced bourne shell."
fi
preuninstall scriptlet (using /bin/sh):
if [ "$1" = 0 ] ; then
    if [ -f /usr/share/info/zsh.info.gz ]; then
    # This is needed so that --excludedocs works.
    /sbin/install-info --delete /usr/share/info/zsh.info.gz /usr/share/info/dir \
      --entry="* zsh: (zsh).            An enhanced bourne shell."
    fi
fi
postuninstall scriptlet (using /bin/sh):
if [ "$1" = 0 ] && [ -f /etc/shells ] ; then
  sed -i '\!^/usr/bin/zsh$!d' /etc/shells
  sed -i '\!^/bin/zsh$!d' /etc/shells
fi

        脚本有四类:

            preinstall:安装过程开始之前执行的脚本;

            postinstall:安装过程后执行的脚本;

            preuninstall:卸载前执行的脚本;

            postuninstall:卸载过程完成之后执行的脚本;




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0