How to abort the installation of an rpm package if some conditions are not met in specfile?

时间秒杀一切 提交于 2019-12-02 01:41:07

You can use the %pre section for this kind of task.

The %pre script executes just before the package is to be installed. It is the rare package that requires anything to be done prior to installation; none of the 350 packages that comprise Red Hat Linux Linux 4.0 make use of it.

Some guide to get you started; the script content (not used in a %pre section) comes from jpackage-utils, you will find some other good examples of scripts there:

  %pre
  # try to find jvm from java command

  # try javac first, or we might get the location of the jre instead - djw
  java=`which javac 2>/dev/null || :`

  # if we don't have the jdk, then maybe we have the jre - djw
  if [ -z "$java" ] ; then
    java=`which java 2>/dev/null || :`
  fi

  if [ -n "$java" ] ; then
    while [ -h "$java" ] ; do
      java=`readlink $java 2>/dev/null`
    done
    return
  fi

  echo "Can't find java virtual machine, aborting."
  exit 1
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!