diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-08-11 12:17:57 +0200 | 
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-08-11 12:17:57 +0200 | 
| commit | c8ea3b672655ddab746a7aea5a50217057b02b9e (patch) | |
| tree | 01a0e712f4cf32c7140cf1a4ae14db4da4202253 /engine/SCons/Tool/packaging/rpm.py | |
| parent | ca7be46fc0013fc037a045b6d4df73776461e821 (diff) | |
| parent | f6c9bffb15e04ea412db4df22a3851448221b85a (diff) | |
mergedebian/3.1.1-1
Diffstat (limited to 'engine/SCons/Tool/packaging/rpm.py')
| -rw-r--r-- | engine/SCons/Tool/packaging/rpm.py | 57 | 
1 files changed, 35 insertions, 22 deletions
diff --git a/engine/SCons/Tool/packaging/rpm.py b/engine/SCons/Tool/packaging/rpm.py index 73b3ae7..aa15061 100644 --- a/engine/SCons/Tool/packaging/rpm.py +++ b/engine/SCons/Tool/packaging/rpm.py @@ -4,7 +4,7 @@ The rpm packager.  """  # -# Copyright (c) 2001 - 2017 The SCons Foundation +# Copyright (c) 2001 - 2019 The SCons Foundation  #  # Permission is hereby granted, free of charge, to any person obtaining  # a copy of this software and associated documentation files (the @@ -25,7 +25,7 @@ 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. -__revision__ = "src/engine/SCons/Tool/packaging/rpm.py 74b2c53bc42290e911b334a6b44f187da698a668 2017/11/14 13:16:53 bdbaddog" +__revision__ = "src/engine/SCons/Tool/packaging/rpm.py 72ae09dc35ac2626f8ff711d8c4b30b6138e08e3 2019-08-08 14:50:06 bdeegan"  import os @@ -51,10 +51,9 @@ def package(env, target, source, PACKAGEROOT, NAME, VERSION,      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=. +        # Deduce the build architecture, but allow it to be overridden +        # by setting ARCHITECTURE in the construction env.          buildarchitecture = SCons.Tool.rpmutils.defaultMachine() -          if 'ARCHITECTURE' in kw:              buildarchitecture = kw['ARCHITECTURE'] @@ -126,20 +125,18 @@ def build_specfile(target, source, env):      """ Builds a RPM specfile from a dictionary with string metadata and      by analyzing a tree of nodes.      """ -    file = open(target[0].get_abspath(), 'w') - -    try: -        file.write( build_specfile_header(env) ) -        file.write( build_specfile_sections(env) ) -        file.write( build_specfile_filesection(env, source) ) -        file.close() +    with open(target[0].get_abspath(), 'w') as ofp: +        try: +            ofp.write(build_specfile_header(env)) +            ofp.write(build_specfile_sections(env)) +            ofp.write(build_specfile_filesection(env, source)) -        # call a user specified function -        if 'CHANGE_SPECFILE' in env: -            env['CHANGE_SPECFILE'](target, source) +            # call a user specified function +            if 'CHANGE_SPECFILE' in env: +                env['CHANGE_SPECFILE'](target, source) -    except KeyError as e: -        raise SCons.Errors.UserError( '"%s" package field for RPM is missing.' % e.args[0] ) +        except KeyError as e: +            raise SCons.Errors.UserError('"%s" package field for RPM is missing.' % e.args[0])  # @@ -201,7 +198,8 @@ def build_specfile_header(spec):          'PACKAGEVERSION' : '%%define release %s\nRelease: %%{release}\n',          'X_RPM_GROUP'    : 'Group: %s\n',          'SUMMARY'        : 'Summary: %s\n', -        'LICENSE'        : 'License: %s\n', } +        'LICENSE'        : 'License: %s\n', +    }      str = str + SimpleTagCompiler(mandatory_header_fields).compile( spec ) @@ -211,6 +209,7 @@ def build_specfile_header(spec):          'X_RPM_URL'           : 'Url: %s\n',          'SOURCE_URL'          : 'Source: %s\n',          'SUMMARY_'            : 'Summary(%s): %s\n', +        'ARCHITECTURE'        : 'BuildArch: %s\n',          'X_RPM_DISTRIBUTION'  : 'Distribution: %s\n',          'X_RPM_ICON'          : 'Icon: %s\n',          'X_RPM_PACKAGER'      : 'Packager: %s\n', @@ -229,19 +228,33 @@ def build_specfile_header(spec):          'X_RPM_PREFIX'        : 'Prefix: %s\n',          # internal use -        'X_RPM_BUILDROOT'     : 'BuildRoot: %s\n', } +        'X_RPM_BUILDROOT'     : 'BuildRoot: %s\n', +    }      # fill in default values: -    # Adding a BuildRequires renders the .rpm unbuildable under System, which +    # Adding a BuildRequires renders the .rpm unbuildable under systems which      # are not managed by rpm, since the database to resolve this dependency is      # missing (take Gentoo as an example) -#    if not s.has_key('x_rpm_BuildRequires'): -#        s['x_rpm_BuildRequires'] = 'scons' +    #if 'X_RPM_BUILDREQUIRES' not in spec: +    #    spec['X_RPM_BUILDREQUIRES'] = 'scons'      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 ) + +    # Add any extra specfile definitions the user may have supplied. +    # These flags get no processing, they are just added. +    # github #3164: if we don't turn off debug package generation +    # the tests which build packages all fail.  If there are no +    # extra flags, default to adding this one. If the user wants +    # to turn this back on, supply the flag set to None. + +    if 'X_RPM_EXTRADEFS' not in spec: +        spec['X_RPM_EXTRADEFS'] = ['%global debug_package %{nil}'] +    for extra in spec['X_RPM_EXTRADEFS']: +        str += extra + '\n' +      return str  #  | 
