brezerk / q4wine

Q4Wine is a Qt GUI for W.I.N.E. It will help you manage wine prefixes and installed applications.
http://q4wine.brezblock.org.ua/
GNU General Public License v3.0
208 stars 40 forks source link

using pre run scripts #49

Closed nerijus closed 9 years ago

nerijus commented 9 years ago

I tried to add in Scripts->Pre run: /usr/bin/fuseiso /path/to/image.iso /mnt/cdrom but the image is not mounted. Although it is mounted when I execute this command in a terminal. Then I created a text file with the above command, pasted the command and made the file executable. If I add path to the script to Scripts->Pre run, it works. Could it be possible to make such mount command runnable without putting it into script?

brezerk commented 9 years ago

well. In general, setting Pre run to "/usr/bin/fuseiso /path/to/image.iso /mnt/cdrom" should work.

    run_string.append(" /bin/sh -c \"");
    run_string.append(script_path);
    run_string.append("\" 2>&1");

So it will be converted to string like:

/bin/sh -c "/usr/bin/fuseiso /path/to/image.iso /mnt/cdrom"

Note, that if you are using quotes inside 'Pre run', it will break the logic.

Anyway I will need more details: Try to enable q4wine's logging subsystem, you should get the error message if 'Pre run' fails.

nerijus commented 9 years ago

From the log: App STDOUT and STDERR output: /bin/sh: /usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom: Toks failas ar aplankas neegzistuoja

it means file or directory does not exist.

brezerk commented 9 years ago

hm. ok. can you show me full run string please? (should be displayed in log as well)

nerijus commented 9 years ago

All output with LANG=C: Exit code: 32512 App STDOUT and STDERR output: /bin/sh: /usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom: No such file or directory

But, when I run /usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom or /bin/sh -c "/usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom" from the terminal, it works.

nerijus commented 9 years ago

I modified the source to output run_string too:

--- wineobject.cpp.orig 2013-12-16 23:02:55.000000000 +0200
+++ wineobject.cpp  2014-12-25 13:39:12.045774874 +0200
@@ -390,6 +390,10 @@
             stdout.append("\n");
             stdout.append(QString("%1").arg(status));
             stdout.append("\n");
+            stdout.append("Run string:");
+            stdout.append("\n");
+            stdout.append(run_string);
+            stdout.append("\n");
             stdout.append("App STDOUT and STDERR output:");
             stdout.append("\n");
             stdout.append(app_stdout);

The log output is: Exit code: 32512 Run string: env WINEPREFIX='/home/user/.wine' WINESERVER='/usr/bin/wineserver' WINELOADER='/usr/bin/wine' WINEDLLPATH='' /bin/sh -c "'/usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom'" 2>&1 App STDOUT and STDERR output: /bin/sh: /usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom: No such file or directory

nerijus commented 9 years ago

The version is from Fedora 21 - q4wine-1.1-5.r2.fc21.i686

brezerk commented 9 years ago

yep. I see.

 /bin/sh -c "'/usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom'"
/bin/sh: /usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom: No such file or directory
 /bin/sh -c "/usr/bin/fuseiso /mnt/d/Games/DidzLenkt.iso /mnt/cdrom"
Can`t open image file: No such file or directory
brezerk commented 9 years ago

So the problem that there are double quotes... Let me take a look on source code.

brezerk commented 9 years ago

Yeah. It seems to be safe to remove \" quotes in 378-380 lines:

    run_string.append(" /bin/sh -c ");
    run_string.append(script_path);
    run_string.append(" 2>&1");

Fixed in trunk: https://github.com/brezerk/q4wine/commit/e3c6e5e4b01f522caf232e79856aece64b85c848

Try the solution. Reopen ticket if needed. Thanks for the bug report.

nerijus commented 9 years ago

Something is still wrong. With the above patch I do not get Run string output anymore (which I added) and the log is:

Exec string:
/usr/bin/env  WINEPREFIX='/home/user/.wine'  WINESERVER='/usr/bin/wineserver'  WINELOADER='/usr/bin/wine'  WINEDLLPATH=''  /bin/sh -c "cd '/mnt/ntfs/Program Files/Snowball Interactive/BigRace(Lithuanian)/' &&   '/usr/bin/wine'   'BG_Start.exe'  2>&1 "
Exit code:
10
App STDOUT and STDERR output:
Can't load version information. Check prefix and/or version settings.

But the iso file is mounted.

Then I clear the pre run script in the app options, and try to launch it again. The log:

Exit code:
512
Run string:
 env  WINEPREFIX='/home/user/.wine'  WINESERVER='/usr/bin/wineserver'  WINELOADER='/usr/bin/wine'  WINEDLLPATH=''  /bin/sh -c  2>&1
App STDOUT and STDERR output:
/bin/sh: -c: option requires an argument
brezerk commented 9 years ago

The last message is a message from post mount script. It is fixed in the same commit above: https://github.com/brezerk/q4wine/commit/e3c6e5e4b01f522caf232e79856aece64b85c848 Please, try to build git head sources.

nerijus commented 9 years ago

I'll try, but I see a bug in the following logic:

+ if (pre_run){
+ stdout.append("Prerun Exec string:");
+ } else {
+ stdout.append("Postrun Exec string:");
+ }
+ stdout.append("\n");
+ stdout.append(run_string);
+ stdout.append("\n");

What if both prerun and postrun exist? What if both are empty?

brezerk commented 9 years ago

nope. pre and post run calsl this function separately. if pre/post run is empty, then this function will be not called at all.

nerijus commented 9 years ago

With empty prerun:

Exec string:
/usr/bin/env  WINEPREFIX='/home/user/.wine'  WINESERVER='/usr/bin/wineserver'  WINELOADER='/usr/bin/wine'  WINEDLLPATH=''  /bin/sh -c "cd '/mnt/ntfs/Program Files/Snowball Interactive/BigRace(Lithuanian)/' &&   '/usr/bin/wine'   'BG_Start.exe'  2>&1 "
Exit code:
10
App STDOUT and STDERR output:
Can't load version information. Check prefix and/or version settings.

It is on another PC than the bug was reported with, so it may be some other problem. I can run wine from command line.

nerijus commented 9 years ago

If I delete /home/user/.config/q4wine, the first time wizard launches (btw, it is called First startup wizRAd, should be wizARd), in Step 3 the first 3 paths are filled, but wine libs (32 bit) and wine libs (64 bit) are empty. I fill 32 bit as /usr/lib/wine, leave 64 bit empty (my system is 32 bit), but after the wizard finishes it reports:

Error while loading application settings. wine's library path for 32 and 64 bit is not set. Please, go to the q4wine options dialog and set at least one path.

In the Options->General all the paths are empty.

brezerk commented 9 years ago

hm. yeah, your configuration seems to miss WINEDLLPATH=''.

please open another issue, and add some info: wine version + a list of wine pgk's owned files on your system. thanks.

nerijus commented 9 years ago

With a new source it seems OK now.

nerijus commented 9 years ago

One more problem. If I put path with spaces and () in a pre run script: /usr/bin/fuseiso /mnt/ntfs/Program Files/Snowball Interactive/BigRace(Lithuanian)/DidzLenkt.iso /mnt/cdrom I get in the log:

Prerun Exec string:
 env  WINEPREFIX='/home/user/.wine'  WINESERVER='/usr/bin/wineserver'  WINELOADER='/usr/bin/wine'  WINEDLLPATH='/usr/lib/wine'  /bin/sh -c '/usr/bin/fuseiso /mnt/ntfs/Program Files/Snowball Interactive/BigRace(Lithuanian)/DidzLenkt.iso /mnt/cdrom' 2>&1
Exit code:
256
App STDOUT and STDERR output:
/bin/sh: -c: eilutė 0: sintaksės klaida prie netikėtos leksemos: „(“
/bin/sh: -c: eilutė 0: `/usr/bin/fuseiso /mnt/ntfs/Program Files/Snowball Interactive/BigRace(Lithuanian)/DidzLenkt.iso /mnt/cdrom'

sintaksės klaida means syntax error. If the iso file path is without spaces and (), it works.

brezerk commented 9 years ago

there is nothing I can do with this :)

try to escape spaces and braces with \ i.e.:

 /mnt/ntfs/Program\ Files/Snowball\ Interactive/BigRace\(Lithuanian\)/DidzLenkt.iso

or add quotes

/usr/bin/fuseiso "/mnt/ntfs/Program Files/Snowball Interactive/BigRace(Lithuanian)/DidzLenkt.iso" /mnt/cdrom
nerijus commented 9 years ago

Quotes are OK, sorry forgot to try them. Thank you very much for fixing this bug.

brezerk commented 9 years ago

Ur'welcome. Thanks for the reports and your help :)