Re: [gentoo-dev] [PATCH v2] sysroot.eclass: Add support for running Windows binaries via Wine

2026-01-28 Thread Sam James
Eli Schwartz  writes:

> On 1/27/26 10:01 AM, James Le Cuirot wrote:
>
 +  # Assume that Wine can do its own CPU emulation.
 +  install -m0755 /dev/stdin "${SCRIPT}" <<-EOF || die
>>>
>>> (What about my '-' question?)
>>>
 +  #!/bin/sh
 +  SANDBOX_ON=0 LD_PRELOAD= 
 WINEPATH="\${WINEPATH}\${WINEPATH+;};${winepath//\//\\}" exec wine "\${@}"
>>>
>>> shellcheck sez:
>>> SC3060 (warning): In POSIX sh, string replacement is undefined.
>> 
>> I think shellcheck iz wrong. The replacement happens in the Bash context, not
>> the /bin/sh context.
>
>
> I recommend assuming by default that shellcheck is always wrong.

That's what I do. I looked at first, was suspicious, and then ran it.

> But also, install a package and then run shellcheck on the installed file --
> don't even *try* to run shellcheck on strings of shell embedded in other
> shell scripts

.. but I missed that it's evaluated in the bash context instead.


signature.asc
Description: PGP signature


Re: [gentoo-dev] [PATCH v2] sysroot.eclass: Add support for running Windows binaries via Wine

2026-01-27 Thread Eli Schwartz
On 1/27/26 10:01 AM, James Le Cuirot wrote:

>>> +   # Assume that Wine can do its own CPU emulation.
>>> +   install -m0755 /dev/stdin "${SCRIPT}" <<-EOF || die
>>
>> (What about my '-' question?)
>>
>>> +   #!/bin/sh
>>> +   SANDBOX_ON=0 LD_PRELOAD= 
>>> WINEPATH="\${WINEPATH}\${WINEPATH+;};${winepath//\//\\}" exec wine "\${@}"
>>
>> shellcheck sez:
>> SC3060 (warning): In POSIX sh, string replacement is undefined.
> 
> I think shellcheck iz wrong. The replacement happens in the Bash context, not
> the /bin/sh context.


I recommend assuming by default that shellcheck is always wrong. But
also, install a package and then run shellcheck on the installed file --
don't even *try* to run shellcheck on strings of shell embedded in other
shell scripts


-- 
Eli Schwartz


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: [gentoo-dev] [PATCH v2] sysroot.eclass: Add support for running Windows binaries via Wine

