简体   繁体   English

如何使可重定位的rpm?

[英]How To make relocatable rpm?

I have java application with pom.xml. 我有带pom.xml的Java应用程序。 I am making rpm package with prefixes tags . 我正在用前缀标签制作rpm包。

When I am querying on prefix tags of rpm : 当我查询rpm的前缀标签时:

sudo rpm -qp --queryformat "%{prefixes}\n" java-hbase-processor-1.0-SNAPSHOT20160330060627.noarch.rpm 

I got ==> /var 我有==> / var

IF I run following command : 如果我运行以下命令:

rpm -qi java-hbase-processor | grep Relocations

I got : Relocations : /opt /tmp Relocations : /var /tmp 我得到了:重定位:/ opt / tmp重定位:/ var / tmp

All above shows that rpm is relocatable . 以上说明rpm是可重定位的。 But if run install command 但是如果运行install命令

sudo rpm -i --prefix=/home/sohanvir/ java-hbase-processor-1.0-SNAPSHOT20160330060627.noarch.rpm

It will give error with message: 它将显示错误消息:

error: package java-hbase-processor is not relocatable 错误:程序包java-hbase-processor无法重定位

Thanks in advance . 提前致谢 。

According to RPM.org : 根据RPM.org

By default, RPM will install a relocatable package in the prefix directory listed in the spec file. 默认情况下,RPM将在spec文件中列出的前缀目录中安装可重定位的软件包。 You can override this on the RPM install command line with "--prefix <dir> " . 您可以在RPM安装命令行上使用“ --prefix <dir>覆盖它。 For example, if the package in question were going to be installed in "/opt" but you don't have enough disk space there (and it is a relocatable package), you could install it "--prefix /usr/opt" . 例如,如果要安装的软件包要安装在“ / opt”目录下,但是您的磁盘空间不足(并且是可重定位的软件包),则可以将其安装在“ --prefix / usr / opt”目录下

If there is more then one Prefix you may relocate each prefix separately by using syntax like: 如果存在多个前缀,则可以使用以下语法分别重新定位每个前缀:

rpm ... --relocate /opt=/usr/opt --relocate /etc=/usr/etc ...

If any of the Prefixes is not being relocated they can be skipped on the command line 如果没有重新放置任何前缀,则可以在命令行上跳过它们

However, it goes on to say that there are a number of things that can go wrong in building a relocatable RPM (even if you see the Prefix tags). 但是,它继续说在构建可重定位的RPM时可能会有很多错误(即使您看到Prefix标签也是如此)。 If you only want to extract files from the RPM, there are tools for that (such as rpmunpack , rpm2cpio or unrpm ). 如果只想从RPM中提取文件,则可以使用一些工具(例如rpmunpackrpm2cpiounrpm )。

Further reading: 进一步阅读:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM