Forums

Rules to write script

I know, I'm annoying :-)

Auteur Réponses
Quentin PÂRIS Dimanche 28 Février 2010 à 12:12
Quentin PÂRISAnonymous

Hi everybody,

This post is not a compulsory list to follow, but some suggestions to make your scripts better.
I recommend you to follow these tips whenever possible.

1 - PlayOnLinux detection

Instead of:
if [ "$PLAYONLINUX" = "" ]then
exit 0
fi


You can use
 [ "$PLAYONLINUX" = "" ] && exit 0 

It's a bit clearer.

Use the following heading to recognize your script


#!/bin/bash
# Date: (2009-06-25 11-00)
# Last revision: (2009-10-17 20-00)
# Wine version used: 
# Distribution used to test: 
# Author: 
# Licence: 
# Depend: 

You can add all comments you like, if you think it could help the scriptors understand your script.

Post some screenshots on the forum


It will convince the scriptor that your script works.

"Freeze" your script


If your script works well, you can "freeze" it. That is to say, minimize the risk of change in the future by external factors. For instance, you can:
- Set a specific Wine version
- Set a version for your program
- Avoid using winetricks

Winetricks


If you can avoid using winetricks, all the better.
Here is a list of functions.
If one of these works for your script, use it instead of winetricks.
You can use both winetricks and these functions if you need to.
If a function doesn't work for you, or doesn't have the same behavior as winetricks, please report it to the scriptor.
You can't use these functions in a single line. For example, if you want to install msxml3 and riched20, use:
POL_Call POL_Install_msxml3
POL_Call POL_Install_riched20
If you have some free time, you can help us write functions.

Use a silent install if possible


If the user does not see a Wine window during the installation process, it's cleaner.
There are several possibilities to make a silent install, depending on the installation file.
Examples:
wine setup.exe /s
wine setup.exe /q
wine setup.exe /silent # Works for innosetup files, but shows the progress bar
wine setup.exe /quiet
wine setup.exe /verysilent # The best for innosetup files 


If these lines don't work, try capital letters.

For zip self-extracting files, you can try
unzip your_file.exe

You can also try, but it doesn't seem to respect directories (could be good for some libraries):
cabextract your_file.exe

For a .msi file:
wine msiexec /i setup.msi /q

Recopy the licence file


If you use a silent install, the licence file is no longer visible. The developer of the software would appreciate to see the licence. Example:

POL_SetupWindow_licence "Please read this carefully" "Licence" "$REPERTOIRE/tmp/ie_license.txt"

When you need to make a file


Please don't use the following code:
echo "Line 1" > your_file.txt
echo "Line 2" >> your_file.txt
echo "Line 3" >> your_file.txt 

Use:
cat << _EOF_ > your_file.txt
Line 1
Line 2
Line 3
_EOF_

If you need to make several files, change _EOF_ string for the second.

About multiple versions


Two possibilities:
1 - Your program has a lot of different minor versions (case of Notepad++)
In that case, we will not make a script for each version, it would be nonsensical. Few possibilities:
- Ask the user what version they want to download and install.
- Try to detect automatically the latest version (it's the best solution if it works well, but be careful, if you get the name of the latest version from the official website of the program, don't forget that the website can change in the future, and it could cause bugs).
- Make a variable that contains the name of the latest version. This way it will be very easy to change it in the future (a good solution, that avoids a lot of bugs, in my opinion).
- If you think a version works or will work better than the others, you can keep it (cf. "Freeze your script" section).

2 - Your software has different branches of development, for different major versions
That is the case of Windows Media Player, Internet Explorer, Firefox, etc.
- Please make a different script for each version. Do not put all the versions in a single script. The user will be able to find easily the right version by using the search bar.

About the patches and the extensions


I strongly recommend you to make a different script for the patch, to avoid the same problem: we want your script to be findable in the search bar. In the future version of PlayOnLinux, maybe we could separate them from the other games.

Translation


Please write your script in English first, additional translations are very appreciated.

Testing your script


Don't hesitate to use "Magic Numbers". Before sending your script to validation, you can type in PlayOnLinux's search bar: get:magic_number to run your script.
For example, get:269 will let you test the Inno Setup script, even if it's not validated.

About the vote


Don't give five stars to your script right after validation, it's not very fair-play.

About v2 functions


Do not use them (message, question, attendre, creer_prefixe, etc...).

About free software


Examples of Windows Live Messenger 2008, iTunes 7 scripts
You can mention that free software is available, and mention its name. You can inform the user that the application might not work as it works on Windows, and it could be a better solution to install a free program.

About No-CD patches


Some games need a No-CD patch to work with Wine. In some countries, it's not illegal to crack protection if it is obligatory to run the software on a different operating system.
In that case, please tell the user that they need to patch the game at their own risk, and that PlayOnLinux will not do it for them, nor take any responsibility for it.

About Program Files variable


Please use the following code:
PROGRAMFILES="Program Files" 
POL_LoadVar_PROGRAMFILES
It should work with the latest PlayOnLinux version.

Thank your for reading this, if I have something else to add, I will reply to this post.

Edité par Salvatos

lil_stenly Dimanche 28 Février 2010 à 13:40
lil_stenly

Silent installation for MSI:

wine msiexec /i setup.msi /q
Quentin PÂRIS Dimanche 28 Février 2010 à 14:47
Quentin PÂRISAnonymous

Thank's
Dr Phil Dimanche 28 Février 2010 à 21:26
Dr Phil

Great Tinou! =)
I think scripts will be much cleaner in the future. =)

BTW: The link in the winetricks-section is wrong.
http://www.playonmac.com/repository/admin.php?cat=100 should be changed to:
http://www.playonmac.com/repository/?cat=100
Berillions Lundi 1 Mars 2010 à 19:36
Berillions

Also, if you need more than 1 CD or DVD to install your game and Wine doesn't want to eject your CD/DVD when the installation asks for the 2nd/3rd... CD/DVD, you can use this function to solve the problem:

Instead of:
wine "$CDROM/setup.exe"

Use this:
wine start /unix "$CDROM/setup.exe"

Tested with Mass Effect and Mass Effect 2.

Enjoy :D

Edité par Salvatos


This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca-notice@playonlinux.com