Пример #1
0
def add_wine_key(linux_release_name: str, quiet: bool = False) -> None:
    """
    >>> add_wine_key(configmagick_linux.get_linux_release_name(), quiet=True)

    """
    lib_log_utils.log_verbose(
        'Add Wine Key and Repository, linux_release_name="{linux_release_name}"'
        .format(linux_release_name=linux_release_name),
        quiet=quiet)
    lib_shell.run_shell_command('rm -f ./winehq.key*',
                                shell=True,
                                use_sudo=True,
                                quiet=quiet)
    lib_shell.run_shell_command(
        'wget -nv -c https://dl.winehq.org/wine-builds/winehq.key',
        use_sudo=True,
        quiet=quiet)
    lib_shell.run_shell_command('apt-key add winehq.key',
                                use_sudo=True,
                                quiet=quiet)
    lib_shell.run_shell_command('rm -f ./winehq.key*',
                                shell=True,
                                use_sudo=True,
                                quiet=quiet)
    lib_shell.run_shell_command(
        'apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ {linux_release_name} main"'
        .format(linux_release_name=linux_release_name),
        use_sudo=True,
        pass_stdout_stderr_to_sys=True,
        quiet=quiet)
Пример #2
0
def download_latest_git_files_from_github_to_winecache(
        wine_prefix: Union[str, pathlib.Path] = configmagick_linux.
    get_path_home_dir_current_user() / '.wine',
        username: str = configmagick_linux.get_current_username(),
        force_download: bool = False,
        quiet: bool = False) -> None:
    """
    >>> install_wine_machine.create_wine_test_prefixes()
    >>> download_latest_git_files_from_github_to_winecache(wine_prefix = 'wine_test_32', force_download=True, quiet=False)
    >>> download_latest_git_files_from_github_to_winecache(wine_prefix = 'wine_test_64', force_download=False, quiet=False)
    """
    wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix, username)
    wine_arch = lib_wine.get_wine_arch_from_wine_prefix(
        wine_prefix=wine_prefix, username=username)

    lib_log_utils.log_verbose(
        'Download latest Portable Git from Github to Wine Cache', quiet=quiet)
    git_download_link = get_git_portable_download_link_from_github(
        wine_arch=wine_arch)
    git_exe_filename = pathlib.Path(git_download_link.rsplit('/', 1)[1])

    if lib_wine.is_file_in_wine_cache(filename=git_exe_filename,
                                      username=username) or force_download:
        if force_download:
            lib_wine.remove_file_from_winecache(filename=git_exe_filename,
                                                username=username)
            lib_wine.download_file_to_winecache(
                download_link=git_download_link,
                filename=git_exe_filename,
                username=username)
    else:
        lib_wine.download_file_to_winecache(download_link=git_download_link,
                                            filename=git_exe_filename,
                                            username=username)
Пример #3
0
def download_latest_mono_msi_files_from_github(username: str,
                                               force_download: bool = False,
                                               quiet: bool = False) -> None:
    """
    >>> username = configmagick_linux.get_current_username()
    >>> force_download = True
    >>> download_latest_mono_msi_files_from_github(username=username, force_download=force_download)
    >>> force_download = False
    >>> download_latest_mono_msi_files_from_github(username=username, force_download=force_download)
    """
    lib_log_utils.log_verbose(
        'Download latest Mono MSI Files from Github to Wine Cache',
        quiet=quiet)
    mono_download_link = get_wine_mono_download_link_from_github()
    mono_msi_filename = pathlib.Path(mono_download_link.rsplit('/', 1)[1])

    if lib_wine.is_file_in_wine_cache(filename=mono_msi_filename,
                                      username=username) or force_download:
        if force_download:
            lib_wine.remove_file_from_winecache(filename=mono_msi_filename,
                                                username=username)
            lib_wine.download_file_to_winecache(
                download_link=mono_download_link,
                filename=mono_msi_filename,
                username=username)
    else:
        lib_wine.download_file_to_winecache(download_link=mono_download_link,
                                            filename=mono_msi_filename,
                                            username=username)
