web-dev-qa-db-ja.com

WineにPythonをインストールします

WineのUbuntuボックスにWindowsバージョンPython 2.7.5 32Bitをインストールする必要があります(WineでEuler Math Toolboxをテストし、ネイティブPythonを使用できないため)。

何をするにしても、インストールの最後にエラーが表示されます(screendumpを参照)。 「python.2.7.5.msi」や「winetricks python26」までもインストールしようとしました。エラーは常に同じです。インストーラーが機能しないようです。

別のUbuntuシステムで以前にそれをやったが、うまくいった。

手伝ってくれてありがとう!

Screenshot of Error

「winetricks python26」の出力は次のとおりです。

rene@rene-stick:~/Arbeitsfläche$ winetricks python26
Executing w_do_call python26
Executing load_python26
Executing mkdir -p /home/rene/.cache/winetricks/python26
Downloading http://www.python.org/ftp/python/2.6.2/python-2.6.2.msi to /home/rene/.cache/winetricks/python26
--2013-08-08 14:47:10--  http://www.python.org/ftp/python/2.6.2/python-2.6.2.msi
Auflösen des Hostnamen »www.python.org (www.python.org)«... 82.94.164.162, 2001:888:2000:d::a2
Verbindungsaufbau zu www.python.org (www.python.org)|82.94.164.162|:80... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 200 OK
Länge: 14536192 (14M) [application/x-msi]
In »»python-2.6.2.msi«« speichern.

100%[======================================>] 14.536.192   683KB/s   in 21s    

2013-08-08 14:47:32 (673 KB/s) - »»python-2.6.2.msi«« gespeichert [14536192/14536192]

Executing mkdir -p /home/rene/.cache/winetricks/python26
Downloading http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20214/pywin32-214.win32-py2.6.exe to /home/rene/.cache/winetricks/python26
--2013-08-08 14:47:34--  http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20214/pywin32-214.win32-py2.6.exe
Auflösen des Hostnamen »downloads.sourceforge.net (downloads.sourceforge.net)«... 216.34.181.59
Verbindungsaufbau zu downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:80... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 302 Found
Platz: http://dfn.dl.sourceforge.net/project/pywin32/pywin32/Build%20214/pywin32-214.win32-py2.6.exe [folge]
--2013-08-08 14:47:34--  http://dfn.dl.sourceforge.net/project/pywin32/pywin32/Build%20214/pywin32-214.win32-py2.6.exe
Auflösen des Hostnamen »dfn.dl.sourceforge.net (dfn.dl.sourceforge.net)«... 194.95.248.253, 2001:638:d:c101:acdc:1979:2:1001
Verbindungsaufbau zu dfn.dl.sourceforge.net (dfn.dl.sourceforge.net)|194.95.248.253|:80... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 302 Found
Platz: http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20214/pywin32-214.win32-py2.6.exe?download&failedmirror=dfn.dl.sourceforge.net [folge]
--2013-08-08 14:47:34--  http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20214/pywin32-214.win32-py2.6.exe?download&failedmirror=dfn.dl.sourceforge.net
Wiederverwendung der bestehenden Verbindung zu downloads.sourceforge.net:80.
HTTP-Anforderung gesendet, warte auf Antwort... 302 Found
Platz: http://switch.dl.sourceforge.net/project/pywin32/pywin32/Build%20214/pywin32-214.win32-py2.6.exe [folge]
--2013-08-08 14:47:35--  http://switch.dl.sourceforge.net/project/pywin32/pywin32/Build%20214/pywin32-214.win32-py2.6.exe
Auflösen des Hostnamen »switch.dl.sourceforge.net (switch.dl.sourceforge.net)«... 130.59.138.21, 2001:620:0:1b::21
Verbindungsaufbau zu switch.dl.sourceforge.net (switch.dl.sourceforge.net)|130.59.138.21|:80... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 200 OK
Länge: 6438204 (6,1M) [application/octet-stream]
In »»pywin32-214.win32-py2.6.exe«« speichern.

