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.
#!/usr/bin/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) for line in spec: if build_re.match(line): for token in line.rsplit(" "): if build_re.match(token): continue if compare_re.match(token): break token = token.rstrip(" ,\n\r") if len(token) > 0: print token if __name__ == "__main__": main()
To use it, save in a file called buildreqs.py and run:
sudo yum install `./buidreqs.py ~/rpmbuild/SPECS/krb5.spec`
There’s always: yum-builddep foo.spec (yes, it can operate on .spec files too)
I knew if I posted this someone would post the right way to do it. Thanks, Rex.
Can be easier and more accurate to use the mock?
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.
Remind back in the days for Mandrake we had urpmi –buildrequires for that
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.