Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
For building Wine staging
#!/bin/bash
# Builds Wine-staging
# Notes:
# 1. Targeted for usage inside a VM (use shared directory $HOME/mnt/vmshare between host and guest).
# 2. You'd need to separately push the result on the host to whatever location you want (like to /opt).
# 3. Place any manual patches in ${HOME}/build/patches
# 4. Override arch to something else if you aren't using Ryzen.
#
# Usage:
# wine_staging_build.sh [staging-patchset]
#
# Examples:
# 1. To build just Wine with esync patches:
#
# wine_staging_build.sh eventfd_synchronization
#
# 2. To build full Wine staging:
#
# wine_staging_build.sh
#
base=${HOME}/build
wine_branch=${wine_branch:-"master"}
wine_src=${base}/wine-git/source
wine_build=${base}/wine-git/build
wine_staging_branch=${wine_staging_branch:-"master"}
wine_staging_src=${base}/wine-staging
patches=${patches:-true} # enabled
patches_dir="${base}/patches-staging" # extra patches if any
arch=${arch:-"znver2"} # assumes Ryzen, change if needed
staging_patchset="$@"
if [[ "$staging_patchset" == "" ]]; then
staging_patchset='--all'
fi
if [[ "$wine_branch" == "wine"* ]]; then
dest_dir="${HOME}/mnt/vmshare/${wine_branch}-staging"
else
dest_dir="${HOME}/mnt/vmshare/wine-${wine_branch}-staging"
fi
export CXXFLAGS="-O3 -march=${arch}"
export CFLAGS="$CXXFLAGS"
function prepare() {
mkdir -p "$patches_dir"
mkdir -p "$wine_build"
}
function update_wine_sources() {
cd $(dirname "$wine_src")
git clone git://source.winehq.org/git/wine.git $(basename "$wine_src")
cd "$wine_src"
git reset --hard HEAD
git clean -df
git checkout master
git pull --rebase --prune
git checkout ${wine_branch}
if (($? != 0)); then
echo "Invalid branch or tag ${wine_branch}! Aborting"
exit 2
fi
}
function update_wine_staging_sources() {
cd $(dirname "$wine_staging_src")
git clone git://github.com/wine-staging/wine-staging.git $(basename "$wine_staging_src")
cd "$wine_staging_src"
git reset --hard HEAD
git clean -df
git checkout master
git pull --rebase --prune
git checkout ${wine_staging_branch}
if (($? != 0)); then
echo "Invalid branch or tag ${wine_staging_branch}! Aborting"
exit 2
fi
}
function extra_patch() {
local patch_dir="$1"
cd $wine_src
for patchfile in ${patch_dir}/*; do
echo "Applying ${patchfile}"
patch -p1 -i ${patchfile}
if (($? != 0)); then
echo "Extra patching failed, check what's wrong..."
exit 1
fi
done
}
function patch_staging {
cd $wine_staging_src/patches
./patchinstall.sh DESTDIR="$wine_src" $staging_patchset
if (($? != 0)); then
echo "Patching failed, check what's wrong..."
exit 1
fi
}
function patch_sources() {
if $patches; then
extra_patch "${base}/patches"
fi
patch_staging
}
function configure() {
rm -rfv ${wine_build}/*
cd $wine_build
${wine_src}/configure --enable-win64 --disable-tests --prefix=
}
function build() {
cd $wine_build
make -j$(nproc)
if (($? != 0)); then
echo "Build failed!"
exit 2
fi
}
function publish() {
cd $wine_build
mkdir -p ${dest_dir}
rm -rfv ${dest_dir}/*
DESTDIR=${dest_dir} make -j$(nproc) install
}
############################################
shopt -s nullglob
prepare
update_wine_sources
update_wine_staging_sources
patch_sources
configure
build
publish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment