Ejemplo n.º 1
0
def main():
    distro = get_distro()
    print()
    packages = get_packages(distro)
    dependencies = get_dependencies(distro, packages)

    if dependencies:
        install_command = install_commands[distro] + list(dependencies)

        print()
        print('Installing packages...')
        print(' '.join(install_command))
        run_command(install_command)
    else:
        print()
        print('No packages to install')

    print()
    print('Fetching submodules')
    for package in packages:
        if package.has_submodules:
            run_command(['git', 'submodule', 'update', '--init', '--recursive', package.path])

    print()
    for package in packages:
        print('Setting up {}'.format(package))
        package.setup(distro)
Ejemplo n.º 2
0
def get(package):
    """retrieves resources for packaging

    .. note:: package params are defined in packages.yaml

    .. note:: param names in packages.yaml can be overriden by editing
     definitions.py which also has an explanation on each param.

    :param dict package: dict representing package config
     as configured in packages.yaml
     will be appended to the filename and to the package
     depending on its type
    :rtype: `None`
    """

    def handle_sources_path(sources_path, overwrite):
        if sources_path is None:
            lgr.error('Sources path key is required under {0} '
                      'in packages.yaml.'.format(defs.PARAM_SOURCES_PATH))
            sys.exit(codes.mapping['sources_path_required'])
        u = utils.Handler()
        # should the source dir be removed before retrieving package contents?
        if overwrite:
            lgr.info('Overwrite enabled. removing {0} before retrieval'.format(
                sources_path))
            u.rmdir(sources_path)
        else:
            if os.path.isdir(sources_path):
                lgr.error('The destination directory for this package already '
                          'exists and overwrite is disabled.')
                sys.exit(codes.mapping['path_already_exists_no_overwrite'])
        # create the directories required for package creation...
        if not os.path.isdir(sources_path):
            u.mkdir(sources_path)

    # you can send the package dict directly, or retrieve it from
    # the packages.yaml file by sending its name
    c = package if isinstance(package, dict) else get_package_config(package)

    repo = yum.Handler() if CENTOS else apt.Handler() if DEBIAN else None
    retr = retrieve.Handler()
    py = python.Handler()
    rb = ruby.Handler()

    sources_path = c.get(defs.PARAM_SOURCES_PATH, None)
    handle_sources_path(
        sources_path, c.get(defs.PARAM_OVERWRITE_SOURCES, True))

    # TODO: (TEST) raise on "command not supported by distro"
    # TODO: (FEAT) add support for building packages from source
    repo.install(c.get(defs.PARAM_PREREQS, []))
    repo.add_src_repos(c.get(defs.PARAM_SOURCE_REPOS, []))
    if c.get(defs.PARAM_SOURCE_PPAS, []) and not DEBIAN:
        lgr.error('ppas not supported by {0}'.format(utils.get_distro()))
        sys.exit(codes.mapping['ppa_not_supported_by_distro'])
    repo.add_ppa_repos(c.get(defs.PARAM_SOURCE_PPAS, []))
    retr.downloads(c.get(defs.PARAM_SOURCE_KEYS, []), sources_path)
    repo.add_keys(c.get(defs.PARAM_SOURCE_KEYS, []), sources_path)
    retr.downloads(c.get(defs.PARAM_SOURCE_URLS, []), sources_path)
    repo.download(c.get(defs.PARAM_REQS, []), sources_path)
    if c.get(defs.PARAM_VIRTUALENV):
        with utils.chdir(os.path.abspath(sources_path)):
            py.make_venv(c['virtualenv']['path'])
        py.install(c['virtualenv']['modules'], c['virtualenv']['path'],
                   sources_path)
    py.get_modules(c.get(defs.PARAM_PYTHON_MODULES, []), sources_path)
    rb.get_gems(c.get(defs.PARAM_RUBY_GEMS, []), sources_path)
    # nd.get_packages(c.get(defs.PARAM_NODE_PACKAGES, []), sources_path)
    lgr.info('Package retrieval completed successfully!')
Ejemplo n.º 3
0
    def __init__(self, package):
        self.package = package

    def validate_package_properties(self):
        if defs.PARAM_DESTINATION_PACKAGE_TYPES in self.package:
            self.destination_package_types(
                self.package[defs.PARAM_DESTINATION_PACKAGE_TYPES])

    def destination_package_types(self, package_types):
        if not isinstance(package_types, list):
            lgr.error('{0} key must be of type "list".'.format(
                defs.PARAM_DESTINATION_PACKAGE_TYPES))
            sys.exit(codes.mapping['package_types_must_be_list'])
        for package_type in package_types:
            if package_type not in SUPPORTED_PACKAGE_TYPES:
                lgr.error('{0} key must contain one of: {1}.'.format(
                    defs.PARAM_DESTINATION_PACKAGE_TYPES,
                    SUPPORTED_PACKAGE_TYPES))
                sys.exit(codes.mapping['unsupported_package_type'])


def main():
    lgr.debug('Running in main...')

if __name__ == '__main__':
    main()

# TODO: fail on Windows
CENTOS = utils.get_distro() in ('centos')
DEBIAN = utils.get_distro() in ('Ubuntu', 'debian')
Ejemplo n.º 4
0
        self.package = package

    def validate_package_properties(self):
        if defs.PARAM_DESTINATION_PACKAGE_TYPES in self.package:
            self.destination_package_types(
                self.package[defs.PARAM_DESTINATION_PACKAGE_TYPES])

    def destination_package_types(self, package_types):
        if not isinstance(package_types, list):
            lgr.error('{0} key must be of type "list".'.format(
                defs.PARAM_DESTINATION_PACKAGE_TYPES))
            sys.exit(codes.mapping['package_types_must_be_list'])
        for package_type in package_types:
            if package_type not in SUPPORTED_PACKAGE_TYPES:
                lgr.error('{0} key must contain one of: {1}.'.format(
                    defs.PARAM_DESTINATION_PACKAGE_TYPES,
                    SUPPORTED_PACKAGE_TYPES))
                sys.exit(codes.mapping['unsupported_package_type'])


def main():
    lgr.debug('Running in main...')


if __name__ == '__main__':
    main()

# TODO: fail on Windows
CENTOS = utils.get_distro() in ('centos')
DEBIAN = utils.get_distro() in ('Ubuntu', 'debian')