Repacking with rpm

On linux, we can repackage the installed rpm, if so. As I remember, rpm can be generated from installed binaries

rpm -??? > my.rpm 

In addition, a later, newer rpm should work on another machine

+4
source share
3 answers

This is possible, but not with the rpm command. I wrote a perl script that does this; it creates a specification file based on rpm -q outputs and performs a “build” that simply copies the installed files from the system.

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

Usage example, mailx rpm:

Request:

 $ 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 

Cancel it:

 $ ./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 

Request a new package:

 $ 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 

The code is not elegant at all, but functional. It copies a lot of rpm information (everything from rpm -qi and most scripts), but this is by no means comprehensive. In addition, it cannot copy the GPG signature and will not have the same checksums as the original RPM file.

NOTE. This is not the “right” way to create and distribute RPM packages, and it is mainly written for troubleshooting and educational purposes.

+2
source

There is also rpmrebuild http://rpmrebuild.sourceforge.net

+3
source

In fact, there is a simple but “complicated” way; it's simple: rpm -e --repackage package-name It will output the RPM to /var/spool/repackage/ .

Example:

 # rpm -e --repackage samba3x-client # file /var/spool/repackage/samba3x-client-3.5.4-0.83.el5_7.2.i386.rpm /var/spool/repackage/samba3x-client-3.5.4-0.83.el5_7.2.i386.rpm: RPM v3 bin i386 samba3x-client-3.5.4-0.83.el5_7 

Why is it difficult? Since it actually deletes the program before packing it, just so you know.

+3
source

Source: https://habr.com/ru/post/1390830/


All Articles