Пример #1
0
def _install_local(configured_name, platform, package, package_path,
                   install_dir, installed, dry_run):
    logger.info("installing %s from local archive" % package.name)
    metadata, files = _install_common(configured_name, platform, package,
                                      package_path, install_dir, installed,
                                      dry_run)

    if metadata:
        installed_package = package.copy()
        if platform not in package.platforms:
            installed_platform = configfile.PlatformDescription(
                dict(name=platform))
        else:
            installed_platform = installed_package.get_platform(platform)
        if installed_platform.archive is None:
            installed_platform.archive = configfile.ArchiveDescription()
        installed_platform.archive.url = "file://" + os.path.abspath(
            package_path)
        installed_platform.archive.hash = common.compute_md5(package_path)
        metadata.install_type = 'local'
        metadata.dirty = True
        logger.warning(
            "Using --local install flags any resulting package as 'dirty'")
        _update_installed_package_files(metadata,
                                        installed_package,
                                        platform=platform,
                                        installed=installed,
                                        install_dir=install_dir,
                                        files=files)
        return True
    else:
        return False
def edit(config, args_name, args_archive, arguments):
    """
    Modifies an existing installable entry.
    """
    (metadata, platform_description)  = _get_new_metadata(config, args_name, args_archive, arguments)
    package_name = metadata.package_description.name

    if package_name not in config.installables:
        raise InstallablesError('package %s does not exist, use add instead' % package_name)
    if args_name and args_name != package_name:
        raise InstallablesError('name argument (%s) does not match package name (%s)' % (args_name, package_name))
        
    installed_package_description = config.installables[package_name]
    for element in _PACKAGE_ATTRIBUTES:
        if element in metadata.package_description \
          and  metadata.package_description[element] is not None:
          installed_package_description[element] = metadata.package_description[element]

    platform_name = platform_description.name
    if platform_name in installed_package_description.platforms:
        installed_platform_description = installed_package_description.platforms[platform_name]
    else:
        installed_platform_description = configfile.PlatformDescription()
        installed_platform_description.name = platform_name
        installed_package_description.platforms[platform_name] = platform_description.copy()

    for element in _ARCHIVE_ATTRIBUTES:
        if element in metadata.archive \
          and metadata.archive[element] is not None:
            installed_package_description.platforms[platform_name].archive[element] = metadata.archive[element]
Пример #3
0
 def _create_or_update_platform(self, name, build_directory):
     try:
         platform_description = self.config.get_platform(name)
     except configfile.ConfigurationError:
         platform_description = configfile.PlatformDescription(
             {'name': name})
         self.config.package_description.platforms[
             name] = platform_description
     if build_directory is not None:
         platform_description.build_directory = build_directory
Пример #4
0
 def _create_or_update_platform_archive(self, platform, format,
                                        hash_algorithm):
     try:
         platform_description = self.config.get_platform(platform)
     except configfile.ConfigurationError:
         platform_description = configfile.PlatformDescription(
             {'name': platform})
         self.config.package_description.platforms[
             platform] = platform_description
     if platform_description.archive is None:
         platform_description.archive = configfile.ArchiveDescription()
     platform_description.archive.format = format
     platform_description.archive.hash_algorithm = hash_algorithm
def _install_binary(configured_name, platform, package, config_file, install_dir, installed, dry_run):
    # Check that we have a platform-specific or common url to use.
    req_plat = package.get_platform(platform)
    package_name = getattr(package, 'name', '(undefined)')
    if not req_plat:
        logger.warning("package %s has no installation information configured for platform %s"
                       % (package_name, platform))
        return False
    archive = req_plat.archive
    if not archive:
        raise InstallError("no archive specified for package %s for platform %s" %
                           (package_name, platform))
    if not archive.url:
        raise InstallError("no url specified for package %s for platform %s" % (package_name, platform))
    # Is this package already installed?
    installed_pkg = installed.dependencies.get(package.name)

    # Rely on ArchiveDescription's equality-comparison method to discover
    # whether the installed ArchiveDescription matches the requested one. This
    # test also handles the case when inst_plat.archive is None (not yet
    # installed).
    if installed_pkg and installed_pkg['install_type'] == 'local':
        logger.warning("""skipping %s package because it was installed locally from %s
  To allow new installation, run 
  autobuild uninstall %s""" % (package_name, installed_pkg['archive']['url'], package_name))
        return False

    # get the package file in the cache, downloading if needed, and verify the hash
    # (raises InstallError on failure, so no check is needed)
    cachefile = get_package_file(package_name, archive.url, hash_algorithm=(archive.hash_algorithm or 'md5'), expected_hash=archive.hash)
    if cachefile is None:
        raise InstallError("Failed to download package '%s' from '%s'" % (package_name, archive.url))

    metadata, files = _install_common(configured_name, platform, package, cachefile, install_dir, installed, dry_run)
    if metadata:
        installed_package = package.copy()
        if platform not in package.platforms:
            installed_platform = configfile.PlatformDescription(dict(name=platform))
        else:
            installed_platform = installed_package.get_platform(platform)
        if installed_platform.archive is None:
            installed_platform.archive = configfile.ArchiveDescription()
        metadata.install_type = 'package'
        _update_installed_package_files(metadata, package,
                                        platform=platform, installed=installed,
                                        install_dir=install_dir, files=files)
        return True
    else:
        return False