100%[======================================>] 6.438.204    588KB/s   in 10s    

2013-08-08 14:47:45 (612 KB/s) - »»pywin32-214.win32-py2.6.exe«« gespeichert [6438204/6438204]

Executing wine msiexec /i python-2.6.2.msi ALLUSERS=1
fixme:storage:create_storagefile Storage share mode not implemented.
fixme:sxs:cache_QueryAssemblyInfo 0x3ec228, 0x00000002, L"Microsoft.VC90.CRT,version=\"9.0.21022.8\",publicKeyToken=\"1fc8b3b9a1e18e3b\",processorArchitecture=\"x86\",type=\"win32\"", 0x32f8c8
fixme:sxs:cache_QueryAssemblyInfo 0x3ec228, 0x00000002, L"policy.9.0.Microsoft.VC90.CRT,version=\"9.0.21022.8\",publicKeyToken=\"1fc8b3b9a1e18e3b\",processorArchitecture=\"x86\",type=\"win32-policy\"", 0x32f8c8
fixme:msi:ControlEvent_SpawnWaitDialog Doing Nothing
err:msi:ACTION_InstallFiles compressed file wasn't installed (L"C:\\Python26\\Lib\\test\\readme.txt")
err:msi:ITERATE_Actions Execution halted, action L"InstallFiles" returned 1603
err:msi:ITERATE_Actions Execution halted, action L"ExecuteAction" returned 1603
------------------------------------------------------
Note: command 'wine msiexec /i python-2.6.2.msi ALLUSERS=1' returned status 67.  Aborting.
------------------------------------------------------
5
Rene

友人がWine 1.6をインストールすることでこれを解決したと思います。

彼の命令は:

  1. Sudo add-apt-repository ppa:ubuntu-wine/ppa
  2. Sudo apt-get update
  3. Sudo apt-get install wine1.6 winetricks
  4. winetricks python26

たぶん、Wine 1.6への更新が主なポイントです。私は知らない。その後、Python 27.5をインストールできます。まったく問題ありません。

7
Rene

あなたが取得する場合

wine: cannot find L"C:\\windows\\system32\\python.exe"

インストール後に実行できます

wine /Users/user/.wine/drive_c/Python26/python.exe
1

実際には、最新のpython3.7/python2.7をwineで使用できます。

基本的に必要なことは、Windowsマシンにpythonをインストールし(「すべてのユーザー」ではなく「現在のユーザー」用)、ディレクトリ全体をワインマシンにコピーすることです。

または、Python ダウンロードページをリリース からダウンロードできます。

次に、ワインレジストリに次のパスを追加します: "c:\ python37; C:\ python37\Scripts; ..."そしてすべてが正常に機能します。

Ubuntu用に自動で行うために 便利なスクリプト をGithubで提供しました。これらは保守および更新されるため、使用することをお勧めします。リンクは変更される可能性があるため、以下の現在のインストールスクリプトを見つけてください。

ただし、WINE STABLE、WINE DEVELOP、またはWINE STAGINGのいずれをインストールするかを最初に決定する必要があります(WINE DEVELOPをお勧めします)。

次に、どのアーキテクチャ(32ビットまたは64ビットWine)を決定する必要があり、その上に、説明に従ってコピーして32または64ビットPython 2.7またはPython 3.7をインストールできます。前。

全体のプロセスは少し長く、インストールする必要がある多くの詳細があります。ここではスクリプト(それらは互いに依存しているため、すべてをダウンロードして、目的のパスに保存する必要があります):

#!/bin/bash
# ../home/install_wine.sh

function include_dependencies {
    local my_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"  # this gives the full path, even for sourced scripts
    chmod +x "${my_dir}/lib_bash/*.sh"
    source "${my_dir}/lib_bash/lib_color.sh"
    source "${my_dir}/lib_bash/lib_retry.sh"
    source "${my_dir}/lib_bash/lib_wine_install.sh"
}