Пример #4
0
def install_mono_latest(wine_prefix: Union[
    str, pathlib.Path] = configmagick_linux.get_path_home_dir_current_user() /
                        '.wine',
                        username: str = configmagick_linux.
                        get_current_username(),
                        quiet: bool = False) -> None:
    """
    install the latest mono version from github

    >>> install_wine_machine.create_wine_test_prefixes()
    >>> install_mono_latest('wine_test_32', quiet=True)
    >>> install_mono_latest('wine_test_64', quiet=True)

    """
    wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix, username)
    wine_arch = lib_wine.get_wine_arch_from_wine_prefix(
        wine_prefix=wine_prefix, username=username)
    mono_download_link = get_wine_mono_download_link_from_github()
    mono_msi_filename = pathlib.Path(mono_download_link.rsplit('/', 1)[1])
    wine_cache_directory = lib_wine.get_path_wine_cache_for_user(
        username=username)
    lib_log_utils.banner_verbose(
        'Installing Wine Mono :\n'
        'WINEPREFIX="{wine_prefix}"\n'
        'WINEARCH="{wine_arch}"\n'
        'mono_msi_filename="{mono_msi_filename}"\n'
        'wine_cache_directory="{wine_cache_directory}"'.format(
            wine_prefix=wine_prefix,
            wine_arch=wine_arch,
            wine_cache_directory=wine_cache_directory,
            mono_msi_filename=mono_msi_filename),
        quiet=quiet)

    download_latest_mono_msi_files_from_github(username=username,
                                               force_download=False,
                                               quiet=quiet)

    lib_log_utils.log_verbose(
        'Install "{mono_msi_filename}" on WINEPREFIX="{wine_prefix}"'.format(
            mono_msi_filename=mono_msi_filename, wine_prefix=wine_prefix),
        quiet=quiet)

    command = 'WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine msiexec /i "{wine_cache_directory}/{mono_msi_filename}"'\
        .format(wine_prefix=wine_prefix,
                wine_arch=wine_arch,
                wine_cache_directory=wine_cache_directory,
                mono_msi_filename=mono_msi_filename)
    lib_shell.run_shell_command(command,
                                shell=True,
                                run_as_user=username,
                                pass_stdout_stderr_to_sys=True,
                                quiet=quiet)
    lib_wine.fix_wine_permissions(
        wine_prefix=wine_prefix,
        username=username)  # it is cheap, just in case
    lib_log_utils.banner_success(
        'Wine Mono "{mono_msi_filename}" installed'.format(
            mono_msi_filename=mono_msi_filename))
Пример #5
0
def install_libfaudio0_if_needed(quiet: bool = False) -> None:
    if int(configmagick_linux.get_linux_release_number_major()) >= 18:
        try:
            lib_log_utils.log_verbose('Install libfaudio0', quiet=quiet)
            configmagick_linux.install_linux_package('libfaudio0', quiet=quiet)
        except subprocess.CalledProcessError:
            lib_log_utils.log_verbose('Install libfaudio0 backport',
                                      quiet=quiet)
            install_libfaudio0_backport(quiet=quiet)
Пример #6
0
def install_wine_packages(wine_release: str,
                          reinstall: bool = False,
                          quiet: bool = False) -> None:
    lib_log_utils.log_verbose('Install Wine Packages', quiet=quiet)
    configmagick_linux.install_linux_package(
        'winehq-{wine_release}'.format(wine_release=wine_release),
        parameters=['--install-recommends'],
        reinstall=reinstall,
        quiet=quiet)
    configmagick_linux.install_linux_packages(
        ['cabextract', 'libxml2', 'libpng-dev'],
        reinstall=reinstall,
        quiet=quiet)
Пример #7
0
def install_gecko(wine_prefix: Union[
    str, pathlib.Path] = configmagick_linux.get_path_home_dir_current_user() /
                  '.wine',
                  username: str = configmagick_linux.get_current_username(),
                  quiet: bool = False) -> None:
    """
    install 32 Bit Gecko for 32/64 Bit Wine, and 64 Bit Gecko for 64 Bit Wine

    >>> install_wine_machine.create_wine_test_prefixes()
    >>> install_gecko(wine_prefix='wine_test_32', quiet=True)
    >>> install_gecko(wine_prefix='wine_test_64', quiet=True)

    """
    lib_log_utils.banner_verbose(
        'Install Gecko on WINEPREFIX="{wine_prefix}"'.format(
            wine_prefix=wine_prefix),
        quiet=quiet)
    wine_prefix = lib_wine.get_and_check_wine_prefix(
        wine_prefix, username)  # prepend /home/user if needed
    download_gecko_msi_files(wine_prefix=wine_prefix,
                             username=username,
                             quiet=True)
    wine_arch = lib_wine.get_wine_arch_from_wine_prefix(wine_prefix, username)

    if wine_arch == 'win32' or wine_arch == 'win64':
        lib_log_utils.log_verbose(
            'Install Gecko 32 Bit on WINEPREFIX="{wine_prefix}"'.format(
                wine_prefix=wine_prefix),
            quiet=quiet)
        install_gecko_32(wine_prefix=wine_prefix,
                         username=username,
                         quiet=quiet)

    if wine_arch == 'win64':
        lib_log_utils.log_verbose(
            'Install Gecko 64 Bit on WINEPREFIX="{wine_prefix}"'.format(
                wine_prefix=wine_prefix),
            quiet=quiet)
        install_gecko_64(wine_prefix=wine_prefix,
                         username=username,
                         quiet=quiet)

    lib_wine.fix_wine_permissions(
        wine_prefix=wine_prefix,
        username=username)  # it is cheap, just in case
    lib_log_utils.banner_success('Wine Gecko installed')
