How to execute shell scripts from 32-bit Wine on 6

2019-08-03 07:37发布

问题:

My 32-bit application is running under Wine, and to help it better integrate with the environment, it runs some shell scripts. I was just testing under Ubuntu 14.04 64-bit, and my program crashed with this error:

err:process:create_process starting 64-bit process L"Z:\\bin\\sh" not supported in 32-bit wineprefix

I've tried searching for a 32-bit build of "sh" on my system, but couldn't find one. Any creative ideas on how I can get past this issue?

回答1:

I am a user of the program in question and I did some experimenting with it.

Not 32-bit vs. 64-bit but "shared object" vs. "executable" ?

Running file /bin/dash it prints:

/bin/dash: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV), ...

Running file /bin/bash however prints:

/bin/bash: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), ...

dash is a "shared object" while bash is an "executable". Clearly /bin/dash seems to work like an executable in some way (I don't know the technical details here), but it seems that this difference matters to Wine.

I got the same error as you reported (can't start 64 bit process) for Wine 1.4, but the error I got on newer versions of Wine was wine: Bad EXE format for Z:\bin\sh..

If you actually just replace /bin/sh with /bin/bash (even though that's a 64-bit binary) it will work. Wine also didn't seem to like running a symlink, but copying over /bin/bash worked.

So first back up the existing (symlinked) /bin/sh with:

sudo cp /bin/sh /bin/sh_orig

Then copy bash to sh:

sudo cp /bin/bash /bin/sh

Then when I ran Wine with the program and its calls to /bin/sh work fine.

Alternatively, you download a 32-bit shell directly

Pull down the .deb file for the 32-bit bash shell:

 wget http://us.archive.ubuntu.com/ubuntu/pool/main/b/bash/bash_4.3-6ubuntu1_i386.deb

I your home directory, extract it into a folder:

mkdir ~/bash_4.3-6ubuntu1_i386
dpkg -x bash_4.3-6ubuntu1_i386.deb ~/bash_4.3-6ubuntu1_i386

Copy the bash script into /bin/sh:

sudo mv /bin/sh /bin/sh64original
sudo cp ~/bash_4.3-6ubuntu1_i386/bin/bash /bin/sh
sudo chown root:root /bin/sh

Or run schroot, but still must copy /bin/bash to /bin/sh

Basile Starynkevitch mentioned above about setting up a 32-bit shell in an schroot environment. I did that with an Ubuntu 14.04 32-bit environment and ran into the same issue with the dash vs. bash "shared object" vs. "executable" (but when I copied /bin/bash to /bin/sh it worked), so that helped me realize that the distinction wasn't the 32-bit vs. 64-bit difference but the format of the shell executables that mattered to Wine.

If you would like I can post details for setting up the schroot evnironment but basically I followed the instructions at https://help.ubuntu.com/community/DebootstrapChroot but needed to configure the /etc/apt/sources.list to have the full list of packages (as are installed in my default host system) for apt-get install wine to work.