#!/bin/env bash # Builds WINE. This is meant for a multilib system, and will build a WOW64-enabled WINE (one "wine" # executable for both 32-bit and 64-bit apps). The version built is the latest that wine-staging # is available for. # # This is based on the SBo SlackBuild. # Set STAGING=true to build with the wine-staging patches. set -e BUILD=${BUILD:-1} TAG=${TAG:-dc} TMP=${TMP:-/tmp} PKG=$TMP/package-wine BRANCH=${BRANCH:-6.x} STAGING=${STAGING:-false} if [[ -z $ARCH ]]; then case $( uname -m ) in i?86) ARCH=i486 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac fi case $ARCH in "i486") SLKCFLAGS="-O2 -march=i486 -mtune=i686" ;; "i686") SLKCFLAGS="-O2 -march=i686 -mtune=i686" ;; "x86_64") SLKCFLAGS="-O2 -fPIC" ;; *) SLKCFLAGS="-O2" ;; esac VERSION="$(python3 - << EOF import os from pathlib import PurePosixPath import requests url = 'https://api.github.com/repos/wine-staging/wine-staging/tags' headers = {'Accept': 'application/vnd.github.v3+json'} releases = requests.get(url, headers=headers).json() print(releases[0]['name'][1:]) EOF )" # Clean release-candidate versions (e.g. 4.0-rc1) so that they're Slackware-compatible (e.g. 4.0rc1). PKGVER=${VERSION//-/} rm -rf "$PKG" "$TMP/wine_src" cd "$TMP" mkdir wine_src cd wine_src wget "https://dl.winehq.org/wine/source/$BRANCH/wine-$VERSION.tar.xz" wget https://raw.githubusercontent.com/Ponce/slackbuilds/master/system/wine/slack-desc tar xvf "wine-${VERSION}.tar.xz" OPTS="" if [[ "$STAGING" != "false" ]]; then wget --content-disposition "https://github.com/wine-staging/wine-staging/archive/v$VERSION.tar.gz" tar xvf "wine-staging-${VERSION}.tar.gz" cd "wine-staging-$VERSION/patches" # The builds fail for me unless I disable GTK3 support. # As they say on tvtropes: YMMV. OPTS="--without-gtk3" ./patchinstall.sh --all DESTDIR="$TMP/wine_src/wine-$VERSION" fi cd "$TMP/wine_src/wine-$VERSION" chown -R root:root . find -L . \ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ -o -perm 511 \) -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; autoreconf -vif mkdir "$TMP/wine_src/win64-build" cd "$TMP/wine_src/win64-build" CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ "$TMP/wine_src/wine-$VERSION/configure" \ --enable-win64 \ --prefix=/usr \ --mandir=/usr/man \ --docdir=/usr/doc/wine-"$VERSION" \ --disable-tests \ --build="$ARCH"-slackware-linux \ "$OPTS" make mkdir -p "$TMP/wine_src/win32-build" cd "$TMP/wine_src/win32-build" CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ PKG_CONFIG_PATH=/usr/lib/pkgconfig \ "$TMP/wine_src/wine-$VERSION/configure" \ --prefix=/usr \ --mandir=/usr/man \ --docdir=/usr/doc/wine-"$VERSION" \ --disable-tests \ --build="$ARCH"-slackware-linux \ --with-wine64=../win64-build \ "$OPTS" make make install DESTDIR="$PKG" cd ../win64-build make install DESTDIR="$PKG" find "$PKG" -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true find "$PKG"/usr/man -type f -exec gzip -9 {} \; for i in $( find "$PKG/usr/man" -type l ) ; do ln -s "$( readlink "$i" ).gz" "$i.gz" ; rm $i ; done mkdir -p "$PKG/usr/doc/wine-$VERSION" cp -a "$TMP"/wine_src/wine-"$VERSION"/[[:upper:]][[:upper:]]* "$PKG/usr/doc/wine-$VERSION" mkdir -p "$PKG/install" cat "$TMP/wine_src/slack-desc" > "$PKG/install/slack-desc" cd "$PKG" /sbin/makepkg -l y -c n "$TMP/wine-${PKGVER}-${ARCH}-$BUILD$TAG.${PKGTYPE:-tgz}"