commit:     c6424c7e33bc44b6b73741087ba04ff79241f4f8
Author:     NP-Hardass <NP-Hardass <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 22 22:39:37 2018 +0000
Commit:     NP Hardass <np-hardass <AT> gentoo <DOT> org>
CommitDate: Mon Jan 22 22:39:37 2018 +0000
URL:        https://gitweb.gentoo.org/repo/proj/wine.git/commit/?id=c6424c7e

app-emulation/wine-d3d9: Clean up manpage fixes

Use estack eclass to avoid dealing with specifics of shopt usage
Change implementation to handle any manpage from any locale
Remove linguas references, finishing l10n switch

Closes: https://bugs.gentoo.org/645238
Bug: https://bugs.gentoo.org/617864
Closes: https://bugs.gentoo.org/643576
Package-Manager: Portage-2.3.19, Repoman-2.3.6

 app-emulation/wine-d3d9/Manifest                 |  2 +-
 app-emulation/wine-d3d9/wine-d3d9-2.0-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.1-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.10-r1.ebuild | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.11-r1.ebuild | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.12-r1.ebuild | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.13-r1.ebuild | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.14-r1.ebuild | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.15-r1.ebuild | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.16-r1.ebuild | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.17-r1.ebuild | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.18.ebuild    | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.19.ebuild    | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.2-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.20.ebuild    | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.21.ebuild    | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.3-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.4-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.5-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.6-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.7-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.8-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-2.9-r1.ebuild  | 54 ++++++++++++------------
 app-emulation/wine-d3d9/wine-d3d9-9999.ebuild    | 54 ++++++++++++------------
 24 files changed, 622 insertions(+), 622 deletions(-)

diff --git a/app-emulation/wine-d3d9/Manifest b/app-emulation/wine-d3d9/Manifest
index c07ff88..0f97de4 100644
--- a/app-emulation/wine-d3d9/Manifest
+++ b/app-emulation/wine-d3d9/Manifest
@@ -1,4 +1,4 @@
-DIST gentoo-wine-patches-20180119.tar.xz 58688 SHA256 
bb8f634241e7a4ba528bb6e0db78512889c4d25773773e87d76a2452dde72360 SHA512 
3e605bf613dca333e501b5578d9c92a42d351a23f8d7d9d6a545a7dc043dcc4c7f52918e6ad46db63a6f00f3ace4b77055f8343176afb976e6a04590dcee64b7
 WHIRLPOOL 
46dfe36cce8e46a916b5e6f49e6674d9f9612b6ebbd3fd1ba47e6ff34bc68d95a916b76d1a61b0b25ddf97840dd78dffa2d7d0239e6fc0d3cbd74cc0c1868e9a
+DIST gentoo-wine-patches-20180120.tar.xz 58672 SHA256 
2708673a6a2da2546a0089c9fea93de81758546c2f9081fdac9ef81243f57b40 SHA512 
5b354a409c7a2b77499aaa593b9248a1d15d755e3687b095755faacc30068bfcdbdd5c2a2a78617cb1a78c46d2931162bd69ec3379b035d81494bea7108263c2
 WHIRLPOOL 
585563761161a14f0d435a3cee6e55216730d9fd46f7c930e7554c00a48f9c807bed8aa869a8f4aec4031abc2c18330ec98cbe0fe7d40b828b423f99acf40e37
 DIST wine-2.0.tar.bz2 23662707 SHA256 
9756f5a2129b6a83ba701e546173cbff86caa671b0af73eb8f72c03b20c066c6 SHA512 
b0a57ba8202d9fc396e5bfb7a7718d6bababbed8f3351e7fdc36afa37f35a871e04903757618f73427aeb71a52b2d323977d79e48f8b38d636f23fd404441186
 WHIRLPOOL 
fa9f774d87dae73c7d1f3b86dc3b03ea27065eb6140f1cac13c82fe16f7ebff8f8365ed447220cf5c2788b9f4aae7c482e4f9e2e69f47e5435209e148f5dbdfe
 DIST wine-2.1.tar.xz 18887032 SHA256 
bfb9abf63691c93df28d9599aaa866dc2b4e27209b3b7b546df8a37d7d9d1e6e SHA512 
03d678ee6e89c2804813f2827255fcf59e96ca9a45b7d8ac441cfc84f835e5e5689c70a79a41a04c631e1add7807fa4a5758acef3bd7aadfb2e92e68958c6ef6
 WHIRLPOOL 