include_dependencies  # me need to do that via a function to have local scope of my_dir




clr_bold clr_green "Install WINE"
check_wine_version

clr_green "add 386 Architecture"
retry Sudo dpkg --add-architecture i386
clr_green "add Wine Keys"
retry wget https://dl.winehq.org/wine-builds/winehq.key
Sudo apt-key add winehq.key
Sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main'
clr_green "Wine Packages Update"
retry Sudo apt-get update
clr_green "Wine Packages Install"
retry Sudo apt-get install --install-recommends winehq-${wine_version}
retry Sudo apt-get install -y cabextract
retry Sudo apt-get install -y libxml2
retry Sudo apt-get install -y libpng-dev

clr_green "Install latest Winetricks"
Sudo rm -f /usr/bin/winetricks
retry Sudo wget --directory-prefix=/usr/bin/ https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
Sudo chmod +x /usr/bin/winetricks
retry Sudo winetricks -q --self-update
clr_green "Install latest Winetricks - done"

clr_green "done"
clr_green "******************************************************************************************************************"
clr_bold clr_green "FINISHED installing WINE and WINETRICKS"
clr_green "******************************************************************************************************************"

#!/bin/bash
# ../home/install_wine_machine.sh

function include_dependencies {
    local my_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"  # this gives the full path, even for sourced scripts
    chmod +x "${my_dir}/lib_bash/*.sh"
    source "${my_dir}/lib_bash/lib_color.sh"
    source "${my_dir}/lib_bash/lib_retry.sh"
    source "${my_dir}/lib_bash/lib_wine_install.sh"
}

include_dependencies  # me need to do that via a function to have local scope of my_dir

clr_bold clr_green "Install Wine Machine"
check_wine_prefix
check_wine_Arch
check_wine_windows_version
check_headless_xvfb

clr_green "Setup Wine Machine at ${WINEPREFIX}, WINEARCH=${WINEARCH}, wine_windows_version=${wine_windows_version}"
mkdir -p ${WINEPREFIX}
wine_drive_c_dir=${WINEPREFIX}/drive_c
# xvfb-run --auto-servernum winecfg # fails marshal_object couldnt get IPSFactory buffer for interface ...

if [[ ${xvfb_framebuffer_service_active} == "True" ]]; then Sudo service xvfb stop ; fi   # winecfg fails if xvfb server is running
winecfg
if [[ ${xvfb_framebuffer_service_active} == "True" ]]; then Sudo service xvfb start ; fi     # winecfg fails if xvfb server is running

echo "Disable GUI Crash Dialogs"
winetricks nocrashdialog

echo "Set Windows Version to ${wine_windows_version}"
winetricks -q ${wine_windows_version}

echo "Install common Packets"

retry winetricks -q windowscodecs
retry winetricks -q msxml3

clr_green "done"
clr_green "******************************************************************************************************************"
clr_bold clr_green "FINISHED installing Wine Machine ${WINEPREFIX}"
clr_green "******************************************************************************************************************"

#!/bin/bash
# ../home/install_wine_python2_preinstalled.sh

function include_dependencies {
    local my_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"  # this gives the full path, even for sourced scripts
    chmod +x "${my_dir}/lib_bash/*.sh"
    source "${my_dir}/lib_bash/lib_color.sh"
    source "${my_dir}/lib_bash/lib_retry.sh"
    source "${my_dir}/lib_bash/lib_wine_install.sh"
}

include_dependencies  # me need to do that via a function to have local scope of my_dir

# if used outside github/travis You need to set :
# WINEARCH=win32    for 32 Bit Wine
# WINEARCH=         for 64 Bit Wine
# WINEPREFIX defaults to ${HOME}/.wine   or you need to pass it via environment variable
# if running headless, the xvfb service needs to run


clr_bold clr_green "Install Python 2.7 on WINE"
check_wine_prefix
check_wine_Arch

