|
|
Building RPMs in SCons
Here's a recipe I've developed for building a RPM in SCons with out
too much mucking around. My big issue with RPM is the whole
/usr/src/redhat thing which is silly from a permissions point
of view, and also prevent multiple users on the same machine from
building at the same time.
import string, os
# Sources for RPM
arch = 'i386'
sources = [
'foo.spec',
'foo-upstream.tar.gz',
'bippity.patch',
'flippity.patch',
]
# Create RPM build environment
env = Environment()
env.Append(
ENV = {'HOME': os.environ['HOME']},
TARFLAGS = '-z')
# Build tar file of sources
tarfile = env.Tar(
'foo.tar.gz',
sources)
# Build RPM from tarfile with included spec
rpm_defines = {
'_topdir': Dir('#build').abspath,
}
rpm = env.Command(
'rpm_dummy',
tarfile,
'rpmbuild %s -tb %s' % (
string.join(['--define "%s %s" ' % (i[0], i[1])
for i in rpm_defines.items()], ' '),
tarfile[0]))
# Take care of creating and removing various temporary directories
# required by RPM.
env.AddPreAction(rpm, Delete('#build'))
env.AddPreAction(rpm, [Mkdir('#build/SPECS'),
Mkdir('#build/BUILD'),
Mkdir('#build/RPMS/%s' % arch)])
env.AddPostAction(rpm, [Delete('#build/BUILD'),
Delete('#build/SPECS')])
# Clean up after ourselves
env.Clean(rpm, ['#build/BUILD', '#build/SRPMS', '#build/RPMS'])
I like the use of pre and post actions here to create the
directory structure expected by RPM and the cleanup of it afterwards.
Running scons -c will delete all the generated RPM files as well
as the tar file of sources.
Oh yeah, installing and using ccache
is absolutely essential for debugging RPM files. posted at: 12:58 | path: /software/scons | permanent link to this entry | |