Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good RPM building tool?

I am responsible for building multiple RPMs. I have pristine SPEC files for each RPM package that I need to make, and I have BASH scripts which set up the necessary environment and build the RPMs.

I would like to use an actual build tool, such as make, to build these RPMs. By doing so, I hope to eliminate the need for custom, obfuscating BASH scripts in favor of clear, maintainable configuration files (analogous to make's Makefile). However, using POSIX make and keeping sets of make files up to date is probably as much work as maintaining the BASH scripts I currently use to build the RPM packages. There is a reason for programs like cmake and automake which wrap the capabilities of the make command - These tools are much more expressive, allowing for smaller, cleaner configuration files.

However, using autoconf/automake seems a poor choice as well, as they seem to be specifically built for C and C++ development. It has also been suggested that I use scons, but although this seems the best choice (due to its configuration files being actual python scripts), it too is geared for specific languages.

Using my SPEC files as "source code" and the environment as "dependencies" (such as setting up rpmbuild's directory tree structure needed to make RPMs), is there a good build tool I can use to replace my BASH scripts for a cleaner, more maintainable RPM building solution?

EDIT: It appears I was unclear about what I need when I say "build tool". I already use rpmbuild as the 'compiler' I use to 'compile' RPMs using the SPEC file (and relevant source code for the binaries) as 'source code'. I am asking for a tool which can coordinate that process.

like image 923
djhaskin987 Avatar asked Oct 23 '12 22:10

djhaskin987


1 Answers

Depending on the complexity of what you need to do, SCons could indeed be a good choice. I always find it much easier to script in Python than Bash. But that's also a personal preference.

Here's the pertinent Python/SCons code to generate an RPM in SCons:

env = Environment(tools=['default', 'packaging'])

rpmSourceFiles = ['file1', 'file2'] # This is a Python list
rpmTargetFile = 'yourRpmFile'

env.Package( source         = rpmSourceFiles,
             target         = rpmTargetFile,
             NAME           = 'foo',
             VERSION        = '1.2.3',
             PACKAGEVERSION = 0,
             PACKAGETYPE    = 'rpm',
             LICENSE        = 'gpl',
             SUMMARY        = 'balalalalal',
             DESCRIPTION    = 'this should be really really long',
             X_RPM_GROUP    = 'Application/fu',
             SOURCE_URL     = 'http://foo.org/foo-1.2.3.tar.gz'
        )

You can find the Package() builder documented here. Regarding the rpmSourceFiles, its a Python list and should list the RPM input files. If you used SCons to install these source files, then you can just list there simple names, otherwise you will need to provide absolute paths.

Another option if you just want to use only Python, would be to program RPM directly with Python, as explained here.

like image 91
Brady Avatar answered Sep 19 '22 21:09

Brady