Пример #8
0
def install_git(wine_prefix: Union[
    str, pathlib.Path] = configmagick_linux.get_path_home_dir_current_user() /
                '.wine',
                username: str = configmagick_linux.get_current_username(),
                quiet: bool = False) -> None:
    """ install git on wine

    >>> install_wine_machine.create_wine_test_prefixes()
    >>> install_git(wine_prefix='wine_test_32', quiet=True)
    >>> install_git(wine_prefix='wine_test_64', quiet=True)

    """
    configmagick_linux.full_update_and_upgrade(quiet=quiet)
    configmagick_linux.install_linux_package('p7zip-full', quiet=quiet)
    wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix, username)
    wine_arch = lib_wine.get_wine_arch_from_wine_prefix(
        wine_prefix=wine_prefix, username=username)
    wine_cache_directory = lib_wine.get_path_wine_cache_for_user(
        username=username)
    path_git_filename = get_path_git_filename(wine_arch=wine_arch)
    lib_log_utils.banner_verbose(
        'Installing Git Portable :\n'
        'WINEPREFIX="{wine_prefix}"\n'
        'WINEARCH="{wine_arch}"\n'
        'git_filename="{path_git_filename}"\n'
        'wine_cache_directory="{wine_cache_directory}"'.format(
            wine_prefix=wine_prefix,
            wine_arch=wine_arch,
            path_git_filename=path_git_filename,
            wine_cache_directory=wine_cache_directory),
        quiet=quiet)

    download_latest_git_files_from_github_to_winecache(wine_prefix=wine_prefix,
                                                       username=username,
                                                       quiet=quiet)
    lib_log_utils.log_verbose(
        'Install "{path_git_filename}" on WINEPREFIX="{wine_prefix}"'.format(
            path_git_filename=path_git_filename, wine_prefix=wine_prefix),
        quiet=quiet)

    path_git_install_dir = wine_prefix / 'drive_c/Program Files/PortableGit'

    lib_shell.run_shell_command('rm -Rf "{path_git_install_dir}"'.format(
        path_git_install_dir=path_git_install_dir),
                                quiet=True,
                                use_sudo=True,
                                shell=True)
    # remove old installation if exists
    configmagick_linux.force_remove_directory_recursive(path_git_install_dir)
    command = '7z e {wine_cache_directory}/{path_git_filename} -o"{path_git_install_dir}" -y -bd'.format(
        wine_cache_directory=wine_cache_directory,
        path_git_filename=path_git_filename,
        path_git_install_dir=path_git_install_dir)
    lib_shell.run_shell_command(command,
                                shell=True,
                                run_as_user=username,
                                pass_stdout_stderr_to_sys=True,
                                quiet=quiet)
    lib_wine.fix_wine_permissions(
        wine_prefix=wine_prefix,
        username=username)  # it is cheap, just in case
    lib_wine.prepend_path_to_wine_registry_path(
        path_to_add='C:\\Program Files\\PortableGit',
        wine_prefix=wine_prefix,
        username=username)
    # we need to use wineconsole here
    command = 'WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wineconsole git --version'.format(
        wine_prefix=wine_prefix, wine_arch=wine_arch)
    try:
        lib_shell.run_shell_command(command,
                                    run_as_user=username,
                                    quiet=True,
                                    shell=True)
        lib_log_utils.banner_success('Git installed')
    except subprocess.CalledProcessError:
        raise RuntimeError(
            'can not install git portable on WINEPREFIX="{wine_prefix}"'.
            format(wine_prefix=wine_prefix))
Пример #9
0
def add_architecture_386(quiet: bool = False) -> None:
    lib_log_utils.log_verbose('Add 386 Architecture', quiet=quiet)
    lib_shell.run_shell_command('dpkg --add-architecture i386',
                                use_sudo=True,
                                pass_stdout_stderr_to_sys=True,
                                quiet=quiet)
