Installing RPM Build Dependencies

If you ever want to build and RPM, you need to make sure that the things it requires are installed. These are listed in the SPEC file on lines that begin with BuildRequires.  Installing these by hand is time consuming enough that it should be automated.  Here’s a first hack in Python.


import sys
import re

build_re = re.compile('BuildRequires:.*')
compare_re = re.compile('.*=.*')

def main():
    if (len(sys.argv) > 1):
        spec = open(sys.argv[1])
        for line in spec:
            if build_re.match(line):
                for token in line.rsplit(" "):
                    if build_re.match(token):
                    if compare_re.match(token):
                    token = token.rstrip(" ,\n\r")
                    if len(token) > 0:
                        print token

if __name__ == "__main__":

To use it, save in a file called and run:

sudo yum install `./ ~/rpmbuild/SPECS/krb5.spec`

6 thoughts on “Installing RPM Build Dependencies

  1. There’s always: yum-builddep foo.spec (yes, it can operate on .spec files too)

  2. Depends on what you are looking to do, but I often have to build on my local machine in order to debug issues, and I don’t need the full mock install. I think mock has its place, but I don’t always want to use it.

  3. That’s what it is called: `yum-builddep’. Two designators I always seem to forget, this and `rpmdevtools’. If not for your blog I’d still be looking.

Leave a Reply

Your email address will not be published. Required fields are marked *