#!/usr/bin/env bash # RUN AS NORMAL USER! X_BIT=32 X_TAG=wine-9.5 # tag or branch name X_PREFIX=$HOME/.local # default is /usr/local info() { GREEN='\033[1;32m' NC='\033[0m' echo -e "${GREEN}$1${NC}" } error() { RED='\033[1;31m' NC='\033[0m' echo -e "${RED}$1${NC}" } user=$(whoami) if [ $user == root ]; then error "You are using a root account. Script is designed to run under a normal user" exit 1 fi info 'Install 32-bit only? (y/N)? ' read answer if [ "$answer" != "${answer#[Yy]}" ] ;then X_BIT=32 info "Installing 32-bit only" else X_BIT=64 info "Installing 64-bit version with WoW (32-bit will be also compiled)" fi sudo dpkg --add-architecture i386 sudo apt update sudo apt install -y \ git \ build-essential \ autoconf \ automake \ ccache \ flex \ bison \ gettext \ cabextract \ winbind # 32-bit toolchain, needed for 32-bit builds sudo apt install -y gcc-multilib # MinGW cross-compiler, PE format DLLs sudo apt install -y gcc-mingw-w64 if [ $X_BIT == 64 ]; then # PulseAudio, sound backend sudo apt install -y libpulse-dev # Dynamic device detection (specifically, mass storage), Removable drives may be incorrectly detected otherwise sudo apt install -y libdbus-1-dev # Host font enumeration, host fonts detection sudo apt install -y libfontconfig-dev # FreeType font reading sudo apt install -y libfreetype-dev # Cryptography sudo apt install -y libgnutls28-dev # Hardware-accelerated/3D graphics sudo apt install -y libgl-dev # Exception unwinding, necessary for x86_64 and arm64, but not used on other platforms sudo apt install -y libunwind-dev # Window management sudo apt install -y libx11-dev # Window drawing sudo apt install -y libxcomposite-dev # Cursor management sudo apt install -y libxcursor-dev # Clipboard management sudo apt install -y libxfixes-dev # Keyboard and mouse sudo apt install -y libxi-dev # Display device management sudo apt install -y libxrandr-dev # Window drawing sudo apt install -y libxrender-dev # Window drawing sudo apt install -y libxext-dev # Multimedia playback, generally necessary for games or applications that play back audio or video files sudo apt install -y libgstreamer1.0-dev # same sudo apt install -y libgstreamer-plugins-base1.0-dev # OpenGL bitmap support sudo apt install -y libosmesa6-dev # HID joystick support, necessary for joystick or other HID support sudo apt install -y libsdl2-dev # Hardware-accelerated/3D graphics, Necessary for some games; only supported by some video cards sudo apt install -y libvulkan-dev # Wayland support needed this sudo apt install -y libxkbregistry-dev # For parallel computing or GPGPU software sudo apt install -y ocl-icd-opencl-dev # libnetapi for Samba NetAPI support sudo apt install -y samba-dev # Kerberos support sudo apt install -y libkrb5-dev # Direct3D 12 support sudo apt install -y libvkd3d-dev # mp3 codec support sudo apt install -y libmpg123-dev # TIFF format support sudo apt install -y libtiff-dev # JPEG format support sudo apt install -y libjpeg-dev # xslt support sudo apt install -y libxslt1-dev # XAudio sound processing sudo apt install -y libfaudio-dev # wcap support sudo apt install -y libpcap-dev # USB support sudo apt install -y libusb-1.0-0-dev # OpenLDAP support sudo apt install -y libldap-dev # OpenAL support sudo apt install -y libopenal-dev # CUPS support sudo apt install -y libcups2-dev # ISDN support (CAPI) sudo apt install -y libcapi20-dev # digital camera support sudo apt install -y libgphoto2-dev # Collection of video4linux support libraries sudo apt install -y libv4l-dev # Scanners support sudo apt install -y libsane-dev # Smart card using PC/SC sudo apt install -y libpcsclite-dev fi sudo apt install -y libpulse-dev:i386 \ libdbus-1-dev:i386 \ libfontconfig-dev:i386 \ libfreetype-dev:i386 \ libgnutls28-dev:i386 \ libgl-dev:i386 \ libunwind-dev:i386 \ libx11-dev:i386 \ libxcomposite-dev:i386 \ libxcursor-dev:i386 \ libxfixes-dev:i386 \ libxi-dev:i386 \ libxrandr-dev:i386 \ libxrender-dev:i386 \ libxext-dev:i386 \ libgstreamer1.0-dev:i386 \ libgstreamer-plugins-base1.0-dev:i386 \ libosmesa6-dev:i386 \ libsdl2-dev:i386 \ libvulkan-dev:i386 \ libxkbregistry-dev:i386 \ ocl-icd-opencl-dev:i386 \ samba-dev:i386 \ libkrb5-dev:i386 \ libvkd3d-dev:i386 \ libmpg123-dev:i386 \ libtiff-dev:i386 \ libjpeg-dev:i386 \ libxslt1-dev:i386 \ libfaudio-dev:i386 \ libpcap-dev:i386 \ libusb-1.0-0-dev:i386 \ libldap-dev:i386 \ libopenal-dev:i386 \ libcups2-dev:i386 \ libcapi20-dev:i386 \ libgphoto2-dev:i386 \ libv4l-dev:i386 \ libsane-dev:i386 \ libpcsclite-dev:i386 sudo apt install -y gstreamer1.0-plugins-good:i386 sudo apt install -y gstreamer1.0-plugins-ugly:i386 sudo apt install -y gstreamer1.0-plugins-good sudo apt install -y gstreamer1.0-plugins-ugly cd ~/Public if [ ! -d 'wine' ]; then git clone https://gitlab.winehq.org/wine/wine.git cd wine else cd wine git fetch --all git checkout master git pull origin master fi info "Confirm by pressing enter switching to $X_TAG"; read git checkout $X_TAG cd .. mkdir -p wine32 WoW='' if [ $X_BIT == 64 ]; then mkdir -p wine64 cd wine64 ../wine/configure CFLAGS="-fpermissive" CC="ccache gcc" CROSSCC="ccache x86_64-w64-mingw32-gcc" --enable-win64 -prefix=$X_PREFIX --disable-tests info "Press enter to proceed with compiling wine 64 bit"; read make -j$(nproc) cd .. WoW='--with-wine64=../wine64' fi cd wine32 PKG_CONFIG_PATH=/usr/lib/pkgconfig ../wine/configure CFLAGS="-fpermissive" CC="ccache gcc" CROSSCC="ccache i686-w64-mingw32-gcc" -prefix=$X_PREFIX --disable-tests $WoW info "Press enter to proceed with compiling wine 32 bit"; read make -j$(nproc) if [ $? != 0 ]; then error "Compilation failed" exit 1 fi cd $HOME/.local/bin wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks chmod 744 winetricks cd $HOME/Public/wine32 info "Now it can be installed into ${X_PREFIX} by the make install command in wine32 or wine64 dir"; info "REBOOT NOW and then read the notes below" # (!) FIRST RUN for 32 bit: # WINEARCH=win32 WINEPREFIX=~/wine32 winecfg # echo 'export WINEPREFIX="$HOME/wine32"' >> ~/.bashrc # exec $SHELL # wine reg add "HKEY_CURRENT_USER\Software\Wine\FileOpenAssociations" /v Enable /d N # wine reg add "HKEY_CURRENT_USER\Software\Wine\Drivers" /v Graphics /d x11,wayland # winetricks # to run under Wayland: # run commands as 'DISPLAY= wine64 notepad' for 64 bit OR 'DISPLAY= wine notepad' for 32 bit # xlsclients - lists the applications running under XWayland (thus not native Wayland windows) # xwininfo - check X window info (shows nothing if it is not X window) # usage examples: # wine start /unix path_to_installer # winefile OR wine explorer # wine explorer /desktop=name,1024x768 program.exe # sudo mount -o loop /media/tar/d/games/Unreal\ Turnament\ 2004/ut3.iso /home/tar/cd-rom/three # sudo mount -o loop -t iso9660 /media/tar/d/games/hmm5_tribes_of_the_east.mdf /home/tar/cd-rom/one # references: # https://wiki.winehq.org/Building_Wine # https://wiki.winehq.org/Winetricks # https://wiki.winehq.org/FAQ # https://wiki.archlinux.org/title/wine