Пример #10
0
def update_wine_packages(quiet: bool = False) -> None:
    lib_log_utils.log_verbose('Update wine packages', quiet=quiet)
    configmagick_linux.full_update_and_upgrade(quiet=quiet)
def install_python_nuget(wine_prefix: Union[
    str, pathlib.Path] = configmagick_linux.get_path_home_dir_current_user() /
                         '.wine',
                         username: str = configmagick_linux.
                         get_current_username(),
                         quiet: bool = False) -> None:
    """ install python on wine, using the nuget installer
        wine stable 4.0.2 : not working
        wine devel  4.19  : working
        wine staging 4.19 : working

    >>> install_wine_machine.create_wine_test_prefixes()
    >>> install_python_nuget(wine_prefix='wine_test_32', quiet=True)
    >>> install_python_nuget(wine_prefix='wine_test_64', quiet=True)

    >>> # test python 32 Bit installed
    >>> wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix='wine_test_32')
    >>> wine_arch = lib_wine.get_wine_arch_from_wine_prefix(wine_prefix=wine_prefix)
    >>> command = 'WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine '
    >>> result = lib_shell.run_shell_command('WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine python --version'
    ...                                      .format(wine_prefix=wine_prefix, wine_arch=wine_arch), shell=True, quiet=True)
    >>> assert result.stdout.startswith('Python')
    >>> assert '.' in result.stdout

    >>> # test python 64 Bit installed
    >>> wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix='wine_test_64')
    >>> wine_arch = lib_wine.get_wine_arch_from_wine_prefix(wine_prefix=wine_prefix)
    >>> command = 'WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine '
    >>> result = lib_shell.run_shell_command('WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine python --version'
    ...                                      .format(wine_prefix=wine_prefix, wine_arch=wine_arch), shell=True, quiet=True)
    >>> assert result.stdout.startswith('Python')
    >>> assert '.' in result.stdout

    """
    wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix, username)
    wine_arch = lib_wine.get_wine_arch_from_wine_prefix(
        wine_prefix=wine_prefix, username=username)
    if wine_arch == 'win32':
        python_version = 'pythonx86'
    else:
        python_version = 'python'

    wine_cache_directory = lib_wine.get_path_wine_cache_for_user(
        username=username)
    path_nuget_filename = pathlib.Path('nuget.exe')
    lib_log_utils.banner_verbose(
        'Installing Python :\n'
        'WINEPREFIX="{wine_prefix}"\n'
        'WINEARCH="{wine_arch}"\n'
        'wine_cache_directory="{wine_cache_directory}"'.format(
            wine_prefix=wine_prefix,
            wine_arch=wine_arch,
            wine_cache_directory=wine_cache_directory),
        quiet=quiet)

    download_nuget(username=username)

    lib_log_utils.log_verbose(
        'Install Python on WINEPREFIX="{wine_prefix}"'.format(
            wine_prefix=wine_prefix),
        quiet=quiet)

    command = 'DISPLAY="{display}" WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" '\
              'wineconsole "{wine_cache_directory}/{path_nuget_filename}" '\
              'install {python_version} -ExcludeVersion -OutputDirectory "C:\\Program Files"'\
        .format(display=configmagick_linux.get_env_display(),
                wine_prefix=wine_prefix,
                wine_arch=wine_arch,
                wine_cache_directory=wine_cache_directory,
                path_nuget_filename=path_nuget_filename,
                python_version=python_version)

    lib_shell.run_shell_command(command,
                                shell=True,
                                run_as_user=username,
                                pass_stdout_stderr_to_sys=True,
                                quiet=quiet)
    lib_wine.fix_wine_permissions(wine_prefix=wine_prefix, username=username)
    lib_wine.prepend_path_to_wine_registry_path(
        'C:\\Program Files\\{python_version}\\tools'.format(
            python_version=python_version),
        wine_prefix=wine_prefix,
        username=username)

    command = 'WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine python --version'.format(
        wine_prefix=wine_prefix, wine_arch=wine_arch)
    try:
        result = lib_shell.run_shell_command(command,
                                             run_as_user=username,
                                             quiet=True,
                                             shell=True)
        assert result.stdout.startswith('Python')
        lib_log_utils.banner_success('{python_version} installed OK'.format(
            python_version=result.stdout))
    except (subprocess.CalledProcessError, AssertionError):
        raise RuntimeError(
            'can not install Python on WINEPREFIX="{wine_prefix}"'.format(
                wine_prefix=wine_prefix))