Пример #6
0
    def _create_build_config_desc(self, config, name, platform, build,
                                  configure):
        if not name:
            raise AutobuildError('build configuration name not given')

        init_dict = dict({
            'build': build,
            'configure': configure,
            'name': name
        })
        build_config_desc = configfile.BuildConfigurationDescription(init_dict)
        try:
            platform_description = config.get_platform(platform)
        except configfile.ConfigurationError:
            platform_description = configfile.PlatformDescription()
            platform_description.name = platform
        platform_description.configurations[name] = build_config_desc
        config.package_description.platforms[platform] = platform_description
        return build_config_desc
def _get_new_metadata(config, args_name, args_archive, arguments):
    # Get any name/value pairs from the command line
    key_values = _dict_from_key_value_arguments(arguments)

    if args_archive and 'url' in key_values:
        raise InstallablesError("--archive (%s) and url (%s) may not both be specified" \
                                % (args_archive, key_values['url']))
    if args_archive:
        archive_path = args_archive.strip()
    elif 'url' in key_values:
        archive_path = key_values.pop('url')
    else:
        archive_path = None
    archive_file = None
    if archive_path:
        if _is_uri(archive_path):
            archive_url = archive_path
        else:
            archive_url = 'file://' + config.absolute_path(archive_path)
        archive_file = get_package_file(
            args_name,
            archive_url,
            hash_algorithm=key_values.get('hash_algorithm', 'md5'),
            expected_hash=key_values.get('hash', None))
        if archive_file:
            metadata = get_metadata_from_package(archive_file)
            metadata.archive = configfile.ArchiveDescription()
            metadata.archive.url = archive_url
            if 'hash' not in key_values:
                logger.warning("No hash specified, computing from %s" %
                               archive_file)
                metadata.archive['hash'] = common.compute_md5(archive_file)
                metadata.archive['hash_algorithm'] = 'md5'

    if archive_file is None:
        logger.warning(
            "Archive not downloaded; some integrity checks may not work")
        metadata = configfile.MetadataDescription(create_quietly=True)
        metadata.package_description = configfile.PackageDescription(
            dict(name=args_name))
        metadata.archive = configfile.ArchiveDescription()
        metadata.archive.url = archive_path

    package_name = _check_name(args_name, key_values, metadata)
    if metadata.package_description['name'] is None:
        metadata.package_description['name'] = package_name

    for description_key in _PACKAGE_ATTRIBUTES:
        if description_key in key_values:
            logger.warning(
                "specifying '%s' in the installable is no longer required\n  if it is in the package metadata"
                % description_key)
            if description_key in metadata.package_description \
              and metadata.package_description[description_key] is not None \
              and key_values[description_key] != metadata.package_description[description_key]:
                raise InstallablesError("command line %s (%s) does not match archive %s (%s)" \
                                        % (description_key, key_values[description_key],
                                           description_key, metadata.package_description[description_key]))
            else:
                metadata.package_description[description_key] = key_values.pop(
                    description_key)

    for archive_key in _ARCHIVE_ATTRIBUTES:
        if archive_key in key_values:
            if archive_key in metadata.archive \
              and metadata.archive[archive_key] \
              and key_values[archive_key] != metadata.archive[archive_key]:
                raise InstallablesError("command line %s (%s) does not match archive %s (%s)" \
                                        % (archive_key, key_values[archive_key],
                                           archive_key, metadata.archive[archive_key]))
            else:
                metadata.archive[archive_key] = key_values.pop(archive_key)

    if 'platform' in key_values:
        if 'platform' in metadata \
          and metadata['platform'] is not None \
          and key_values['platform'] != metadata['platform'] \
          and metadata['platform'] != common.PLATFORM_COMMON:
            raise InstallablesError("specified platform '%s' does not match archive platform '%s'" \
                                    % ( key_values['platform'], metadata['platform']))
        else:
            platform = key_values.pop('platform')
    else:
        if 'platform' in metadata \
          and metadata['platform'] is not None:
            platform = metadata['platform']
        else:
            raise InstallablesError("Unspecified platform")

    platform_description = configfile.PlatformDescription()
    platform_description.name = platform
    platform_description.archive = metadata.archive.copy()

    _warn_unused(key_values)
    return (metadata, platform_description)