Esempio n. 1
0
    def create(cls, name, files, artifact_name, artifact_type,
               target_directory, fpm_options, exclude_files=None, **kwargs):
        target = ArtifactTarget(name, **kwargs)
        # pylint: disable=W0201
        target.artifact_name = artifact_name
        target.target_directory = target_directory
        target.artifact_type = artifact_type
        target.fpm_options = fpm_options
        target.files = to_iterable(files)
        target.exclude_files = to_iterable(exclude_files)
        target.srcs = None

        return target
Esempio n. 2
0
    def _get_dir_mappings(self, inputdict):
        if 'artifact_target_dir_mappings' not in inputdict:
            return []

        expanded_mappings = []

        dir_mappings = to_iterable(inputdict['artifact_target_dir_mappings'])
        for dir_mapping in dir_mappings:
            source_dir, target_dir = dir_mapping.split('=')
            if not target_dir.startswith('/'):
                target_dir = os.path.join(self.target_directory, target_dir)
            expanded_mappings.append("%s/=%s" % (source_dir, target_dir))

        return expanded_mappings
Esempio n. 3
0
    def __init__(self, name, **kwargs):
        self.name = name

        # the buildfile from which this target originated. It is set after the
        # target is exec'd, i.e., prior to run() being called.
        self.buildFile = None

        # an optional list of dependencies. These are other targets that must
        # be run prior to the execution of this target.
        deps = kwargs.pop('deps', None)
        self.deps = to_iterable(deps)

        # legacy_name is unused internally, it is used to document the target
        self.legacy_name = kwargs.pop('legacy_name', None)

        for builtin in BUILTIN_TEMPLATE_OPTS:
            if builtin in kwargs:
                raise BuildConfigError("`%s` is a reserved parameter." %
                                       builtin)

        self.custom_options = kwargs

        Targets.add(self)
Esempio n. 4
0
def artifact_target(name, **kwargs):
    if 'files' not in kwargs:
        raise BuildConfigError(
            "artifact_target %s must contain a 'files' key" % name
        )
    files = kwargs.pop('files', None)
    files = flatten(to_iterable(files))

    if 'exclude_files' in kwargs:
        exclude_files = flatten(to_iterable(kwargs.pop('exclude_files')))
    else:
        exclude_files = []

    if 'artifact' not in kwargs:
        raise BuildConfigError(
            "artifact_target %s must contain an 'artifact' dictionary" % name
        )
    artifact = kwargs.pop('artifact')
    if not isinstance(artifact, dict):
        raise BuildConfigError(
            "artifact of artifact_target %s must be a "
            "dictionary" % name
        )
    if 'name' not in artifact:
        raise BuildConfigError(
            "artifact_target %s must contain a 'name' key" % name
        )

    if 'type' not in artifact:
        raise BuildConfigError(
            "artifact_target %s must contain a 'type' key" % name
        )

    if 'target_directory' not in artifact:
        raise BuildConfigError(
            "artifact_target %s must contain a 'target_directory' key" % name
        )
    if artifact['type'] not in ['deb']:
        raise BuildConfigError('Sorry, only .deb artifacts are supported')

    if 'fpm_options' not in artifact:
        raise BuildConfigError(
            "artifact_target %s must contain a 'fpm_options' dictionary" % name
        )
    opts = artifact['fpm_options']
    if 'deb-user' not in opts:
        raise BuildConfigError(
            "fpm_options dictionary of %s target must contain "
            "a 'deb-user' key" % name
        )
    if 'deb-group' not in opts:
        raise BuildConfigError(
            "fpm_options dictionary of %s target must contain a "
            "'deb-group' key" % name
        )
    if 'maintainer' not in opts:
        raise BuildConfigError(
            "fpm_options dictionary of %s target must contain a "
            "'maintiner' key" % name
        )

    return ArtifactTarget.create(
        name,
        files,
        artifact_name=artifact['name'],
        artifact_type=artifact['type'],
        target_directory=artifact['target_directory'],
        fpm_options=artifact['fpm_options'],
        exclude_files=exclude_files,
        **kwargs
    )
Esempio n. 5
0
 def ignore_paths(self):
     build_files = self.config.get('build_files', {})
     ignore_paths = build_files.get('ignore_paths')
     return to_iterable(ignore_paths)