diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-03-25 04:14:28 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-03-25 04:14:28 (GMT) |
commit | 22d352500f1cd6bd0c53d788a5dc44a1fefa676e (patch) | |
tree | 0984fd581082c27cfbfbb7f94d5751b0e6fd2741 /src/engine/SCons/Tool/packaging | |
parent | 75ac32ac8e32076e25b72a19eb56340cc585fa4e (diff) | |
download | SCons-22d352500f1cd6bd0c53d788a5dc44a1fefa676e.zip SCons-22d352500f1cd6bd0c53d788a5dc44a1fefa676e.tar.gz SCons-22d352500f1cd6bd0c53d788a5dc44a1fefa676e.tar.bz2 |
Move 2.0 changes collected in branches/pending back to trunk for further
development. Note that this set of changes is NOT backward-compatible;
the trunk no longer works with Python 1.5.2, 2.0, or 2.1.
Diffstat (limited to 'src/engine/SCons/Tool/packaging')
-rw-r--r-- | src/engine/SCons/Tool/packaging/__init__.py | 24 | ||||
-rw-r--r-- | src/engine/SCons/Tool/packaging/ipk.py | 10 | ||||
-rw-r--r-- | src/engine/SCons/Tool/packaging/msi.py | 25 | ||||
-rw-r--r-- | src/engine/SCons/Tool/packaging/rpm.py | 42 |
4 files changed, 52 insertions, 49 deletions
diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py index c4ae170..b80f128 100644 --- a/src/engine/SCons/Tool/packaging/__init__.py +++ b/src/engine/SCons/Tool/packaging/__init__.py @@ -25,6 +25,7 @@ SCons Packaging Tool. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -105,16 +106,16 @@ def Package(env, target=None, source=None, **kw): kw['PACKAGETYPE'] = GetOption('package_type') if kw['PACKAGETYPE'] == None: - if env['BUILDERS'].has_key('Tar'): + if 'Tar' in env['BUILDERS']: kw['PACKAGETYPE']='targz' - elif env['BUILDERS'].has_key('Zip'): + elif 'Zip' in env['BUILDERS']: kw['PACKAGETYPE']='zip' else: raise UserError, "No type for Package() given" PACKAGETYPE=kw['PACKAGETYPE'] if not is_List(PACKAGETYPE): - PACKAGETYPE=string.split(PACKAGETYPE, ',') + PACKAGETYPE=PACKAGETYPE.split(',') # load the needed packagers. def load_packager(type): @@ -124,7 +125,7 @@ def Package(env, target=None, source=None, **kw): except ImportError, e: raise EnvironmentError("packager %s not available: %s"%(type,str(e))) - packagers=map(load_packager, PACKAGETYPE) + packagers=list(map(load_packager, PACKAGETYPE)) # set up targets and the PACKAGEROOT try: @@ -139,7 +140,7 @@ def Package(env, target=None, source=None, **kw): default_target = default_name%kw target.extend( [default_target]*size_diff ) - if not kw.has_key('PACKAGEROOT'): + if 'PACKAGEROOT' not in kw: kw['PACKAGEROOT'] = default_name%kw except KeyError, e: @@ -153,7 +154,7 @@ def Package(env, target=None, source=None, **kw): try: for packager in packagers: t=[target.pop(0)] - t=apply(packager.package, [env,t,source], kw) + t=packager.package(env,t,source, **kw) targets.extend(t) assert( len(target) == 0 ) @@ -173,8 +174,7 @@ def Package(env, target=None, source=None, **kw): args.remove('target') args.remove('source') # now remove any args for which we have a value in kw. - #args=[x for x in args if not kw.has_key(x)] - args=filter(lambda x, kw=kw: not kw.has_key(x), args) + args=[x for x in args if x not in kw] if len(args)==0: raise # must be a different error, so reraise @@ -222,7 +222,7 @@ def options(opts): opts.AddVariables( EnumVariable( 'PACKAGETYPE', 'the type of package to create.', - None, allowed_values=map( str, __all__ ), + None, allowed_values=list(map( str, __all__ )), ignorecase=2 ) ) @@ -236,8 +236,8 @@ def copy_attr(f1, f2): """ #pattrs = [x for x in dir(f1) if not hasattr(f2, x) and\ # x.startswith('PACKAGING_')] - copyit = lambda x, f2=f2: not hasattr(f2, x) and x[:10] == 'PACKAGING_' - pattrs = filter(copyit, dir(f1)) + copyit = lambda x: not hasattr(f2, x) and x[:10] == 'PACKAGING_' + pattrs = list(filter(copyit, dir(f1))) for attr in pattrs: setattr(f2, attr, getattr(f1, attr)) def putintopackageroot(target, source, env, pkgroot, honor_install_location=1): @@ -291,7 +291,7 @@ def stripinstallbuilder(target, source, env): (file.builder.name=="InstallBuilder" or\ file.builder.name=="InstallAsBuilder")) - if len(filter(has_no_install_location, source)): + if len(list(filter(has_no_install_location, source))): warn(Warning, "there are files to package which have no\ InstallBuilder attached, this might lead to irreproducible packages") diff --git a/src/engine/SCons/Tool/packaging/ipk.py b/src/engine/SCons/Tool/packaging/ipk.py index 8575de6..6549445 100644 --- a/src/engine/SCons/Tool/packaging/ipk.py +++ b/src/engine/SCons/Tool/packaging/ipk.py @@ -58,7 +58,7 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION, DESCRIPTION, buildarchitecture = os.uname()[4] buildarchitecture = archmap.get(buildarchitecture, buildarchitecture) - if kw.has_key('ARCHITECTURE'): + if 'ARCHITECTURE' in kw: buildarchitecture = kw['ARCHITECTURE'] # setup the kw to contain the mandatory arguments to this fucntion. @@ -76,7 +76,7 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION, DESCRIPTION, target=[ "%s_%s_%s.ipk"%(NAME, VERSION, buildarchitecture) ] # now apply the Ipkg builder - return apply(bld, [env, target, specfile], kw) + return bld(env, target, specfile, **kw) def gen_ipk_dir(proot, source, env, kw): # make sure the packageroot is a Dir object. @@ -98,7 +98,7 @@ def gen_ipk_dir(proot, source, env, kw): spec_target.append(control.File('preinst')) # apply the builder to the specfile targets - apply(s_bld, [env, spec_target, source], kw) + s_bld(env, spec_target, source, **kw) # the packageroot directory does now contain the specfiles. return proot @@ -125,7 +125,7 @@ def build_specfiles(source, target, env): control_file=open_file('control', target) - if not env.has_key('X_IPK_DESCRIPTION'): + if 'X_IPK_DESCRIPTION' not in env: env['X_IPK_DESCRIPTION']="%s\n %s"%(env['SUMMARY'], env['DESCRIPTION'].replace('\n', '\n ')) @@ -173,7 +173,7 @@ Description: $X_IPK_DESCRIPTION f.close() # call a user specified function - if env.has_key('CHANGE_SPECFILE'): + if 'CHANGE_SPECFILE' in env: content += env['CHANGE_SPECFILE'](target) return 0 diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py index 41ea0b3..95adbed 100644 --- a/src/engine/SCons/Tool/packaging/msi.py +++ b/src/engine/SCons/Tool/packaging/msi.py @@ -25,6 +25,7 @@ The msi packager. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -65,14 +66,14 @@ def convert_to_id(s, id_set): charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyz0123456789_.' if s[0] in '0123456789.': s += '_'+s - id = filter( lambda c : c in charset, s ) + id = [c for c in s if c in charset] # did we already generate an id for this file? try: return id_set[id][s] except KeyError: # no we did not so initialize with the id - if not id_set.has_key(id): id_set[id] = { s : id } + if id not in id_set: id_set[id] = { s : id } # there is a collision, generate an id which is unique by appending # the collision number else: id_set[id][s] = id + str(len(id_set[id])) @@ -109,7 +110,7 @@ def gen_dos_short_file_name(file, filename_set): # strip forbidden characters. forbidden = '."/[]:;=, ' - fname = filter( lambda c : c not in forbidden, fname ) + fname = [c for c in fname if c not in forbidden] # check if we already generated a filename with the same number: # thisis1.txt, thisis2.txt etc. @@ -137,7 +138,7 @@ def create_feature_dict(files): feature = [ feature ] for f in feature: - if not dict.has_key( f ): + if f not in dict: dict[ f ] = [ file ] else: dict[ f ].append( file ) @@ -214,7 +215,7 @@ def build_wxsfile(target, source, env): file.write( doc.toprettyxml() ) # call a user specified function - if env.has_key('CHANGE_SPECFILE'): + if 'CHANGE_SPECFILE' in env: env['CHANGE_SPECFILE'](target, source) except KeyError, e: @@ -296,9 +297,11 @@ def build_wxsfile_file_section(root, files, NAME, VERSION, VENDOR, filename_set, upper_dir = '' # walk down the xml tree finding parts of the directory - dir_parts = filter( lambda d: d != '', dir_parts ) + dir_parts = [d for d in dir_parts if d != ''] for d in dir_parts[:]: - already_created = filter( lambda c: c.nodeName == 'Directory' and c.attributes['LongName'].value == escape(d), Directory.childNodes ) + already_created = [c for c in Directory.childNodes + if c.nodeName == 'Directory' + and c.attributes['LongName'].value == escape(d)] if already_created != []: Directory = already_created[0] @@ -464,7 +467,7 @@ def build_wxsfile_header_section(root, spec): Product.childNodes.append( Package ) # set "mandatory" default values - if not spec.has_key('X_MSI_LANGUAGE'): + if 'X_MSI_LANGUAGE' not in spec: spec['X_MSI_LANGUAGE'] = '1033' # select english # mandatory sections, will throw a KeyError if the tag is not available @@ -475,10 +478,10 @@ def build_wxsfile_header_section(root, spec): Package.attributes['Description'] = escape( spec['SUMMARY'] ) # now the optional tags, for which we avoid the KeyErrror exception - if spec.has_key( 'DESCRIPTION' ): + if 'DESCRIPTION' in spec: Package.attributes['Comments'] = escape( spec['DESCRIPTION'] ) - if spec.has_key( 'X_MSI_UPGRADE_CODE' ): + if 'X_MSI_UPGRADE_CODE' in spec: Package.attributes['X_MSI_UPGRADE_CODE'] = escape( spec['X_MSI_UPGRADE_CODE'] ) # We hardcode the media tag as our current model cannot handle it. @@ -511,7 +514,7 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION, # put the arguments into the env and call the specfile builder. env['msi_spec'] = kw - specfile = apply( wxs_builder, [env, target, source], kw ) + specfile = wxs_builder(* [env, target, source], **kw) # now call the WiX Tool with the built specfile added as a source. msifile = env.WiX(target, specfile) diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index c2a532c..7480542 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -25,11 +25,11 @@ The rpm packager. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os -import string import SCons.Builder @@ -65,7 +65,7 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION, buildarchitecture = os.uname()[4] buildarchitecture = archmap.get(buildarchitecture, buildarchitecture) - if kw.has_key('ARCHITECTURE'): + if 'ARCHITECTURE' in kw: buildarchitecture = kw['ARCHITECTURE'] fmt = '%s-%s-%s.%s.rpm' @@ -81,9 +81,9 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION, del kw['source'], kw['target'], kw['env'] # if no "SOURCE_URL" tag is given add a default one. - if not kw.has_key('SOURCE_URL'): + if 'SOURCE_URL' not in kw: #kw['SOURCE_URL']=(str(target[0])+".tar.gz").replace('.rpm', '') - kw['SOURCE_URL']=string.replace(str(target[0])+".tar.gz", '.rpm', '') + kw['SOURCE_URL']=(str(target[0])+".tar.gz").replace('.rpm', '') # mangle the source and target list for the rpmbuild env = OverrideEnvironment(env, kw) @@ -92,7 +92,7 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION, target, source = collectintargz(target, source, env) # now call the rpm builder to actually build the packet. - return apply(bld, [env, target, source], kw) + return bld(env, target, source, **kw) def collectintargz(target, source, env): """ Puts all source files into a tar.gz file. """ @@ -102,21 +102,21 @@ def collectintargz(target, source, env): # filter out the target we are building the source list for. #sources = [s for s in sources if not (s in target)] - sources = filter(lambda s, t=target: not (s in t), sources) + sources = [s for s in sources if s not in target] # find the .spec file for rpm and add it since it is not necessarily found # by the FindSourceFiles function. #sources.extend( [s for s in source if str(s).rfind('.spec')!=-1] ) - spec_file = lambda s: string.rfind(str(s), '.spec') != -1 - sources.extend( filter(spec_file, source) ) + spec_file = lambda s: str(s).rfind('.spec') != -1 + sources.extend( list(filter(spec_file, source)) ) # as the source contains the url of the source package this rpm package # is built from, we extract the target name #tarball = (str(target[0])+".tar.gz").replace('.rpm', '') - tarball = string.replace(str(target[0])+".tar.gz", '.rpm', '') + tarball = (str(target[0])+".tar.gz").replace('.rpm', '') try: #tarball = env['SOURCE_URL'].split('/')[-1] - tarball = string.split(env['SOURCE_URL'], '/')[-1] + tarball = env['SOURCE_URL'].split('/')[-1] except KeyError, e: raise SCons.Errors.UserError( "Missing PackageTag '%s' for RPM packager" % e.args[0] ) @@ -150,7 +150,7 @@ def build_specfile(target, source, env): file.close() # call a user specified function - if env.has_key('CHANGE_SPECFILE'): + if 'CHANGE_SPECFILE' in env: env['CHANGE_SPECFILE'](target, source) except KeyError, e: @@ -188,16 +188,16 @@ 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'): + if 'X_RPM_PREP' not in spec: 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'): + if 'X_RPM_BUILD' not in spec: spec['X_RPM_BUILD'] = 'mkdir "$RPM_BUILD_ROOT"' - if not spec.has_key('X_RPM_INSTALL'): + if 'X_RPM_INSTALL' not in spec: spec['X_RPM_INSTALL'] = 'scons --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"' - if not spec.has_key('X_RPM_CLEAN'): + if 'X_RPM_CLEAN' not in spec: 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 ) @@ -254,7 +254,7 @@ def build_specfile_header(spec): # if not s.has_key('x_rpm_BuildRequires'): # s['x_rpm_BuildRequires'] = 'scons' - if not spec.has_key('X_RPM_BUILDROOT'): + if 'X_RPM_BUILDROOT' not in spec: spec['X_RPM_BUILDROOT'] = '%{_tmppath}/%{name}-%{version}-%{release}' str = str + SimpleTagCompiler(optional_header_fields, mandatory=0).compile( spec ) @@ -268,7 +268,7 @@ def build_specfile_filesection(spec, files): """ str = '%files\n' - if not spec.has_key('X_RPM_DEFATTR'): + if 'X_RPM_DEFATTR' not in spec: spec['X_RPM_DEFATTR'] = '(-,root,root)' str = str + '%%defattr %s\n' % spec['X_RPM_DEFATTR'] @@ -337,7 +337,7 @@ class SimpleTagCompiler: str = "" #domestic = [ (k,v) for k,v in replacements if not is_international(k) ] - domestic = filter(lambda t, i=is_international: not i(t[0]), replacements) + domestic = [t for t in replacements if not is_international(t[0])] for key, replacement in domestic: try: str = str + replacement % values[key] @@ -346,12 +346,12 @@ class SimpleTagCompiler: raise e #international = [ (k,v) for k,v in replacements if is_international(k) ] - international = filter(lambda t, i=is_international: i(t[0]), replacements) + international = [t for t in replacements if is_international(t[0])] for key, replacement in international: try: #int_values_for_key = [ (get_country_code(k),v) for k,v in values.items() if strip_country_code(k) == key ] - x = filter(lambda t,key=key,s=strip_country_code: s(t[0]) == key, values.items()) - int_values_for_key = map(lambda t,g=get_country_code: (g(t[0]),t[1]), x) + x = [t for t in values.items() if strip_country_code(t[0]) == key] + int_values_for_key = [(get_country_code(t[0]),t[1]) for t in x] for v in int_values_for_key: str = str + replacement % v except KeyError, e: |