从已安装的rpm重新包装rpm [英] repackage an rpm from an installed rpm

查看:120
本文介绍了从已安装的rpm重新包装rpm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux上,我们可以重新打包已安装的rpm.我记得可以从已安装的二进制文件生成rpm.

On linux can we repackage a installed rpm if so how.I remember that the a rpm can be generated from the installed binaries

  rpm -??? > my.rpm

同样,更新的rpm应该在另一台机器上运行

Also the later i.e, the newer rpm should work on a different machine

推荐答案

这是可能的,但不能使用 rpm 命令.我写了一个perl脚本来做到这一点.它根据 rpm -q 的输出来制作规格文件,并执行构建",仅从系统中复制已安装的文件.

This is possible, but not with the rpm command. I wrote a perl script that does this; it crafts a spec file based on the outputs of rpm -q and does a "build" which just copies the installed files from the system.

您可以在这里找到它: https://github.com/cormander/rogue-beret-tools/blob/master/scripts/rpm-repack

You can find it here: https://github.com/cormander/rogue-beret-tools/blob/master/scripts/rpm-repack

用法示例,重新包装 mailx rpm:

Usage example, re-packaging the mailx rpm:

查询:

$ rpm -ql mailx
/bin/mail
/etc/mail.rc
/usr/bin/Mail
/usr/lib/mail.help
/usr/lib/mail.tildehelp
/usr/share/man/man1/Mail.1.gz
/usr/share/man/man1/mail.1.gz

重新包装:

$ ./rpm-repack -p mailx
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.9773
+ umask 022
+ cd /usr/src/redhat/BUILD
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip
+ /usr/lib/rpm/brp-strip-static-archive
+ /usr/lib/rpm/brp-strip-comment-note
Processing files: mailx-8.1.1-44.2.2
Provides: mailx
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1) libc.so.6(GLIBC_2.3) libc.so.6(GLIBC_2.3.4) libc.so.6(GLIBC_2.4) rtld(GNU_HASH)
Checking for unpackaged file(s): /usr/lib/rpm/check-files /tmp/tlkN4yrYEi
Wrote: ~/rpmbuild/RPMS/i386/mailx-8.1.1-44.2.2.i386.rpm

查询新建软件包:

$ rpm -qpl ~/rpmbuild/RPMS/i386/mailx-8.1.1-44.2.2.i386.rpm
/bin/mail
/etc/mail.rc
/usr/bin/Mail
/usr/lib/mail.help
/usr/lib/mail.tildehelp
/usr/share/man/man1/Mail.1.gz
/usr/share/man/man1/mail.1.gz

代码一点也不优雅,但是可以正常工作.它确实复制了许多rpm信息(所有 rpm -qi 和大多数脚本中的信息),但它并不全面.另外,它不能复制GPG签名,也不能与原始RPM文件具有相同的校验和.

The code isn't at all elegant, but functional. It does copy a lot of the rpm info (everything from rpm -qi and most of the scripts), but it isn't by any means comprehensive. Also, it can't copy the GPG signature, nor will it have the same checksums as the original RPM file.

注意::这不是构建和分发RPM软件包的正确"方法,主要用于故障排除和教育目的.

NOTE: This is not a "proper" way to build and distribute RPM packages, and was mainly written for troubleshooting and educational purposes.

这篇关于从已安装的rpm重新包装rpm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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