wine_drive_c_dir=${WINEPREFIX}/drive_c
decompress_dir=${HOME}/bitranox_decompress
mkdir -p ${decompress_dir}

python_version_short=python27
python_version_doc="Python 2.7"

clr_green "Download ${python_version_doc} Binaries from https://github.com/bitranox/binaries_${python_version_short}_wine/archive/master.Zip"
retry wget -nc --no-check-certificate -O ${decompress_dir}/binaries_${python_version_short}_wine-master.Zip https://github.com/bitranox/binaries_${python_version_short}_wine/archive/master.Zip

clr_green "Unzip ${python_version_doc} Master to ${HOME}"
unzip -nqq ${decompress_dir}/binaries_${python_version_short}_wine-master.Zip -d ${decompress_dir}

if [[ "${WINEARCH}" == "win32" ]]
    then
        clr_green "Joining Multipart Zip in ${decompress_dir}/binaries_${python_version_short}_wine-master/bin"
        cat ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/python*_wine_32* > ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/joined_${python_version_short}.Zip
        add_pythonpath="c:/Python27-32;c:/Python27-32/Scripts"
    else
        clr_green "Joining Multipart Zip in ${decompress_dir}/binaries_${python_version_short}_wine-master/bin"
        cat ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/python*_wine_64* > ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/joined_${python_version_short}.Zip
        add_pythonpath="c:/Python27-64;c:/Python27-64/Scripts"
    fi

clr_green "Unzip ${python_version_doc} to ${wine_drive_c_dir}"
unzip -qq ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/joined_${python_version_short}.Zip -d ${wine_drive_c_dir}

prepend_path_to_wine_registry ${add_pythonpath}

clr_green "done"
clr_green "******************************************************************************************************************"
clr_bold clr_green "FINISHED installing Python 2.7 on Wine Machine ${WINEPREFIX}"
clr_green "******************************************************************************************************************"

#!/bin/bash
# ../home/install_wine_python3_preinstalled.sh

function include_dependencies {
    local my_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"  # this gives the full path, even for sourced scripts
    chmod +x "${my_dir}/lib_bash/*.sh"
    source "${my_dir}/lib_bash/lib_color.sh"
    source "${my_dir}/lib_bash/lib_retry.sh"
    source "${my_dir}/lib_bash/lib_wine_install.sh"
}

include_dependencies  # me need to do that via a function to have local scope of my_dir

# if used outside github/travis You need to set :
# WINEARCH=win32    for 32 Bit Wine
# WINEARCH=""       for 64 Bit Wine
# WINEPREFIX defaults to ${HOME}/.wine   or you need to pass it via environment variable

# if running headless, the xvfb service needs to run

clr_bold clr_green "Install Python 3.7 on WINE"
check_wine_prefix
check_wine_Arch


wine_drive_c_dir=${WINEPREFIX}/drive_c
decompress_dir=${HOME}/bitranox_decompress
mkdir -p ${decompress_dir}

python_version_short=python37
python_version_doc="Python 3.7"

clr_green "Download ${python_version_doc} Binaries from https://github.com/bitranox/binaries_${python_version_short}_wine/archive/master.Zip"
retry wget -nc --no-check-certificate -O ${decompress_dir}/binaries_${python_version_short}_wine-master.Zip https://github.com/bitranox/binaries_${python_version_short}_wine/archive/master.Zip

clr_green "Unzip ${python_version_doc} Master to ${HOME}"
unzip -nqq ${decompress_dir}/binaries_${python_version_short}_wine-master.Zip -d ${decompress_dir}

if [[ "${WINEARCH}" == "win32" ]]
    then
        clr_green "Joining Multipart Zip in ${decompress_dir}/binaries_${python_version_short}_wine-master/bin"
        cat ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/python*_wine_32* > ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/joined_${python_version_short}.Zip
        add_pythonpath="c:/Python37-32;c:/Python37-32/Scripts"
    else
        clr_green "Joining Multipart Zip in ${decompress_dir}/binaries_${python_version_short}_wine-master/bin"
        cat ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/python*_wine_64* > ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/joined_${python_version_short}.Zip
        add_pythonpath="c:/Python37-64;c:/Python37-64/Scripts"
    fi

