<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _generate_metadata_file(workdir, archive_name, platform, python_versions, package_name, package_version, build_tag, package_source, wheels):
 """Generate a metadata file for the package. """

    logger.debug('Generating Metadata...')
    metadata = {
        'created_by_wagon_version': _get_wagon_version(),
        'archive_name': archive_name,
        'supported_platform': platform,
        'supported_python_versions': python_versions,
        'build_server_os_properties': {
            'distribution': None,
            'distribution_version': None,
            'distribution_release': None,
        },
        'package_name': package_name,
        'package_version': package_version,
        'package_build_tag': build_tag,
        'package_source': package_source,
        'wheels': wheels,
    }
    if IS_LINUX and platform != ALL_PLATFORMS_TAG:
        distribution, version, release = _get_os_properties()
        metadata.update(
            {'build_server_os_properties': {
                'distribution': distribution.lower(),
                'distribution_version': version.lower(),
                'distribution_release': release.lower()
            }})

    formatted_metadata = json.dumps(metadata, indent=4, sort_keys=True)
    if is_verbose():
        logger.debug('Metadata is: %s', formatted_metadata)
    output_path = os.path.join(workdir, METADATA_FILE_NAME)
    with open(output_path, 'w') as f:
        logger.debug('Writing metadata to file: %s', output_path)
        f.write(formatted_metadata)