rpm2cpio 不显示 RPM 软件包中包含的每个文件。

huangapple go评论39阅读模式
英文:

rpm2cpio doesn't show every file included in the RPM package

问题

"whois"软件包使用Linux的"alternatives"系统(因为也许jwhois是一个替代品?)。它似乎将/usr/bin/whois打包为符号链接,但不清楚是如何实现的。运行rpm -qp --list whois-5.5.1-2.el8.x86_64.rpm会显示以下内容:

/etc/whois.conf
/usr/bin/whois
/usr/bin/whois.md
...更多文件...

但是rpm2cpio whois-5.5.1-2.el8.x86_64.rpm | cpio -itv显示了前一个命令中的所有文件,除了 /usr/bin/whois。

运行rpm -qf /usr/bin/whois显示该文件确实由whois软件包提供,这个软件包确实使用了alternatives系统,可以通过运行rpm -qp --scripts whois-5.5.1-2.el8.x86_64.rpm来查看,其中包括:

postinstall脚本(使用/bin/sh):
/usr/sbin/update-alternatives \
    --install /usr/bin/whois \
        whois /usr/bin/whois.md 30 \

然而,这并不能解释为什么/usr/bin/whois不会出现在cpio归档中。我有两种理论,但不知道如何确定哪一种是正确的:

  1. 文件/usr/bin/whois在RPM中是"特殊的",因此它不会出现在rpm2cpio中;或者
  2. Cpio检测到/usr/bin/whois是一个符号链接,它不指向归档中的另一个文件,因此不会列出它。

这是有关Linux的"alternatives"系统的信息收集。我希望制作自己的"alternative",但我不知道是否应该将符号链接包含在RPM中。

英文:

The "whois" package uses the Linux "alternatives" system (because maybe jwhois is an alternative?) It seems to package /usr/bin/whois as a symlink, but it's not clear how that is done. Running rpm -qp --list whois-5.5.1-2.el8.x86_64.rpm gives this:

/etc/whois.conf
/usr/bin/whois
/usr/bin/whois.md
...more files...

However rpm2cpio whois-5.5.1-2.el8.x86_64.rpm | cpio -itv shows all the files from the previous command except /usr/bin/whois.

Running rpm -qf /usr/bin/whois shows that file is indeed provided by the whois package, which does use the alternatives system as can be seen by running rpm -qp --scripts whois-5.5.1-2.el8.x86_64.rpm which includes:

postinstall scriptlet (using /bin/sh):
/usr/sbin/update-alternatives \
    --install /usr/bin/whois \
        whois /usr/bin/whois.md 30 \

However, that does not explain why /usr/bin/whois does not appear in the cpio archive. I have 2 theories, but I don't know how to determine which, if any is the correct one:

  1. The file /usr/bin/whois is "special" in the RPM so it doesn't appear in rpm2cpio; or
  2. Cpio detects that /usr/bin/whois is a symlink that doesn't point to another file in the archive, and thus does not list it.

This is information gathering about the Linux "alternatives" system. I wish to make my own "alternative", but I don't know if I should include the symlink in the RPM.

答案1

得分: 2

文件/usr/bin/whois实际上不包括在RPM中。它是通过对/usr/sbin/update-alternatives的调用生成的。

它似乎被包括进来是因为在规范文件中有一个%ghost指令。这确保了在卸载时它将被删除。

多个软件包可以使用%ghost指令指定相同的文件,rpm -qf将显示它们属于两个软件包,并且只有在两个软件包都被卸载时才会被删除。

英文:

The file /usr/bin/whois is actually not included in the RPM. It is generated by the call to /usr/sbin/update-alternatives.

It appears to be included because of a %ghost directive in the spec file. This ensures that it will be removed on uninstall.

Multiple packages can specify the same file with the %ghost directive, and rpm -qf will show that they belong to both packages, and thus will be removed only when both packages are uninstalled.

huangapple
  • 本文由 发表于 2023年7月14日 04:09:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76682912.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定