Clean up your spec files!

Modern RPMs don’t need any of the following. You can just delete them:

  • %clean
  • %defattr
  • rm -rf $RPM_BUILD_ROOT or rm -rf %{buildroot}
  • BuildRoot
  • Group (thanks bochecha)


Filed under Uncategorized

7 responses to “Clean up your spec files!

  1. bochecha

    Don’t forget Group !

  2. Peter

    But they do help if you need to maintain packages for EPEL too.

    • rich

      I think some (all?) of these will work for EPEL 6, but none of them for EPEL 5.

      I’ve never been a particular fan of the whole “nested %if” style of keeping a single RPM that builds on every branch. In fact, this set me thinking that it ought to be possible to not do that, but to reconstruct the nested-if version from the branches using git, diff, and possibly a custom tool:

      $ rpm-diff el6/foo.spec master/foo.spec
      Name: foo
      %if 0%{rhel} = 6
      Version: 1.1
      Version: 2.0
  3. c janscen

    Yeah. RPM spec files are in general a complete cargo-mess. People copy things from decades old RPMs, do way too much in %post and %pre, and generally just get something barely working and never check the .spec or RPM with rpmlint (which BTW, should be the style and quality gatekeeper for the distro it is run on).

    I think this comes mostly from the fact that there are no modern books on creating RPMs, everything is from a decade ago and half of the practices and examples are obsolete. Ditto for online tutorials and examples.

    • rich

      I think there are two actionable items here:

      (a) Someone writes a good, modern book on RPM. Panu, we’re waiting!

      (b) We run rpmlint over the whole of Fedora and start fixing cruft.

      Most spec files that I find aren’t terribly bad, with one notable exception: kernel.spec, I’m looking at you. There surely must be a way to tame the utter complexity in this file. (And the Fedora file is positively sane compared to the RHEL version …)

  4. Ian Pilcher

    So does anyone know which of these crufty items (if any) are needed for EL6-compatible SPEC files?

    • rich

      I think most can be junked for EL6 (but not for EL5). But as I said in a comment above, I wouldn’t try to have a single spec file that works across every Fedora and RHEL. Also I’m not over-concerned about cleaning up spec files in old EL branches for the sake of it. Get it right in Rawhide now, and gradually EL 7+ will fix themselves.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.