Пример #12
0
def install_python(wine_prefix: Union[
    str, pathlib.Path] = configmagick_linux.get_path_home_dir_current_user() /
                   '.wine',
                   username: str = configmagick_linux.get_current_username(),
                   python_version: str = 'latest',
                   quiet: bool = False) -> None:
    """ install python on wine, using the normal installer - unfortunately this does not work on travis

    Parameter:
        python_version : 'latest' or valid Version number, like '3.8.0'

    >>> install_wine_machine.create_wine_test_prefixes()
    >>> install_python(wine_prefix='wine_test_32', quiet=True)
    >>> install_python(wine_prefix='wine_test_64', quiet=True)

    >>> # test python 32 Bit installed
    >>> wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix='wine_test_32')
    >>> wine_arch = lib_wine.get_wine_arch_from_wine_prefix(wine_prefix=wine_prefix)
    >>> command = 'WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine '
    >>> result = lib_shell.run_shell_command('WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine python --version'
    ...                                      .format(wine_prefix=wine_prefix, wine_arch=wine_arch), shell=True, quiet=True)
    >>> assert result.stdout.startswith('Python')
    >>> assert '.' in result.stdout

    >>> # test python 64 Bit installed
    >>> wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix='wine_test_64')
    >>> wine_arch = lib_wine.get_wine_arch_from_wine_prefix(wine_prefix=wine_prefix)
    >>> command = 'WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine '
    >>> result = lib_shell.run_shell_command('WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine python --version'
    ...                                      .format(wine_prefix=wine_prefix, wine_arch=wine_arch), shell=True, quiet=True)
    >>> assert result.stdout.startswith('Python')
    >>> assert '.' in result.stdout

    """
    wine_prefix = lib_wine.get_and_check_wine_prefix(wine_prefix, username)
    wine_arch = lib_wine.get_wine_arch_from_wine_prefix(
        wine_prefix=wine_prefix, username=username)
    if python_version == 'latest':
        python_version = get_latest_python_version()
    path_python_filename = get_path_python_exe_filename(version=python_version,
                                                        arch=wine_arch)
    wine_cache_directory = lib_wine.get_path_wine_cache_for_user(
        username=username)
    lib_log_utils.banner_verbose(
        'Installing Python :\n'
        'WINEPREFIX="{wine_prefix}"\n'
        'WINEARCH="{wine_arch}"\n'
        'python_filename="{path_python_filename}"\n'
        'wine_cache_directory="{wine_cache_directory}"'.format(
            wine_prefix=wine_prefix,
            wine_arch=wine_arch,
            wine_cache_directory=wine_cache_directory,
            path_python_filename=path_python_filename),
        quiet=quiet)

    download_python_exe_file(python_version=python_version,
                             wine_prefix=wine_prefix,
                             username=username)

    lib_log_utils.log_verbose(
        'Install "{path_python_filename}" on WINEPREFIX="{wine_prefix}"'.
        format(path_python_filename=path_python_filename,
               wine_prefix=wine_prefix),
        quiet=quiet)

    command = 'DISPLAY="{display}" WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" '\
              'wineconsole "{wine_cache_directory}/{path_python_filename}" '\
              '/quiet InstallAllUsers=1 PrependPath=1 Include_test=0'\
        .format(wine_prefix=wine_prefix,
                wine_arch=wine_arch,
                wine_cache_directory=wine_cache_directory,
                path_python_filename=path_python_filename,
                display=configmagick_linux.get_env_display())

    lib_shell.run_shell_command(command,
                                shell=True,
                                run_as_user=username,
                                pass_stdout_stderr_to_sys=True,
                                quiet=quiet)
    lib_wine.fix_wine_permissions(wine_prefix=wine_prefix, username=username)

    command = 'WINEPREFIX="{wine_prefix}" WINEARCH="{wine_arch}" wine python --version'.format(
        wine_prefix=wine_prefix, wine_arch=wine_arch)
    try:
        result = lib_shell.run_shell_command(command,
                                             run_as_user=username,
                                             quiet=True,
                                             shell=True)
        assert result.stdout.startswith('Python')
        lib_log_utils.banner_success('{python_version} installed OK'.format(
            python_version=result.stdout))
    except (subprocess.CalledProcessError, AssertionError):
        raise RuntimeError(
            'can not install Python on WINEPREFIX="{wine_prefix}"'.format(
                wine_prefix=wine_prefix))