From 54bdf5220dfe4550335252139d6c142a998d9081 Mon Sep 17 00:00:00 2001
From: vharseko <vharseko@3a-systems.ru>
Date: Mon, 25 Jul 2022 16:15:10 +0000
Subject: [PATCH] FIX wine32 install (from ppa:ondrej/php so that we will be able to install wine32:i386 without conflicts) (#245)

---
 .github/workflows/deploy.yml |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index a97718d..5b086d6 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -18,13 +18,27 @@
         if: runner.os == 'Linux'
         shell: bash
         run:   |
-           sudo dpkg --add-architecture i386
-           sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9
-           sudo add-apt-repository 'deb [arch=amd64] https://mirror.mxe.cc/repos/apt focal main'
-           sudo apt -qq update
-           sudo apt install -y --allow-downgrades libpcre2-8-0=10.34-7
-           sudo apt install -y wine32 
-           wine --version
+          set -x -u -o pipefail
+          source /etc/os-release
+          # Get rid of packages installed from ppa:ondrej/php so that we will be able to install wine32:i386 without conflicts
+          # (see issue https://github.com/actions/virtual-environments/issues/4589)
+          # In detail we:
+          #   1. Remove all packages that ppa:ondrej/php has but plain Ubuntu doesn't, i.e. libzip4 and everything PHP
+          #   2. Revert (remaining) packages that ppa:ondrej/php and plain Ubuntu share, back to the plain Ubuntu version
+          #   3. Assert that no packages from ppa:ondrej/php are left installed
+          dpkg -l | grep '^ii' | fgrep deb.sury.org | awk '{print $2}' | grep '^php' \
+            | xargs -r -t sudo apt-get remove --yes libzip4
+          sudo apt update && sudo apt upgrade
+          dpkg -l | grep '^ii' | fgrep deb.sury.org | grep -v libpcre2-posix3 | awk '{print $2}' | sed "s,\$,/${UBUNTU_CODENAME}," \
+            | xargs -r -t sudo apt-get install --yes --no-install-recommends --allow-downgrades -V
+          ! dpkg -l | grep '^ii' | fgrep deb.sury.org
+          # Install 32bit Wine
+          sudo dpkg --add-architecture i386  # for wine32
+          sudo apt-get update  # again, due to new architecture
+          sudo apt-get install --yes --no-install-recommends -V \
+              wine-stable \
+              wine32:i386
+          wine --version
       - uses: actions/checkout@v3
         with:
           fetch-depth: 0

--
Gitblit v1.10.0