clr_green "Unzip ${python_version_doc} to ${wine_drive_c_dir}"
unzip -qq ${decompress_dir}/binaries_${python_version_short}_wine-master/bin/joined_${python_version_short}.Zip -d ${wine_drive_c_dir}

prepend_path_to_wine_registry ${add_pythonpath}


clr_green "done"
clr_green "******************************************************************************************************************"
clr_bold clr_green "FINISHED installing Python 3.7 on Wine Machine ${WINEPREFIX}"
clr_green "******************************************************************************************************************"

#!/bin/bash
# ../home/install_wine_git_portable.sh

function include_dependencies {
    local my_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"  # this gives the full path, even for sourced scripts
    chmod +x "${my_dir}/lib_bash/*.sh"
    source "${my_dir}/lib_bash/lib_color.sh"
    source "${my_dir}/lib_bash/lib_retry.sh"
    source "${my_dir}/lib_bash/lib_wine_install.sh"
}

include_dependencies  # me need to do that via a function to have local scope of my_dir

# if used outside github/travis You need to set :
# WINEARCH=win32    for 32 Bit Wine
# WINEARCH=         for 64 Bit Wine
# WINEPREFIX defaults to ${HOME}/.wine   or you need to pass it via environment variable

# if running headless, the xvfb service needs to run

clr_bold clr_green "Install Git Portable"
check_wine_prefix
check_wine_Arch

wine_drive_c_dir=${WINEPREFIX}/drive_c
decompress_dir=${HOME}/bitranox_decompress
mkdir -p ${decompress_dir}

clr_green "Download Git Portable Binaries"
retry wget -nc --no-check-certificate -O ${decompress_dir}/binaries_portable_git-master.Zip https://github.com/bitranox/binaries_portable_git/archive/master.Zip

clr_green "Unzip Git Portable Binaries Master to ${decompress_dir}"
unzip -nqq ${decompress_dir}/binaries_portable_git-master.Zip -d ${decompress_dir}

if [[ "${WINEARCH}" == "win32" ]]
    then
        clr_green "Joining Multipart Zip in ${decompress_dir}/binaries_portable_git-master/bin"
        cat ${decompress_dir}/binaries_portable_git-master/bin/PortableGit32* > ${decompress_dir}/binaries_portable_git-master/bin/joined_PortableGit.Zip
        add_git_path="c:/PortableGit32/cmd"
    else
        clr_green "Joining Multipart Zip in ${decompress_dir}/binaries_portable_git-master/bin"
        cat ${decompress_dir}/binaries_portable_git-master/bin/PortableGit64* > ${decompress_dir}/binaries_portable_git-master/bin/joined_PortableGit.Zip
        add_git_path="c:/PortableGit64/cmd"
    fi

clr_green "Unzip Git Portable Binaries to ${wine_drive_c_dir}"
unzip -qq ${decompress_dir}/binaries_portable_git-master/bin/joined_PortableGit.Zip -d ${wine_drive_c_dir}

prepend_path_to_wine_registry ${add_git_path}

clr_green "done"
clr_green "******************************************************************************************************************"
clr_bold clr_green "FINISHED installing Git Portable on Wine Machine ${WINEPREFIX}"
clr_green "******************************************************************************************************************"

#!/bin/bash
# ../home/lib_bash/lib_color.sh
#
# Constants and functions for terminal colors.
# Author: Max Tsepkov <[email protected]>
# Manual see https://github.com/mercuriev/bash_colors
#


CLR_ESC="\033["

# All these variables has a function with the same name, but in lower case.
#
CLR_RESET=0             # reset all attributes to their defaults
CLR_RESET_UNDERLINE=24  # underline off
CLR_RESET_REVERSE=27    # reverse off
CLR_DEFAULT=39          # set underscore off, set default foreground color
CLR_DEFAULTB=49         # set default background color