063d935f1ff0922100641f2f53cdac23d2993a83182d45e028e485fd7d0a13bc5cfb77bca76550b1537b3f42fecacef7fd64785adbf6425af823f56f96973b54
 DIST wine-2.10.tar.xz 19209580 SHA256 
488df7ffd2e81da455bf428fc9eb784bb4273a890334500895665711bd52f179 SHA512 
8807e16a571bf45d99097ad5fdfb9fe755f6dbe84010a330fed82f1d48c76b7f19589bfc0e5dde0b9e49a608fd0501db3f7e3e129e4d9d34bcae03bc51a73139
 WHIRLPOOL 
e9a8248aac31593fbac28a3d8d4e62bfce14a7c41cc416ebfca8606518d28efd31b32196133da211f75f48bd228bd5d21fcbbc0479293e813ed99b258b37126e

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.0-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.0-r1.ebuild
index 3f8f071..27edc48 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.0-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.0-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.1-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.1-r1.ebuild
index 4963c3a..3008c1f 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.1-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.1-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.10-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.10-r1.ebuild
index 4c3f847..d647704 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.10-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.10-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.11-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.11-r1.ebuild
index 4c3f847..d647704 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.11-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.11-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.12-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.12-r1.ebuild
index 4c3f847..d647704 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.12-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.12-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.13-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.13-r1.ebuild
index 4c3f847..d647704 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.13-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.13-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.14-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.14-r1.ebuild
index 63b5cb6..2e9cde6 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.14-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.14-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.15-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.15-r1.ebuild
index 63b5cb6..2e9cde6 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.15-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.15-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.16-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.16-r1.ebuild
index 63b5cb6..2e9cde6 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.16-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.16-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.17-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.17-r1.ebuild
index 63b5cb6..2e9cde6 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.17-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.17-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.18.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.18.ebuild
index 0df97c3..442642a 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.18.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.18.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -171,7 +171,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-1.9.5-multilib-portage.patch" #395615
        "${PATCHDIR}/patches/${MY_PN}-1.6-memset-O3.patch" #480508
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=()
 
@@ -370,29 +370,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -528,16 +529,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.19.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.19.ebuild
index 0df97c3..442642a 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.19.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.19.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -171,7 +171,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-1.9.5-multilib-portage.patch" #395615
        "${PATCHDIR}/patches/${MY_PN}-1.6-memset-O3.patch" #480508
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=()
 
@@ -370,29 +370,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -528,16 +529,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.2-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.2-r1.ebuild
index 4963c3a..3008c1f 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.2-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.2-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.20.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.20.ebuild
index 7f16ff6..ddbc7bc 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.20.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.20.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-1.9.5-multilib-portage.patch" #395615
        "${PATCHDIR}/patches/${MY_PN}-1.6-memset-O3.patch" #480508
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=()
 
@@ -371,29 +371,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.21.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.21.ebuild
index 7f16ff6..ddbc7bc 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.21.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.21.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-1.9.5-multilib-portage.patch" #395615
        "${PATCHDIR}/patches/${MY_PN}-1.6-memset-O3.patch" #480508
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=()
 
