Is it possible to modify/rebuild an rpm without the srpm?

I have an rpm for which I need to change the preinstal scriptlet for testing.

However, I do not have the SRPM from which is was built.

Is it possible to change the scriptlet and/or rebuild the rpm without having the SRPM?

If so, how?

I've tried using Midnight Commander (mc) to open the rpm as a directory structure and edit the contents, but even with 666 permissions, it won't let me save any changes.


What is needed is rpmrebuild, which I found via the Red Hat Magazine article.

If you have an rpm for which you only wish to modify the spec file, do the following:

  1. copy the rpm in question to a working directory
  2. run rpmrebuild -e -p <pkg>rpm   (this will open your default editor (typically vi|vim if you haven't made any changes on your rpm-based distro), allowing you to make changes to the spec file)
  3. find the line(s) you wish to change
  4. make changes
  5. save and exit your editor   (Esc:wq! in vi[m], Ctrl-x s in emacs)
  6. rpmrebuild will ask if you want to continue
  7. answer 'yes'
  8. the rebuilt package will show up in /usr/src/redhat/RPMS/<arch>/<pkg>.rpm