2026-01-27 Thread James Le Cuirot
On Tue, Jan 27, 2026 at 02:29:25AM +, Sam James wrote:
> James Le Cuirot  writes:
> 
> > We do not support installing Wine for other architectures, so we assume
> > that Wine can do its own CPU emulation.
> >
> > The sandbox cannot handle Wine and emits a warning even if you allow all
> > writes, so it needs to be disabled.
> >
> > Unlike Linux shared libraries, Windows DLLs are placed in bin rather
> > than lib, so we need to include that in WINEPATH. lib has been included
> > too, just in case.
> >
> > binfmt_misc supports Windows binaries, but there is no point in
> > supporting that combination here, as Wine would need to be installed
> > locally regardless. This cannot be extended into a container like it can
> > with QEMU.
> >
> > This has been tested with i686-w64-mingw32 from crossdev against
> > dev-vcs/git[iconv] after dropping the iconv cross patch.
> >
> > Signed-off-by: James Le Cuirot 
> > ---
> >  eclass/sysroot.eclass | 16 +++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> >
> > I was quite surprised to find that winepath itself runs under Wine. I don't
> > like that much and thought it was reasonable to convert these particular 
> > paths
> > by hand.
> >
> > I also realised that libgcc is important here after finding that zstd.exe 
> > would
> > not run without it in the WINEPATH.
> >
> > diff --git a/eclass/sysroot.eclass b/eclass/sysroot.eclass
> > index 0fae642bf593c..3d710f4917419 100644
> > --- a/eclass/sysroot.eclass
> > +++ b/eclass/sysroot.eclass
> > @@ -80,7 +80,21 @@ sysroot_make_run_prefixed() {
> > fi
> > fi
> >
> > -   if [[ ${QEMU_ARCH} == $(qemu_arch "${CBUILD}") ]]; then
> > +   if [[ ${CHOST} = *-mingw32 ]]; then
> > +   if ! type -P wine >/dev/null; then
> > +   einfo "Wine not found. Continuing without ${SCRIPT##*/} 
> > wrapper."
> > +   return 1
> > +   fi
> > +
> > +   # UNIX paths can work, but programs will not expect this in 
> > %PATH%.
> > +   local 
> > winepath="Z:${LIBGCC};Z:${MYEROOT}/bin;Z:${MYEROOT}/usr/bin;Z:${MYEROOT}/$(get_libdir);Z:${MYEROOT}/usr/$(get_libdir)"
> > +
> > +   # Assume that Wine can do its own CPU emulation.
> > +   install -m0755 /dev/stdin "${SCRIPT}" <<-EOF || die
> 
> (What about my '-' question?)
> 
> > +   #!/bin/sh
> > +   SANDBOX_ON=0 LD_PRELOAD= 
> > WINEPATH="\${WINEPATH}\${WINEPATH+;};${winepath//\//\\}" exec wine "\${@}"
> 
> shellcheck sez:
> SC3060 (warning): In POSIX sh, string replacement is undefined.

I think shellcheck iz wrong. The replacement happens in the Bash context, not
the /bin/sh context.

> 
> > +   EOF
> > +   elif [[ ${QEMU_ARCH} == $(qemu_arch "${CBUILD}") ]]; then
> > # glibc: ld.so is a symlink, ldd is a binary.
> > # musl: ld.so doesn't exist, ldd is a symlink.
> > local DLINKER candidate





Re: [gentoo-dev] [PATCH v2] sysroot.eclass: Add support for running Windows binaries via Wine

2026-01-26 Thread Sam James
Sam James  writes:

> James Le Cuirot  writes:
>
>> We do not support installing Wine for other architectures, so we assume
>> that Wine can do its own CPU emulation.
>>
>> The sandbox cannot handle Wine and emits a warning even if you allow all
>> writes, so it needs to be disabled.
>>
>> Unlike Linux shared libraries, Windows DLLs are placed in bin rather
>> than lib, so we need to include that in WINEPATH. lib has been included
>> too, just in case.
>>
>> binfmt_misc supports Windows binaries, but there is no point in
>> supporting that combination here, as Wine would need to be installed
>> locally regardless. This cannot be extended into a container like it can
>> with QEMU.
>>
>> This has been tested with i686-w64-mingw32 from crossdev against
>> dev-vcs/git[iconv] after dropping the iconv cross patch.
>>
>> Signed-off-by: James Le Cuirot 
>> ---
>>  eclass/sysroot.eclass | 16 +++-
>>  1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> I was quite surprised to find that winepath itself runs under Wine. I don't
>> like that much and thought it was reasonable to convert these particular 
>> paths
>> by hand.
>>
>> I also realised that libgcc is important here after finding that zstd.exe 
>> would
>> not run without it in the WINEPATH.
>>
>> diff --git a/eclass/sysroot.eclass b/eclass/sysroot.eclass
>> index 0fae642bf593c..3d710f4917419 100644
>> --- a/eclass/sysroot.eclass
>> +++ b/eclass/sysroot.eclass
>> @@ -80,7 +80,21 @@ sysroot_make_run_prefixed() {
>>  fi
>>  fi
>>
>> -if [[ ${QEMU_ARCH} == $(qemu_arch "${CBUILD}") ]]; then
>> +if [[ ${CHOST} = *-mingw32 ]]; then
>> +if ! type -P wine >/dev/null; then
>> +einfo "Wine not found. Continuing without ${SCRIPT##*/} 
>> wrapper."
>> +return 1
>> +fi
>> +
>> +# UNIX paths can work, but programs will not expect this in 
>> %PATH%.
>> +local 
>> winepath="Z:${LIBGCC};Z:${MYEROOT}/bin;Z:${MYEROOT}/usr/bin;Z:${MYEROOT}/$(get_libdir);Z:${MYEROOT}/usr/$(get_libdir)"
>> +
>> +# Assume that Wine can do its own CPU emulation.
>> +install -m0755 /dev/stdin "${SCRIPT}" <<-EOF || die
>
> (What about my '-' question?)

(Sorry, missed the answer!)

>
>> +#!/bin/sh
>> +SANDBOX_ON=0 LD_PRELOAD= 
>> WINEPATH="\${WINEPATH}\${WINEPATH+;};${winepath//\//\\}" exec wine "\${@}"
>
> shellcheck sez:
> SC3060 (warning): In POSIX sh, string replacement is undefined.
>
>> +EOF
>> +elif [[ ${QEMU_ARCH} == $(qemu_arch "${CBUILD}") ]]; then
>>  # glibc: ld.so is a symlink, ldd is a binary.
>>  # musl: ld.so doesn't exist, ldd is a symlink.
>>  local DLINKER candidate


signature.asc
Description: PGP signature


Re: [gentoo-dev] [PATCH v2] sysroot.eclass: Add support for running Windows binaries via Wine

2026-01-26 Thread Sam James
James Le Cuirot  writes:

> We do not support installing Wine for other architectures, so we assume
> that Wine can do its own CPU emulation.
>
> The sandbox cannot handle Wine and emits a warning even if you allow all
> writes, so it needs to be disabled.
>
> Unlike Linux shared libraries, Windows DLLs are placed in bin rather
> than lib, so we need to include that in WINEPATH. lib has been included
> too, just in case.
>
> binfmt_misc supports Windows binaries, but there is no point in
> supporting that combination here, as Wine would need to be installed
> locally regardless. This cannot be extended into a container like it can
> with QEMU.
>
> This has been tested with i686-w64-mingw32 from crossdev against
> dev-vcs/git[iconv] after dropping the iconv cross patch.
>
> Signed-off-by: James Le Cuirot 
> ---
>  eclass/sysroot.eclass | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> I was quite surprised to find that winepath itself runs under Wine. I don't
> like that much and thought it was reasonable to convert these particular paths
> by hand.
>
> I also realised that libgcc is important here after finding that zstd.exe 
> would
> not run without it in the WINEPATH.
>
> diff --git a/eclass/sysroot.eclass b/eclass/sysroot.eclass
> index 0fae642bf593c..3d710f4917419 100644
> --- a/eclass/sysroot.eclass
> +++ b/eclass/sysroot.eclass
> @@ -80,7 +80,21 @@ sysroot_make_run_prefixed() {
>   fi
>   fi
>
> - if [[ ${QEMU_ARCH} == $(qemu_arch "${CBUILD}") ]]; then
> + if [[ ${CHOST} = *-mingw32 ]]; then
> + if ! type -P wine >/dev/null; then
> + einfo "Wine not found. Continuing without ${SCRIPT##*/} 
> wrapper."
> + return 1
> + fi
> +
> + # UNIX paths can work, but programs will not expect this in 
> %PATH%.
> + local 
> winepath="Z:${LIBGCC};Z:${MYEROOT}/bin;Z:${MYEROOT}/usr/bin;Z:${MYEROOT}/$(get_libdir);Z:${MYEROOT}/usr/$(get_libdir)"
> +
> + # Assume that Wine can do its own CPU emulation.
> + install -m0755 /dev/stdin "${SCRIPT}" <<-EOF || die

(What about my '-' question?)

> + #!/bin/sh
> + SANDBOX_ON=0 LD_PRELOAD= 
> WINEPATH="\${WINEPATH}\${WINEPATH+;};${winepath//\//\\}" exec wine "\${@}"

shellcheck sez:
SC3060 (warning): In POSIX sh, string replacement is undefined.

> + EOF
> + elif [[ ${QEMU_ARCH} == $(qemu_arch "${CBUILD}") ]]; then
>   # glibc: ld.so is a symlink, ldd is a binary.
>   # musl: ld.so doesn't exist, ldd is a symlink.
>   local DLINKER candidate


signature.asc
Description: PGP signature