@@ -371,29 +371,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.3-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.3-r1.ebuild
index 4963c3a..3008c1f 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.3-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.3-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.4-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.4-r1.ebuild
index 73d161b..aa8f381 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.4-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.4-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.5-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.5-r1.ebuild
index 73d161b..aa8f381 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.5-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.5-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.6-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.6-r1.ebuild
index 73d161b..aa8f381 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.6-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.6-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.7-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.7-r1.ebuild
index 73d161b..aa8f381 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.7-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.7-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.8-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.8-r1.ebuild
index 73d161b..aa8f381 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.8-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.8-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -373,29 +373,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-2.9-r1.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-2.9-r1.ebuild
index 4c3f847..d647704 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-2.9-r1.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-2.9-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -173,7 +173,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
        "${PATCHDIR}/patches/freetype-2.8.1-segfault.patch" #631676
        "${PATCHDIR}/patches/freetype-2.8.1-drop-glyphs.patch" #631376
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=(
        "${PATCHDIR}/patches/freetype-2.8.1-patch-fonts.patch" #631376
@@ -374,29 +374,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -532,16 +533,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

diff --git a/app-emulation/wine-d3d9/wine-d3d9-9999.ebuild 
b/app-emulation/wine-d3d9/wine-d3d9-9999.ebuild
index 7f16ff6..ddbc7bc 100644
--- a/app-emulation/wine-d3d9/wine-d3d9-9999.ebuild
+++ b/app-emulation/wine-d3d9/wine-d3d9-9999.ebuild
@@ -6,7 +6,7 @@ EAPI=6
 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt 
ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv 
te th tr uk wa zh_CN zh_TW"
 PLOCALE_BACKUP="en"
 
-inherit autotools eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
+inherit autotools estack eutils flag-o-matic gnome2-utils l10n multilib 
multilib-minimal pax-utils toolchain-funcs virtualx versionator xdg-utils
 
 MY_PN="${PN%%-*}"
 MY_P="${MY_PN}-${PV}"
@@ -26,7 +26,7 @@ S="${WORKDIR}/${MY_P}"
 
 D3D9_P="wine-d3d9-${PV}"
 D3D9_DIR="${WORKDIR}/wine-d3d9-patches-${D3D9_P}"
-GWP_V="20180119"
+GWP_V="20180120"
 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
 
 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Gallium Nine 
patchset"
@@ -172,7 +172,7 @@ PATCHES=(
        "${PATCHDIR}/patches/${MY_PN}-1.9.5-multilib-portage.patch" #395615
        "${PATCHDIR}/patches/${MY_PN}-1.6-memset-O3.patch" #480508
        "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
-       
"${PATCHDIR}/patches/${MY_PN}-2.0-prevent-build-of-localized-manpages.patch" 
#469418 #617864
+       "${PATCHDIR}/patches/${MY_PN}-2.0-rearrange-manpages.patch" #469418 
#617864
 )
 PATCHES_BIN=()
 
@@ -371,29 +371,30 @@ src_prepare() {
        l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect 
LINGUAS
 
        # Fix manpage generation for locales #469418 and abi_x86_64 #617864
-       # Depends on wine-2.0-prevent-build-of-localized-manpages.patch"
-       # Duplicate manpages input for wine64
-       local man
-       for man in loader/*.man.in; do
-               cp ${man} ${man/wine/wine64} || die
+       # Requires wine-2.0-rearrange-manpages.patch
+
+       # Duplicate manpages input files for wine64
+       local f
+       for f in loader/*.man.in; do
+               cp ${f} ${f/wine/wine64} || die
        done
-       # Add in proper manpages to Makefile
-       local search_text="wine.man.in"
+       # Add wine64 manpages to Makefile
        if use abi_x86_64; then
-               sed -i "/${search_text}/i \
-                       "$'\\\t'"wine64.man.in "$'\\\\' loader/Makefile.in || 
die
+               sed -i "/wine.man.in/i \
+                       \\\twine64.man.in \\\\" loader/Makefile.in || die
+               sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
+\164\2/' loader/Makefile.in || die
        fi
-       local l
-       for l in de fr pl; do
-               if has ${l} ${LINGUAS-${l}}; then
-                       sed -i "/${search_text}/i \
-                               "$'\\\t'"wine.${l}.UTF-8.man.in "$'\\\\' 
loader/Makefile.in || die
-                       if use abi_x86_64; then
-                               sed -i "/${search_text}/i \
-                                       "$'\\\t'"wine64.${l}.UTF-8.man.in 
"$'\\\\' loader/Makefile.in || die
-                       fi
-               fi
-       done
+
+       rm_man_file(){
+               local file="${1}"
+               loc=${2}
+               sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
+       }
+
+       while read f; do
+               l10n_for_each_disabled_locale_do rm_man_file "${f}"
+       done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; 
-print)
 }
 
 src_configure() {
@@ -530,16 +531,15 @@ multilib_src_install_all() {
                dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
        fi
 
-       # Failglob for bin and man loops
-       local glob_state=$(shopt -p failglob)
-       shopt -s failglob
-
+       # Failglob for binloops, shouldn't be necessary, but including to stay 
safe
+       eshopts_push -s failglob #615218
        # Make wrappers for binaries for handling multiple variants
        # Note: wrappers instead of symlinks because some are shell which use 
basename
        local b
        for b in "${D%/}${MY_PREFIX}"/bin/*; do
                make_wrapper "${b##*/}-${WINE_VARIANT}" 
"${MY_PREFIX}/bin/${b##*/}"
        done
+       eshopts_pop
 }
 
 pkg_postinst() {

Reply via email to