如果specfile中没有满足某些条件,如何中止rpm包的安装? [英] How to abort the installation of an rpm package if some conditions are not met in specfile?

查看:444
本文介绍了如果specfile中没有满足某些条件,如何中止rpm包的安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有一些 Requires 标记不满足的内容。
所以我写了一个脚本来验证这些东西,但我在哪里放置它们?
如果没有找到,那么我想退出安装,提示用户在再次尝试安装此rpm之前执行这些步骤。

There are some more things that the Requires tag does not satisfy. So i wrote a script to verify these things but where do I place them ? And if not found then i want to quit installation prompting user to do the steps before attempting to install this rpm again.

%install 标记中退出1 无法使用rpmbuild构建rpm。
表示%install的退出代码不正确。

编辑:让我举个例子。我最初想要测试的是Oracle Java 6是否存在。如果没有,那么提供Java6的路径。如果用户未能提供一个...退出RPM。不允许使用更高的Java,如果没有java,安装不应该成功。如果用户不想安装java rpm软件包,则无法将其置于需要点。

let me provide you an example. What i initially wanted to test was is if Oracle Java 6 is present. If not then provide the path to Java6. If user fails to provide one ... exit the RPM. Higher Java is not allowed and installation should not be successful without java. Cannot place it in Requires for a point if user does not want to install a java rpm package.

希望我得到我的观点。

推荐答案

您可以将%pre部分用于此类任务。

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


%pre脚本在安装包之前执行。
这是一个罕见的包,需要在
安装之前完成任何事情;包含Red Hat Linux $ 350 $ b Linux 4.0的350个软件包中没有一个可以使用它。

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.

一些入门指南;脚本内容(未在%pre部分中使用)来自jpackage-utils,你会在那里找到一些其他很好的脚本示例:

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

这篇关于如果specfile中没有满足某些条件,如何中止rpm包的安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