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.

  • 444 permissions are just "everybody can read"; no write permissions there. you need 7 for read-write-execute -- 700 for you, 777 for everybody. – quack quixote Apr 21 '10 at 13:17
  • @quack quixote - I meant '666', fixing now – warren Apr 21 '10 at 13:40
  • yeah, 444 does look a lot ... less evil, doesn't it? :) – quack quixote Apr 21 '10 at 13:46
  • @quack quixote - it does indeed :) – warren Apr 21 '10 at 14:16

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
| improve this answer | |
  • and the downvote is for ...? – warren Mar 20 '15 at 2:24
  • 1
    doesn't work, I don't know why – Ahmed Sep 30 '16 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.