How to "repackage" a RPM file for example cpio2rpm without installing the RPM?
Asked Answered
R

3

11
  1. I'm able to extract files from a RPM file, but how do I "rebuild" it, for example cpio2rpm?
  2. I have extracted RPM file using following command. rpm2cpio theFileName.rpm | cpio –idmv
  3. I have to modify the few web application files like *.php, *.html or .js. These files don’t require any source recompilation. So I would like to replaces or change these files with modification without rebuilding rpm. Since, I need to do this for multiple platforms like Redhat Linux and SUSE, and multiple architecture like 32 and 64 bit OS.
  4. I am expecting to do these changes on only on system and without rebuild rpm and there would not be have target system architecture dependency (like i386, 64).
  5. I am not looking like command rpmbuild –rebuild the.src.rpm since, I don’t have source. I need to be rebuild binary .RPM file(not source .rpm)
  6. I want to do this without source and platform or architecture independent and without using spec file if possible.

    Any buddy, could you please suggest any solution or any free tools.

    Thank you to all whoever spends time to read and reply to my thread.

Rimrock answered 14/5, 2012 at 9:36 Comment(0)
S
20

You can use rpmrebuild to modify an actual rpm file (it doesn't need to be installed).

Most of the examples for this use complicated inline edit commands to modify known files in particular ways, but you can use a normal editor. I used this to fix a shell script in an rpm file that I didn't have the source for. Call the command as

rpmrebuild -ep theFileName.rpm

This puts you in an editor with the spec file for the RPM. The name of the file will be something like ~/.tmp/rpmrebuild.12839/work/spec.2. If you look in, in this example, ~/.tmp/rpmrebuild.12839/work, you will find all of the files used to make the RPM (in my case, the file was in root/usr/sbin within that directory). So, go to another window, cd to that directory, and edit any files you need to change.

When you have finished editing files, go back to the edit window with the spec file, make any changes you need to that file (I didn't have any, since I wasn't adding or deleting files), save the file, and say "y" to the "Do you want to continue" question. It will then build a new RPM file, and tell you where it has put it (in my case, in ~/rpmbuild/RPMS/x86_64/)

Solingen answered 22/5, 2014 at 17:0 Comment(1)
Great! Is there a way to automate it in some script?Ardatharde
P
1

You can repackage an installed RPM (including modified files) using rpmrebuild. http://rpmrebuild.sourceforge.net/

Obviously your binaries (if any) would have to be platform/architecture independent to work on all the OS flavors you're hoping for, but it sounds like if they're just web files that shouldn't be a problem.

Penetralia answered 24/5, 2012 at 22:0 Comment(0)
C
0

Principially you can pack everything you want into a RPM file. Just treat what you have as "source" and write a SPEC file which puts the data where the compiled binaries would normally go.

Concerning RPM, I consider "source" "what I have" and "binary" "what I need to run". Not very exact terminology, but it helps working with RPMs.

Your spec file looks like any other spec file, what concerns the parameters etc. But the code part is different:

[...]
%prep
# Here you either have nothing to do or you already unpack the cpio and possibly modify it.

# %build can be omitted

%install
[ "${buildroot}" != "/" ] && [ -d ${buildroot} ] && rm -rf ${buildroot};
# Here you can either unpack the cpio or copy the data unpacked in %prep.
# Be careful to put it into %{buildroot} or $RPM_BUILD_ROOT.
Considerate answered 14/5, 2012 at 10:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.