summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Tool/packaging
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Tool/packaging')
-rw-r--r--src/engine/SCons/Tool/packaging/__init__.py187
-rw-r--r--src/engine/SCons/Tool/packaging/ipk.py8
-rw-r--r--src/engine/SCons/Tool/packaging/msi.py28
-rw-r--r--src/engine/SCons/Tool/packaging/packager.py218
-rw-r--r--src/engine/SCons/Tool/packaging/rpm.py35
-rw-r--r--src/engine/SCons/Tool/packaging/src_tarbz2.py4
-rw-r--r--src/engine/SCons/Tool/packaging/src_targz.py4
-rw-r--r--src/engine/SCons/Tool/packaging/src_zip.py4
-rw-r--r--src/engine/SCons/Tool/packaging/tarbz2.py6
-rw-r--r--src/engine/SCons/Tool/packaging/targz.py6
-rw-r--r--src/engine/SCons/Tool/packaging/zip.py6
11 files changed, 133 insertions, 373 deletions
diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py
index e8f6a09..72bbff0 100644
--- a/src/engine/SCons/Tool/packaging/__init__.py
+++ b/src/engine/SCons/Tool/packaging/__init__.py
@@ -32,6 +32,7 @@ import SCons.Environment
from SCons.Options import *
from SCons.Errors import *
from SCons.Util import is_List, make_path_relative
+from SCons.Warnings import warn, Warning
import os, imp
import SCons.Defaults
@@ -96,7 +97,11 @@ def Package(env, target=None, source=None, **kw):
try: kw['PACKAGETYPE']=env['PACKAGETYPE']
except KeyError: pass
- if not kw.has_key('PACKAGETYPE') or kw['PACKAGETYPE']==None:
+ if not kw.get('PACKAGETYPE'):
+ from SCons.Script import GetOption
+ kw['PACKAGETYPE'] = GetOption('package_type')
+
+ if kw['PACKAGETYPE'] == None:
if env['BUILDERS'].has_key('Tar'):
kw['PACKAGETYPE']='targz'
elif env['BUILDERS'].has_key('Zip'):
@@ -175,76 +180,48 @@ def Package(env, target=None, source=None, **kw):
targets.extend(env.Alias( 'package', targets ))
return targets
-def build_source(ss, sources):
- for s in ss:
- if s.__class__==SCons.Node.FS.Dir:
- build_source(s.all_children())
- elif not s.has_builder() and s.__class__==SCons.Node.FS.File:
- sources.append(s)
- else:
- build_source(s.sources)
-
-def FindSourceFiles(env, target=None, source=None ):
- """ returns a list of all children of the target nodes, which have no
- children. This selects all leaves of the DAG that gets build by SCons for
- handling dependencies.
- """
- if target==None: target = '.'
-
- nodes = env.arg2nodes(target, env.fs.Entry)
-
- sources = []
- for node in nodes:
- build_source(node.all_children(), sources)
-
- # now strip the build_node from the sources by calling the srcnode
- # function
- def get_final_srcnode(file):
- srcnode = file.srcnode()
- while srcnode != file.srcnode():
- srcnode = file.srcnode()
- return srcnode
-
- # get the final srcnode for all nodes, this means stripping any
- # attached build node.
- map( get_final_srcnode, sources )
-
- # remove duplicates
- return list(set(sources))
-
-def FindInstalledFiles(env, source=[], target=[]):
- """ returns the list of all targets of the Install and InstallAs Builder.
- """
- from SCons.Tool import install
- return install._INSTALLED_FILES
-
#
# SCons tool initialization functions
#
+
+added = None
+
def generate(env):
+ from SCons.Script import AddOption
+ global added
+ if not added:
+ added = 1
+ AddOption('--package-type',
+ dest='package_type',
+ default=None,
+ type="string",
+ action="store",
+ help='The type of package to create.')
+
try:
env['BUILDERS']['Package']
env['BUILDERS']['Tag']
- env['BUILDERS']['FindSourceFiles']
- env['BUILDERS']['FindInstalledFiles']
except KeyError:
env['BUILDERS']['Package'] = Package
env['BUILDERS']['Tag'] = Tag
- env['BUILDERS']['FindSourceFiles'] = FindSourceFiles
- env['BUILDERS']['FindInstalledFiles'] = FindInstalledFiles
def exists(env):
return 1
+# XXX
def options(opts):
opts.AddOptions(
- EnumOption( [ 'PACKAGETYPE', '--package-type' ],
+ EnumOption( 'PACKAGETYPE',
'the type of package to create.',
None, allowed_values=map( str, __all__ ),
ignorecase=2
)
)
+#
+# Internal utility functions
+#
+
def copy_attr(f1, f2):
""" copies the special packaging file attributes from f1 to f2.
"""
@@ -254,79 +231,69 @@ def copy_attr(f1, f2):
pattrs = filter(copyit, dir(f1))
for attr in pattrs:
setattr(f2, attr, getattr(f1, attr))
-#
-# Emitter functions which are reused by the various packagers
-#
-def packageroot_emitter(pkg_root, honor_install_location=1):
- """ creates the packageroot emitter.
-
- The package root emitter uses the CopyAs builder to copy all source files
- to the directory given in pkg_root.
+def putintopackageroot(target, source, env, pkgroot, honor_install_location=1):
+ """ Uses the CopyAs builder to copy all source files to the directory given
+ in pkgroot.
If honor_install_location is set and the copied source file has an
PACKAGING_INSTALL_LOCATION attribute, the PACKAGING_INSTALL_LOCATION is
- used as the new name of the source file under pkg_root.
+ used as the new name of the source file under pkgroot.
- The source file will not be copied if it is already under the the pkg_root
+ The source file will not be copied if it is already under the the pkgroot
directory.
All attributes of the source file will be copied to the new file.
"""
- def package_root_emitter(target, source, env, pkg_root=pkg_root, honor_install_location=honor_install_location):
- pkgroot = pkg_root
- # make sure the packageroot is a Dir object.
- if SCons.Util.is_String(pkgroot): pkgroot=env.Dir(pkgroot)
-
- def copy_file_to_pkg_root(file, env=env, pkgroot=pkgroot, honor_install_location=honor_install_location):
- if file.is_under(pkgroot):
- return file
- else:
- if hasattr(file, 'PACKAGING_INSTALL_LOCATION') and\
- honor_install_location:
- new_name=make_path_relative(file.PACKAGING_INSTALL_LOCATION)
- else:
- new_name=make_path_relative(file.get_path())
+ # make sure the packageroot is a Dir object.
+ if SCons.Util.is_String(pkgroot): pkgroot=env.Dir(pkgroot)
+ if not SCons.Util.is_List(source): source=[source]
- new_file=pkgroot.File(new_name)
- new_file=env.CopyAs(new_file, file)[0]
+ new_source = []
+ for file in source:
+ if SCons.Util.is_String(file): file = env.File(file)
- copy_attr(file, new_file)
+ if file.is_under(pkgroot):
+ new_source.append(file)
+ else:
+ if hasattr(file, 'PACKAGING_INSTALL_LOCATION') and\
+ honor_install_location:
+ new_name=make_path_relative(file.PACKAGING_INSTALL_LOCATION)
+ else:
+ new_name=make_path_relative(file.get_path())
- return new_file
- return (target, map(copy_file_to_pkg_root, source))
- return package_root_emitter
+ new_file=pkgroot.File(new_name)
+ new_file=env.CopyAs(new_file, file)[0]
+ copy_attr(file, new_file)
+ new_source.append(new_file)
-from SCons.Warnings import warn, Warning
+ return (target, new_source)
-def stripinstall_emitter():
- """ create the a emitter which:
- * strips of the Install Builder of the source target, and stores the
- install location as the "PACKAGING_INSTALL_LOCATION" of the given source
- File object. This effectively avoids having to execute the Install
- Action while storing the needed install location.
- * warns about files that are mangled by this emitter which have no
- Install Builder.
+def stripinstallbuilder(target, source, env):
+ """ strips the install builder action from the source list and stores
+ the final installation location as the "PACKAGING_INSTALL_LOCATION" of
+ the source of the source file. This effectively removes the final installed
+ files from the source list while remembering the installation location.
+
+ It also warns about files which have no install builder attached.
"""
- def strip_install_emitter(target, source, env):
- def has_no_install_location(file):
- return not (file.has_builder() and\
- hasattr(file.builder, 'name') and\
- (file.builder.name=="InstallBuilder" or\
- file.builder.name=="InstallAsBuilder"))
-
- if len(filter(has_no_install_location, source)):
- warn(Warning, "there are file to package which have no\
- InstallBuilder attached, this might lead to irreproducible packages")
-
- n_source=[]
- for s in source:
- if has_no_install_location(s):
- n_source.append(s)
- else:
- for ss in s.sources:
- n_source.append(ss)
- copy_attr(s, ss)
- setattr(ss, 'PACKAGING_INSTALL_LOCATION', s.get_path())
+ def has_no_install_location(file):
+ return not (file.has_builder() and\
+ hasattr(file.builder, 'name') and\
+ (file.builder.name=="InstallBuilder" or\
+ file.builder.name=="InstallAsBuilder"))
+
+ if len(filter(has_no_install_location, source)):
+ warn(Warning, "there are files to package which have no\
+ InstallBuilder attached, this might lead to irreproducible packages")
+
+ n_source=[]
+ for s in source:
+ if has_no_install_location(s):
+ n_source.append(s)
+ else:
+ for ss in s.sources:
+ n_source.append(ss)
+ copy_attr(s, ss)
+ setattr(ss, 'PACKAGING_INSTALL_LOCATION', s.get_path())
- return (target, n_source)
- return strip_install_emitter
+ return (target, n_source)
diff --git a/src/engine/SCons/Tool/packaging/ipk.py b/src/engine/SCons/Tool/packaging/ipk.py
index 267fe3c..e3ae277 100644
--- a/src/engine/SCons/Tool/packaging/ipk.py
+++ b/src/engine/SCons/Tool/packaging/ipk.py
@@ -30,7 +30,7 @@ import SCons.Builder
import SCons.Node.FS
import os
-from SCons.Tool.packaging import stripinstall_emitter, packageroot_emitter
+from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
def package(env, target, source, PACKAGEROOT, NAME, VERSION, DESCRIPTION,
SUMMARY, X_IPK_PRIORITY, X_IPK_SECTION, SOURCE_URL,
@@ -42,8 +42,8 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION, DESCRIPTION,
# setup the Ipkg builder
bld = env['BUILDERS']['Ipkg']
- bld.push_emitter(packageroot_emitter(PACKAGEROOT))
- bld.push_emitter(stripinstall_emitter())
+ target, source = stripinstallbuilder(target, source, env)
+ target, source = putintopackageroot(target, source, env, PACKAGEROOT)
# This should be overridable from the construction environment,
# which it is by using ARCHITECTURE=.
@@ -85,7 +85,7 @@ def gen_ipk_dir(proot, source, env, kw):
# create the specfile builder
s_bld=SCons.Builder.Builder(
action = build_specfiles,
- emitter = [stripinstall_emitter(), packageroot_emitter(proot)])
+ )
# create the specfile targets
spec_target=[]
diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py
index 7fc7892..1ce2b1a 100644
--- a/src/engine/SCons/Tool/packaging/msi.py
+++ b/src/engine/SCons/Tool/packaging/msi.py
@@ -36,7 +36,7 @@ from SCons.Builder import Builder
from xml.dom.minidom import *
from xml.sax.saxutils import escape
-from SCons.Tool.packaging import stripinstall_emitter
+from SCons.Tool.packaging import stripinstallbuilder
#
# Utility functions
@@ -223,7 +223,7 @@ def build_wxsfile(target, source, env):
#
# setup function
#
-def create_default_directory_layout(root, NAME, VERSION, vendor, filename_set):
+def create_default_directory_layout(root, NAME, VERSION, VENDOR, filename_set):
""" Create the wix default target directory layout and return the innermost
directory.
@@ -231,7 +231,7 @@ def create_default_directory_layout(root, NAME, VERSION, vendor, filename_set):
the Product tag.
Everything is put under the PFiles directory property defined by WiX.
- After that a directory with the 'vendor' tag is placed and then a
+ After that a directory with the 'VENDOR' tag is placed and then a
directory with the name of the project and its VERSION. This leads to the
following TARGET Directory Layout:
C:\<PFiles>\<Vendor>\<Projectname-Version>\
@@ -247,9 +247,9 @@ def create_default_directory_layout(root, NAME, VERSION, vendor, filename_set):
d2.attributes['Name'] = 'PFiles'
d3 = doc.createElement( 'Directory' )
- d3.attributes['Id'] = 'vendor_folder'
- d3.attributes['Name'] = escape( gen_dos_short_file_name( vendor, filename_set ) )
- d3.attributes['LongName'] = escape( vendor )
+ d3.attributes['Id'] = 'VENDOR_folder'
+ d3.attributes['Name'] = escape( gen_dos_short_file_name( VENDOR, filename_set ) )
+ d3.attributes['LongName'] = escape( VENDOR )
d4 = doc.createElement( 'Directory' )
project_folder = "%s-%s" % ( NAME, VERSION )
@@ -268,7 +268,7 @@ def create_default_directory_layout(root, NAME, VERSION, vendor, filename_set):
#
# mandatory and optional file tags
#
-def build_wxsfile_file_section(root, files, NAME, VERSION, vendor, filename_set, id_set):
+def build_wxsfile_file_section(root, files, NAME, VERSION, VENDOR, filename_set, id_set):
""" builds the Component sections of the wxs file with their included files.
Files need to be specified in 8.3 format and in the long name format, long
@@ -276,7 +276,7 @@ def build_wxsfile_file_section(root, files, NAME, VERSION, vendor, filename_set,
Features are specficied with the 'X_MSI_FEATURE' or 'DOC' FileTag.
"""
- root = create_default_directory_layout( root, NAME, VERSION, vendor, filename_set )
+ root = create_default_directory_layout( root, NAME, VERSION, VENDOR, filename_set )
components = create_feature_dict( files )
factory = Document()
@@ -470,7 +470,7 @@ def build_wxsfile_header_section(root, spec):
# mandatory sections, will throw a KeyError if the tag is not available
Product.attributes['Name'] = escape( spec['NAME'] )
Product.attributes['Version'] = escape( spec['VERSION'] )
- Product.attributes['Manufacturer'] = escape( spec['vendor'] )
+ Product.attributes['Manufacturer'] = escape( spec['VENDOR'] )
Product.attributes['Language'] = escape( spec['X_MSI_LANGUAGE'] )
Package.attributes['Description'] = escape( spec['SUMMARY'] )
@@ -490,12 +490,11 @@ def build_wxsfile_header_section(root, spec):
# this builder is the entry-point for .wxs file compiler.
wxs_builder = Builder(
- action = Action( build_wxsfile, string_wxsfile ),
- emitter = stripinstall_emitter(),
- suffix = '.wxs' )
+ action = Action( build_wxsfile, string_wxsfile ),
+ ensure_suffix = '.wxs' )
def package(env, target, source, PACKAGEROOT, NAME, VERSION,
- DESCRIPTION, SUMMARY, **kw):
+ DESCRIPTION, SUMMARY, VENDOR, X_MSI_LANGUAGE, **kw):
# make sure that the Wix Builder is in the environment
SCons.Tool.Tool('wix').generate(env)
@@ -507,6 +506,9 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION,
kw.update(loc)
del kw['source'], kw['target'], kw['env']
+ # strip the install builder from the source files
+ target, source = stripinstallbuilder(target, source, env)
+
# put the arguments into the env and call the specfile builder.
env['msi_spec'] = kw
specfile = apply( wxs_builder, [env, target, source], kw )
diff --git a/src/engine/SCons/Tool/packaging/packager.py b/src/engine/SCons/Tool/packaging/packager.py
deleted file mode 100644
index 7aca2b6..0000000
--- a/src/engine/SCons/Tool/packaging/packager.py
+++ /dev/null
@@ -1,218 +0,0 @@
-"""SCons.Tool.Packaging.packager
-"""
-
-#
-# __COPYRIGHT__
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-import os
-import SCons.Defaults
-from SCons.Util import strip_abs_path
-
-class Packager:
- """ abstract superclass of all packagers.
-
- Defines the minimal set of function which need to be implemented in order
- to create a new packager.
- """
- def __init__(self):
- self.specfile_suffix = '.spec'
-
- def create_builder(self, env, kw):
- raise Exception( "%s does not implement create_builder()" % (self.__class__.__name_) )
-
- def add_targets(self, kw):
- """ In the absence of a target this method creates a default one of
- the spec given in the kw argument.
- """
- if not kw.has_key('target'):
- NAME, VERSION = kw['projectname'], kw['version']
- kw['target'] = [ "%s-%s"%(NAME,VERSION) ]
-
- return kw
-
- def strip_install_emitter(self, target, source, env):
- """ this emitter assert that all files in source have an InstallBuilder
- attached. We take their sources and copy over the file tags, so the
- the builder this emitter is attached to is independent of the *installed*
- files.
- """
- tag_factories = [ LocationTagFactory() ]
-
- def has_no_install_location(file):
- return not ( file.has_builder() and (file.builder.name == 'InstallBuilder' or file.builder.name == 'InstallAsBuilder') )
-
- # check if all source file belong into this package.
- files = filter( has_no_install_location, source )
- if len( files ) != 0:
- raise SCons.Errors.UserError( "There are files which have no Install() Builder attached and are therefore not packageable\n%s" % map( lambda x: x.get_path(), files ) )
-
- # All source files have an InstallBuilder attached and we don't want our
- # package to be dependent on the *installed* files but only on the
- # files that will be installed. Therefore we only care for sources of
- # the files in the source list.
- n_source = []
-
- for s in source:
- n_s = s.sources[0]
- n_s.set_tags( s.get_tags(tag_factories) )
- n_source.append( n_s )
-
- return ( target, n_source )
-
-
-class BinaryPackager(Packager):
- """ abstract superclass for all packagers creating a binary package.
-
- Binary packagers are seperated from source packager by their requirement to
- create a specfile or manifest file. This file contains the contents of the
- binary packager together with some information about specific files.
-
- This superclass provides two needed facilities:
- * its specfile_emitter function sets up the correct list of source file
- and warns about files with no InstallBuilder attached.
- """
- def create_specfile_targets(self, kw):
- """ returns the specfile target name(s).
-
- This function is called by specfile_emitter to find out the specfiles
- target name.
- """
- p, v = kw['NAME'], kw['VERSION']
- return '%s-%s' % ( p, v )
-
- def specfile_emitter(self, target, source, env):
- """ adds the to build specfile to the source list.
- """
- # create a specfile action that is executed for building the specfile
- specfile_action = SCons.Action.Action( self.build_specfile,
- self.string_specfile,
- varlist=[ 'SPEC' ] )
-
- # create a specfile Builder with the right sources attached.
- specfile_builder = SCons.Builder.Builder( action = self.build_specfile,
- suffix = self.specfile_suffix )
-
- specfile = apply( specfile_builder, [ env ], {
- 'target' : self.create_specfile_targets(env),
- 'source' : source } )
-
- specfile.extend( source )
- return ( target, specfile )
-
- def string_specfile(self, target, source, env):
- return "building specfile %s"%(target[0].abspath)
-
- def build_specfile(self, target, source, env):
- """ this function is called to build the specfile of name "target"
- from the source list and the settings in "env"
- """
- raise Exception( 'class does not implement build_specfile()' )
-
-class SourcePackager(Packager):
- """ abstract superclass for all packagers which generate a source package.
-
- They are seperated from other packager by the their package_root attribute.
- Since before a source package is created with the help of a Tar or Zip
- builder their content needs to be moved to a package_root. For example the
- project foo with VERSION 1.2.3, will get its files placed in foo-1.2.3/.
- """
- def create_package_root(self,kw):
- """ creates the package_r oot for a given specification dict.
- """
- try:
- return kw['package_root']
- except KeyError:
- NAME, VERSION = kw['projectname'], kw['version']
- return "%s-%s"%(NAME,VERSION)
-
- def package_root_emitter(self, pkg_root, honor_install_location=1):
- def package_root_emitter(target, source, env):
- """ This emitter copies the sources to the src_package_root directory:
- * if a source has an install_location, not its original name is
- used but the one specified in the 'install_location' tag.
- * else its original name is used.
- * if the source file is already in the src_package_root directory,
- nothing will be done.
- """
- new_source = []
- for s in source:
- if os.path.dirname(s.get_path()).rfind(pkg_root) != -1:
- new_source.append(s)
- else:
- tags = s.get_tags()
- new_s = None
-
- if tags.has_key( 'install_location' ) and honor_install_location:
- my_target = strip_abs_path(tags['install_location'])
- else:
- my_target = strip_abs_path(s.get_path())
-
- new_s = env.CopyAs( os.path.join( pkg_root, my_target ), s )[0]
-
- # store the tags of our original file in the new file.
- new_s.set_tags( s.get_tags() )
- new_source.append( new_s )
-
- return (target, new_source)
-
- return package_root_emitter
-
-class TagFactory:
- """An instance of this class has the responsibility to generate additional
- tags for a SCons.Node.FS.File instance.
-
- Subclasses have to be callable. This class definition is informally
- describing the interface.
- """
-
- def __call__(self, file, current_tag_dict):
- """ This call has to return additional tags in the form of a dict.
- """
- pass
-
- def attach_additional_info(self, info=None):
- pass
-
-class LocationTagFactory(TagFactory):
- """ This class creates the "location" tag, which describes the install
- location of a given file.
-
- This is done by analyzing the builder of a given file for a InstallBuilder,
- from this builder the install location is deduced.
- """
-
- def __call__(self, file, current_tag_dict):
- if current_tag_dict.has_key('install_location'):
- return {}
-
- if file.has_builder() and\
- (file.builder.name == "InstallBuilder" or\
- file.builder.name == "InstallAsBuilder") and\
- file.has_explicit_builder():
- return { 'install_location' : file.get_path() }
- else:
- return {}
-
-
diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py
index 94b7b7a..5f97608 100644
--- a/src/engine/SCons/Tool/packaging/rpm.py
+++ b/src/engine/SCons/Tool/packaging/rpm.py
@@ -33,7 +33,9 @@ import string
import SCons.Builder
-from SCons.Tool.packaging import stripinstall_emitter, packageroot_emitter, src_targz
+from SCons.Environment import OverrideEnvironment
+from SCons.Tool.packaging import stripinstallbuilder, src_targz
+from SCons.Errors import UserError
def package(env, target, source, PACKAGEROOT, NAME, VERSION,
PACKAGEVERSION, DESCRIPTION, SUMMARY, X_RPM_GROUP, LICENSE,
@@ -43,12 +45,13 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION,
bld = env['BUILDERS']['Rpm']
- bld.push_emitter(targz_emitter)
- bld.push_emitter(specfile_emitter)
- bld.push_emitter(stripinstall_emitter())
-
- # override the default target, with the rpm specific ones.
- if str(target[0])=="%s-%s"%(NAME, VERSION):
+ # Generate a UserError whenever the target name has been set explicitly,
+ # since rpm does not allow for controlling it. This is detected by
+ # checking if the target has been set to the default by the Package()
+ # Environment function.
+ if str(target[0])!="%s-%s"%(NAME, VERSION):
+ raise UserError( "Setting target is not supported for rpm." )
+ else:
# This should be overridable from the construction environment,
# which it is by using ARCHITECTURE=.
# Guessing based on what os.uname() returns at least allows it
@@ -79,13 +82,19 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION,
# if no "SOURCE_URL" tag is given add a default one.
if not kw.has_key('SOURCE_URL'):
- kw['SOURCE_URL']=(str(target[0])+".tar.gz").replace('.rpm', '')
+ #kw['SOURCE_URL']=(str(target[0])+".tar.gz").replace('.rpm', '')
+ kw['SOURCE_URL']=string.replace(str(target[0])+".tar.gz", '.rpm', '')
+
+ # mangle the source and target list for the rpmbuild
+ env = OverrideEnvironment(env, kw)
+ target, source = stripinstallbuilder(target, source, env)
+ target, source = addspecfile(target, source, env)
+ target, source = collectintargz(target, source, env)
# now call the rpm builder to actually build the packet.
return apply(bld, [env, target, source], kw)
-
-def targz_emitter(target, source, env):
+def collectintargz(target, source, env):
""" Puts all source files into a tar.gz file. """
# the rpm tool depends on a source package, until this is chagned
# this hack needs to be here that tries to pack all sources in.
@@ -116,7 +125,7 @@ def targz_emitter(target, source, env):
return (target, tarball)
-def specfile_emitter(target, source, env):
+def addspecfile(target, source, env):
specfile = "%s-%s" % (env['NAME'], env['VERSION'])
bld = SCons.Builder.Builder(action = build_specfile,
@@ -180,7 +189,7 @@ def build_specfile_sections(spec):
# Default prep, build, install and clean rules
# TODO: optimize those build steps, to not compile the project a second time
if not spec.has_key('X_RPM_PREP'):
- spec['X_RPM_PREP'] = 'rm -rf "$RPM_BUILD_ROOT"' + '\n%setup -q'
+ spec['X_RPM_PREP'] = '[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"' + '\n%setup -q'
if not spec.has_key('X_RPM_BUILD'):
spec['X_RPM_BUILD'] = 'mkdir "$RPM_BUILD_ROOT"'
@@ -189,7 +198,7 @@ def build_specfile_sections(spec):
spec['X_RPM_INSTALL'] = 'scons --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"'
if not spec.has_key('X_RPM_CLEAN'):
- spec['X_RPM_CLEAN'] = 'rm -rf "$RPM_BUILD_ROOT"'
+ spec['X_RPM_CLEAN'] = '[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"'
str = str + SimpleTagCompiler(optional_sections, mandatory=0).compile( spec )
diff --git a/src/engine/SCons/Tool/packaging/src_tarbz2.py b/src/engine/SCons/Tool/packaging/src_tarbz2.py
index 7d876e4..8323107 100644
--- a/src/engine/SCons/Tool/packaging/src_tarbz2.py
+++ b/src/engine/SCons/Tool/packaging/src_tarbz2.py
@@ -28,10 +28,10 @@ The tarbz2 SRC packager.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-from SCons.Tool.packaging import packageroot_emitter
+from SCons.Tool.packaging import putintopackageroot
def package(env, target, source, PACKAGEROOT, **kw):
bld = env['BUILDERS']['Tar']
bld.set_suffix('.tar.bz2')
- bld.push_emitter(packageroot_emitter(PACKAGEROOT, honor_install_location=0))
+ target, source = putintopackageroot(target, source, env, PACKAGEROOT, honor_install_location=0)
return bld(env, target, source, TARFLAGS='-jc')
diff --git a/src/engine/SCons/Tool/packaging/src_targz.py b/src/engine/SCons/Tool/packaging/src_targz.py
index d84976e..db51279 100644
--- a/src/engine/SCons/Tool/packaging/src_targz.py
+++ b/src/engine/SCons/Tool/packaging/src_targz.py
@@ -28,10 +28,10 @@ The targz SRC packager.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-from SCons.Tool.packaging import packageroot_emitter
+from SCons.Tool.packaging import putintopackageroot
def package(env, target, source, PACKAGEROOT, **kw):
bld = env['BUILDERS']['Tar']
bld.set_suffix('.tar.gz')
- bld.push_emitter(packageroot_emitter(PACKAGEROOT, honor_install_location=0))
+ target, source = putintopackageroot(target, source, env, PACKAGEROOT, honor_install_location=0)
return bld(env, target, source, TARFLAGS='-zc')
diff --git a/src/engine/SCons/Tool/packaging/src_zip.py b/src/engine/SCons/Tool/packaging/src_zip.py
index d60fe85..01bd42e 100644
--- a/src/engine/SCons/Tool/packaging/src_zip.py
+++ b/src/engine/SCons/Tool/packaging/src_zip.py
@@ -28,10 +28,10 @@ The zip SRC packager.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-from SCons.Tool.packaging import packageroot_emitter
+from SCons.Tool.packaging import putintopackageroot
def package(env, target, source, PACKAGEROOT, **kw):
bld = env['BUILDERS']['Zip']
bld.set_suffix('.zip')
- bld.push_emitter(packageroot_emitter(PACKAGEROOT, honor_install_location=0))
+ target, source = putintopackageroot(target, source, env, PACKAGEROOT, honor_install_location=0)
return bld(env, target, source)
diff --git a/src/engine/SCons/Tool/packaging/tarbz2.py b/src/engine/SCons/Tool/packaging/tarbz2.py
index 7127896..52252da 100644
--- a/src/engine/SCons/Tool/packaging/tarbz2.py
+++ b/src/engine/SCons/Tool/packaging/tarbz2.py
@@ -28,11 +28,11 @@ The tarbz2 SRC packager.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-from SCons.Tool.packaging import stripinstall_emitter, packageroot_emitter
+from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
def package(env, target, source, PACKAGEROOT, **kw):
bld = env['BUILDERS']['Tar']
bld.set_suffix('.tar.gz')
- bld.push_emitter(packageroot_emitter(PACKAGEROOT))
- bld.push_emitter(stripinstall_emitter())
+ target, source = putintopackageroot(target, source, env, PACKAGEROOT)
+ target, source = stripinstallbuilder(target, source, env)
return bld(env, target, source, TARFLAGS='-jc')
diff --git a/src/engine/SCons/Tool/packaging/targz.py b/src/engine/SCons/Tool/packaging/targz.py
index 798e570..4713840 100644
--- a/src/engine/SCons/Tool/packaging/targz.py
+++ b/src/engine/SCons/Tool/packaging/targz.py
@@ -28,11 +28,11 @@ The targz SRC packager.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-from SCons.Tool.packaging import stripinstall_emitter, packageroot_emitter
+from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
def package(env, target, source, PACKAGEROOT, **kw):
bld = env['BUILDERS']['Tar']
bld.set_suffix('.tar.gz')
- bld.push_emitter(packageroot_emitter(PACKAGEROOT))
- bld.push_emitter(stripinstall_emitter())
+ target, source = stripinstallbuilder(target, source, env)
+ target, source = putintopackageroot(target, source, env, PACKAGEROOT)
return bld(env, target, source, TARFLAGS='-zc')
diff --git a/src/engine/SCons/Tool/packaging/zip.py b/src/engine/SCons/Tool/packaging/zip.py
index 7663a4a..639d569 100644
--- a/src/engine/SCons/Tool/packaging/zip.py
+++ b/src/engine/SCons/Tool/packaging/zip.py
@@ -28,11 +28,11 @@ The zip SRC packager.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-from SCons.Tool.packaging import stripinstall_emitter, packageroot_emitter
+from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
def package(env, target, source, PACKAGEROOT, **kw):
bld = env['BUILDERS']['Zip']
bld.set_suffix('.zip')
- bld.push_emitter(packageroot_emitter(PACKAGEROOT))
- bld.push_emitter(stripinstall_emitter())
+ target, source = stripinstallbuilder(target, source, env)
+ target, source = putintopackageroot(target, source, env, PACKAGEROOT)
return bld(env, target, source)