Ejemplo n.º 1
0
def package(env, target, source, PACKAGEROOT, NAME, VERSION, PACKAGEVERSION,
            DESCRIPTION, SUMMARY, X_RPM_GROUP, LICENSE, **kw):
    # initialize the rpm tool
    SCons.Tool.Tool('rpm').generate(env)

    bld = env['BUILDERS']['Rpm']

    # 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
        # to work for both i386 and x86_64 Linux systems.
        archmap = {
            'i686': 'i386',
            'i586': 'i386',
            'i486': 'i386',
        }

        buildarchitecture = os.uname()[4]
        buildarchitecture = archmap.get(buildarchitecture, buildarchitecture)

        if kw.has_key('ARCHITECTURE'):
            buildarchitecture = kw['ARCHITECTURE']

        fmt = '%s-%s-%s.%s.rpm'
        #srcrpm = fmt % (NAME, VERSION, PACKAGEVERSION, 'src')
        binrpm = fmt % (NAME, VERSION, PACKAGEVERSION, buildarchitecture)

        #target = [ srcrpm, binrpm ]
        target = [
            binrpm,
        ]

    # get the correct arguments into the kw hash
    loc = locals()
    del loc['kw']
    kw.update(loc)
    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'):
        #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)
Ejemplo n.º 2
0
def package(env, target, source, PACKAGEROOT, NAME, VERSION,
            PACKAGEVERSION, DESCRIPTION, SUMMARY, X_RPM_GROUP, LICENSE,
            **kw):
    # initialize the rpm tool
    SCons.Tool.Tool('rpm').generate(env)

    bld = env['BUILDERS']['Rpm']

    # 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=.
        buildarchitecture = SCons.Tool.rpmutils.defaultMachine()

        if 'ARCHITECTURE' in kw:
            buildarchitecture = kw['ARCHITECTURE']

        fmt = '%s-%s-%s.%s.rpm'
        srcrpm = fmt % (NAME, VERSION, PACKAGEVERSION, 'src')
        binrpm = fmt % (NAME, VERSION, PACKAGEVERSION, buildarchitecture)

        target = [ srcrpm, binrpm ]

    # get the correct arguments into the kw hash
    loc=locals()
    del loc['kw']
    kw.update(loc)
    del kw['source'], kw['target'], kw['env']

    # if no "SOURCE_URL" tag is given add a default one.
    if 'SOURCE_URL' not in kw:
        #kw['SOURCE_URL']=(str(target[0])+".tar.gz").replace('.rpm', '')
        kw['SOURCE_URL']=(str(target[0])+".tar.gz").replace('.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 bld(env, target, source, **kw)
Ejemplo n.º 3
0
        escape = env['ESCAPE']
        def subst(matchobj):
            key = matchobj.group(1)
            if key not in env:
                return matchobj.group(0)
            else:
                val = env.subst('$' + key)
                return 'CONFIG_%s=%s' % (key, escape(val))
        config = re.sub(r'^CONFIG_(\w+)=.*', subst, template, flags=re.M)
        config_file.write(config)
    try:
        os.chmod(config_filename, 0o755)
    except: pass


template_env = OverrideEnvironment(config_env, {})

# strip any -Warning flags
cxxflags_cleaned = [x for x in config_env['LIBMAPNIK_CXXFLAGS']
                      if x.startswith('-Wp,') or not x.startswith('-W')]
# strip clang specific flags to avoid breaking gcc
# while it is not recommended to mix compilers, this nevertheless
# makes it easier to compile apps with gcc and mapnik-config against mapnik built with clang
cxxflags_cleaned = [x for x in cxxflags_cleaned if x != '-Qunused-arguments']
cxx_cleaned = config_env['CXX'].replace(' -Qunused-arguments', '')

template_env['CXXFLAGS'] = ' '.join(cxxflags_cleaned)
template_env['CXX'] = re.sub(r'^ccache +', '', cxx_cleaned)

template_env['DEFINES'] = ' '.join(config_env['LIBMAPNIK_DEFINES'])
Ejemplo n.º 4
0
def wheel_package_builder_wrapper(
    env,
    target,
    source=None,
    *,
    purelib=(),
    platlib=(),
    scripts=(),
    packages=None,
    root_is_purelib=True,
    python_tag='py3',
    abi_tag='none',
    platform_tag='any',
):
    if source is None:
        source = target
        target = '.'

    env = OverrideEnvironment(
        env, {
            '_WHEEL_ROOT_IS_PURELIB': root_is_purelib,
            '_WHEEL_TAG': '{}-{}-{}'.format(python_tag, abi_tag, platform_tag),
        })

    wheel_filename = format_wheel_package_filename(**env.Dictionary())

    target = env.arg2nodes(target, node_factory=env.Dir)
    target = target[0].File(wheel_filename)

    packages = packages or {}

    source = env.arg2nodes(source, node_factory=env.Entry)
    purelib = env.arg2nodes(purelib, node_factory=env.Entry)
    platlib = env.arg2nodes(platlib, node_factory=env.Entry)
    scripts = env.arg2nodes(scripts, node_factory=env.Entry)
    packages = {name: env.Dir(d) for name, d in packages.items()}

    wheel_entries = []

    for category, nodes in {
            None: source,
            'purelib': purelib,
            'platlib': platlib
    }.items():
        for node in nodes:
            if isinstance(node, WheelEntry):
                if category is not None:
                    raise ValueError(
                        "Cannot use WheelEntry sources with convenience parameters 'purelib' and 'platlib'"
                    )
                wheel_entry = node
            else:
                arcpath = find_package_entry_dest(node, packages)
                wheel_entry = WheelEntry(arcpath, node, category=category)

            wheel_entries.append(wheel_entry)

    for node in scripts:
        wheel_entries.append(
            WheelEntry(
                arcpath=node.name,
                source=node,
                category='scripts',
            ))

    return env._WheelFileInternal(target, wheel_entries)