CLR_BOLD=1              # set bold
CLR_BRIGHT=2            # set half-bright (simulated with color on a color display)
CLR_UNDERSCORE=4        # set underscore (simulated with color on a color display)
CLR_REVERSE=7           # set reverse video

CLR_BLACK=30            # set black foreground
CLR_RED=31              # set red foreground
CLR_GREEN=32            # set green foreground
CLR_BROWN=33            # set brown foreground
CLR_BLUE=34             # set blue foreground
CLR_Magenta=35          # set Magenta foreground
CLR_CYAN=36             # set cyan foreground
CLR_WHITE=37            # set white foreground

CLR_BLACKB=40           # set black background
CLR_REDB=41             # set red background
CLR_GREENB=42           # set green background
CLR_BROWNB=43           # set brown background
CLR_BLUEB=44            # set blue background
CLR_MAGENTAB=45         # set Magenta background
CLR_CYANB=46            # set cyan background
CLR_WHITEB=47           # set white background


# check if string exists as function
# usage: if fn_exists "sometext"; then ... fi
function fn_exists
{
    type -t "$1" | grep -q 'function'
}

# iterate through command arguments, o allow for iterative color application
function clr_layer
{
    # default echo setting
    CLR_ECHOSWITCHES="-e"
    CLR_STACK=""
    CLR_SWITCHES=""
    ARGS=("$@")

    # iterate over arguments in reverse
    for ((i=$#; i>=0; i--)); do
        ARG=${ARGS[$i]}
        # echo $ARG
        # set CLR_VAR as last argtype
        firstletter=${ARG:0:1}

        # check if argument is a switch
        if [ "$firstletter" = "-" ] ; then
            # if -n is passed, set switch for echo in clr_escape
            if [[ $ARG == *"n"* ]]; then
                CLR_ECHOSWITCHES="-en"
                CLR_SWITCHES=$ARG
            fi
        else
            # last arg is the incoming string
            if [ -z "$CLR_STACK" ]; then
                CLR_STACK=$ARG
            else
                # if the argument is function, apply it
                if [ -n "$ARG" ] && fn_exists $ARG; then
                    #continue to pass switches through recursion
                    CLR_STACK=$($ARG "$CLR_STACK" $CLR_SWITCHES)
                fi
            fi
        fi
    done

    # pass stack and color var to escape function
    clr_escape "$CLR_STACK" $1;
}

# General function to wrap string with escape sequence(s).
# Ex: clr_escape foobar $CLR_RED $CLR_BOLD
function clr_escape
{
    local result="$1"
    until [ -z "${2:-}" ]; do
    if ! [ $2 -ge 0 -a $2 -le 47 ] 2>/dev/null; then
        echo "clr_escape: argument \"$2\" is out of range" >&2 && return 1
    fi
        result="${CLR_ESC}${2}m${result}${CLR_ESC}${CLR_RESET}m"
    shift || break
    done

    echo "$CLR_ECHOSWITCHES" "$result"
}

function clr_reset           { clr_layer $CLR_RESET "$@";           }
function clr_reset_underline { clr_layer $CLR_RESET_UNDERLINE "$@"; }
function clr_reset_reverse   { clr_layer $CLR_RESET_REVERSE "$@";   }
function clr_default         { clr_layer $CLR_DEFAULT "$@";         }
function clr_defaultb        { clr_layer $CLR_DEFAULTB "$@";        }
function clr_bold            { clr_layer $CLR_BOLD "$@";            }
function clr_bright          { clr_layer $CLR_BRIGHT "$@";          }
function clr_underscore      { clr_layer $CLR_UNDERSCORE "$@";      }
function clr_reverse         { clr_layer $CLR_REVERSE "$@";         }
function clr_black           { clr_layer $CLR_BLACK "$@";           }
function clr_red             { clr_layer $CLR_RED "$@";             }
function clr_green           { clr_layer $CLR_GREEN "$@";           }
function clr_brown           { clr_layer $CLR_BROWN "$@";           }
function clr_blue            { clr_layer $CLR_BLUE "$@";            }
function clr_Magenta         { clr_layer $CLR_Magenta "$@";         }
function clr_cyan            { clr_layer $CLR_CYAN "$@";            }
function clr_white           { clr_layer $CLR_WHITE "$@";           }
function clr_blackb          { clr_layer $CLR_BLACKB "$@";          }
function clr_redb            { clr_layer $CLR_REDB "$@";            }
function clr_greenb          { clr_layer $CLR_GREENB "$@";          }
function clr_brownb          { clr_layer $CLR_BROWNB "$@";          }
function clr_blueb           { clr_layer $CLR_BLUEB "$@";           }
function clr_magentab        { clr_layer $CLR_MAGENTAB "$@";        }
function clr_cyanb           { clr_layer $CLR_CYANB "$@";           }
function clr_whiteb          { clr_layer $CLR_WHITEB "$@";          }

# Outputs colors table
function clr_dump
{
    local T='gYw'

    echo -e "\n                 40m     41m     42m     43m     44m     45m     46m     47m";

    for FGs in '   0m' '   1m' '  30m' '1;30m' '  31m' '1;31m' \
               '  32m' '1;32m' '  33m' '1;33m' '  34m' '1;34m' \
               '  35m' '1;35m' '  36m' '1;36m' '  37m' '1;37m';
    do
        FG=${FGs// /}
        echo -en " $FGs \033[$FG  $T  "
        for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
            echo -en " \033[$FG\033[$BG  $T  \033[0m";
        done
        echo;
    done

    echo
    clr_bold "    Code     Function           Variable"
    echo \
'    0        clr_reset          $CLR_RESET
    1        clr_bold           $CLR_BOLD
    2        clr_bright         $CLR_BRIGHT
    4        clr_underscore     $CLR_UNDERSCORE
    7        clr_reverse        $CLR_REVERSE

    30       clr_black          $CLR_BLACK
    31       clr_red            $CLR_RED
    32       clr_green          $CLR_GREEN
    33       clr_brown          $CLR_BROWN
    34       clr_blue           $CLR_BLUE
    35       clr_Magenta        $CLR_Magenta
    36       clr_cyan           $CLR_CYAN
    37       clr_white          $CLR_WHITE

    40       clr_blackb         $CLR_BLACKB
    41       clr_redb           $CLR_REDB
    42       clr_greenb         $CLR_GREENB
    43       clr_brownb         $CLR_BROWNB
    44       clr_blueb          $CLR_BLUEB
    45       clr_magentab       $CLR_MAGENTAB
    46       clr_cyanb          $CLR_CYANB
    47       clr_whiteb         $CLR_WHITEB
'
}

function fail {
  clr_bold clr_red "${1}" >&2
  exit 1
}

## make it possible to call functions without source include
# Check if the function exists (bash specific)
if [[ ! -z "$1" ]]
    then
        if declare -f "${1}" > /dev/null
        then
          # call arguments verbatim
          "$@"
        else
          # Show a helpful error
          function_name="${1}"
          library_name="${0}"
          fail "\"${function_name}\" is not a known function name of \"${library_name}\""
        fi
    fi

#!/bin/bash
# ../home/lib_bash/lib_retry.sh

function include_dependencies {
    local my_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"  # this gives the full path, even for sourced scripts
    source "${my_dir}/lib_color.sh"
}

include_dependencies  # we need to do that via a function to have local scope of my_dir


function fail {
  clr_bold clr_red "${1}" >&2
  exit 1
}


function retry {
  local n=1
  local max=5
  local delay=5
  while true; do
    my_command="${@}"
    "$@" && break || {
      if [[ $n -lt $max ]]; then
        ((n++))
        clr_bold clr_red "Command \"${my_command}\" failed. Attempt ${n}/${max}:"
        sleep $delay;
      else
        fail "The command \"${my_command}\" has failed after ${n} attempts."
      fi
    }
  done
}


## make it possible to call functions without source include
# Check if the function exists (bash specific)
if [[ ! -z "$1" ]]
    then
        if declare -f "${1}" > /dev/null
        then
          # call arguments verbatim
          "$@"
        else
          # Show a helpful error
          function_name="${1}"
          library_name="${0}"
          fail "\"${function_name}\" is not a known function name of \"${library_name}\""
        fi
    fi

#!/bin/bash
# ../home/lib_bash/lib_wine_install.sh

function include_dependencies {
    local my_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"  # this gives the full path, even for sourced scripts
    chmod +x "${my_dir}/*.sh"
    source "${my_dir}/lib_color.sh"
    source "${my_dir}/lib_retry.sh"
}

include_dependencies  # we need to do that via a function to have local scope of my_dir


function fail {
  clr_bold clr_red "${1}" >&2
  exit 1
}


function check_wine_version {
    if [[ -z ${wine_version} ]]
        then
            clr_bold clr_red "WARNING - no wine_version in environment set - set now to default: devel"
            echo "available Versions: stable, devel, staging"
            export wine_version="devel"
        fi
}


function check_wine_prefix {
    ## set wine prefix to ${HOME}/.wine if not given by environment variable
    if [[ -z ${WINEPREFIX} ]]
        then
            clr_bold clr_red "WARNING - no WINEPREFIX in environment - set now to ${HOME}/.wine"
            export WINEPREFIX=${HOME}/.wine
        fi
}

function check_wine_Arch {
    if [[ -z ${WINEARCH} ]]
        then
            clr_bold clr_red "WARNING - no WINEARCH in environment - will install 64 Bit Wine"
            clr_bold clr_red "in Order to install 32Bit You need to set WINEARCH=\"win32\""
            clr_bold clr_red "in Order to install 64Bit You need to set WINEARCH=\"\""
        fi
}


function check_wine_windows_version {
    if [[ -z ${wine_windows_version} ]]
        then
            clr_bold clr_red "WARNING - no wine_windows_version in environment - set now to win10"
            clr_bold clr_red "available Versions: win10, win2k, win2k3, win2k8, win31, win7, win8, win81, win95, win98, winxp"
            export wine_windows_version="win10"
        fi
}


function check_headless_xvfb {
    clr_green "Check if we run headless and xvfb Server is running"
    export xvfb_framebuffer_service_active="False"
    systemctl is-active --quiet xvfb && export xvfb_framebuffer_service_active="True"
    # run winetricks with xvfb if needed
    if [[ ${xvfb_framebuffer_service_active} == "True" ]]
        then
            clr_green "we run headless, xvfb service is running"
        else
            clr_green "we run on normal console, xvfb service is not running"
        fi
}

function prepend_path_to_wine_registry {
    add_pythonpath="${1}"
    clr_green "add Path Settings to Registry"
    wine_current_reg_path="`wine reg QUERY \"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\" /v PATH | grep REG_SZ | sed 's/^.*REG_SZ\s*//'`"
    wine_new_reg_path="${add_pythonpath};${wine_current_reg_path}"
    wine reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /t REG_SZ /v PATH /d "${wine_new_reg_path}" /f
    wine_actual_reg_path="`wine reg QUERY \"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\" /v PATH | grep REG_SZ | sed 's/^.*REG_SZ\s*//'`"
    clr_green "adding Path done"
    clr_bold clr_green "Wine Registry PATH=${wine_actual_reg_path}"
}


## make it possible to call functions without source include
# Check if the function exists (bash specific)
if [[ ! -z "$1" ]]
    then
        if declare -f "${1}" > /dev/null
        then
          # call arguments verbatim
          "$@"
        else
          # Show a helpful error
          function_name="${1}"
          library_name="${0}"
          fail "\"${function_name}\" is not a known function name of \"${library_name}\""
        fi
    fi

0
bitranox