The forum

Regarding scripts

A few guidelines

Author Replies
Salvatos Monday 4 April 2011 at 22:10
SalvatosAnonymous

Hi,

More and more people are contributing scripts, and we're really thankful for your help!
During validation, we keep seeing some issues that creep up and annoy us a little. To ease the validation process, I decided to write this post to explain what you should avoid in your scripts.

Some of these rules are necessary for the script to function properly and are therefore mandatory. Others are recommendations. If I don't mention it, your script won't be turned down at validation even if that rule isn't followed.

Some scripts that are already validated don't obey these rules. They are being revised, but this takes some time, so we can't fix it all at once.

1 - Do not use sudo! (Mandatory)


Do not
For obvious safety concerns, you must not use the commands sudo, gksudo, kdesu, ...

Instead
If you really need sudo in your script, you'll have to ask the user to type it in. To do so, you can use the following code:
POL_Call POL_Function_RootCommand "Command root ; exit"

2 - Use the $TITLE variable (recommended)


Do not
Choose a different title for every window. This will confuse the user.
POL_SetupWindow_message "Your message" "Random title"

Instead
The $TITLE variable is defined automatically, and it contains your script's name.
POL_SetupWindow_message "Your message" "$TITLE"


3 - Shorten headers (recommended)


Do not
Almost no one uses this anymore, but as a reminder,
if [ "$PLAYONLINUX" = "" ]then
exit 0
fi


Instead
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

4 - Argument order (Mandatory)


For your script to be Mac/BSD compatible, you need to follow argument order in certain commands.
Never
rm directory -rf
mkdir directory -p
cp directory -r

Instead
rm -rf directory
mkdir -p directory
cp -r directory

5 - Do not use wget to downlaod an external script (Mandatory)


Never
wget http://winezeug.googlecode.com/svn/trunk/winetricks --output-document=winetricks
bash winetricks -q some_packages

Instead
POL_Winetricks some_packages
or (recommended)
POL_Call POL_Install_package

6 - Do not use echo multiple times to write into a file (Mandatory)


Do not
echo "line 1" > my_file
echo "line 2" >> my file
...

Instead
cat << EOF > my_file
line 1
line 2
...
EOF

7 - Script header (recommended)


Use
#!/bin/bash
# Date : (2009-05-30 17-30)
# Last revision : (2009-05-30 17-30)
# Wine version used : 
# Distribution used to test :
# Author : Your name
# Script licence : 
# Program licence :
# Depend :

8 - Use exit at the end of your script (Mandatory)


The GPG signature is inserted at the end of your script. If you don't add exit, your script cannot be signed without bash trying to interpret the signature.
Use
POL_SetupWindow_Close
exit

9 - Regarding Wine versions


You can bind your program to a Wine version it works well with if it is complex enough (all games apply). However, we advise against using this method for small applications like mp3tag.

10 - Do not download images from Wikipedia and resize them with convert (Mandatory)


Never
wget http://www.google.com/images/logos/sketchup_logo.png --output-document="$REPERTOIRE/tmp/leftnotrotated.png"
convert "$REPERTOIRE/tmp/leftnotrotated.png" -rotate 270 "$REPERTOIRE/tmp/leftnotscaled.png"
convert "$REPERTOIRE/tmp/leftnotscaled.png" -scale 150x356\\! "$REPERTOIRE/tmp/left.png"
POL_SetupWindow_Init "" "$REPERTOIRE/tmp/left.png"

11 - Watch out for what you do after cd! (Mandatory)


Do not
cd $WINEPREFIX/windows/tmp
rm ./*
# If cd fails, you don't know what will be deleted.

Instead
- Generally speaking, avoid using rm, but otherwise:
rm $WINEPREFIX/windows/tmp/*

12 - PlayOnLinux v2 functions are forbidden (Mandatory)



13 - Use $REPERTOIRE (Mandatory)


Do not
$HOME/.PlayOnLinux

Instead
$REPERTOIRE

14 - Use POL_SetupWindow_wait_next_signal before large commands (unzip, tar, wine, ...)


- Otherwise, the GUI freezes and the user may think it's a bug.

15 - Do not use cfg_check, it is useless



16 - Warn the user if the game requires a CD/DVD protection bypass, without encouraging them to do it! (that's a tricky one) (strongly recommended)


- Advocating piracy is forbidden

17 - Do not include the patch in the script, unless it is required for it to work (recommended, even mandatory in some cases)


- Create a separate script

18 - Do not install libraries directly in a script, use POL_Call (same as 17)



From here on, those are suggestions you can follow if you feel like it


19 - Use POL_Debug functions


- There is no documentation for now, so you can look at how the League of Legends script (Testing category) works for now if you really want to.

20 - Avoid weird stuff if you can...


- If we're having trouble following what's going on in your script, it will be rejected. You should therefore avoid awk and sed lines that go on forever (and could fail on a different system such as Mac).

21 - Use POL_SetupWindow_auto_shortcut, instead of POL_SetupWindow_make_shortcut



22 - No need to use POL_LoadVar_PROGRAMFILES



23 - Comment your script



24 - Enter a description, and send in the icons, miniatures...


- The Description box allows you to enter a description of the software (not of the script itself). BBCode is allowed
- The install icon is 22x22
- The game icon is 32x32 or more
- The miniature is 200x150

25 - Provide the script at least in English and/or French


- It's always best to get an English version for the international crowds

26 - Regarding signatures


- Even if you don't want your script to be available to all PlayOnLinux users, you can ask us for a signature so that PlayOnLinux doesn't complain when you launch it. (If you want to deploy a custom program on a large number of computers.)

27 - Generally speaking, small programs work on Mac. So if your script is built well, you can tick the PlayOnMac box


- Be careful with games.

28 - Avoid detecting the application's latest version...


... unless there is a file specifically made for this on the official site.
See note 20.


Translated for Tinou

Edited by Salvatos


Disclaimer: I'm a noob, not a dev; my advice is only a guess.
Attention : Je suis aussi noob que vous, prenez mes suggestions avec un grain de sel ;)
jjmacey Wednesday 4 April 2012 at 13:54
jjmacey

Hi,

Firstly, I would like to thank the contributors that made playonlinux possible. And, secondly my apologies if this is not the right place to post my question.

I have been using Linux for about 10 years and have converted many people over to various Linux distros. The one app that they all want is Microsoft Word 2007, which I easily add by using playonlinux. However, some people have additional requirements.

A good buddy of mine is an architect and on Monday I had a sort of install fest at his place. I installed openSuSE 12.1 with the KDE 4.0 desktop manager, all the apps he would need including Microsoft Word 2007, and the rest of all those open source goodies.

His one additional basic requirement was to install Autocad 2002, which I did sucessfully. How I did it is still a mystery because I was installing so many apps, trouble shooting, testing, etc., etc. He has been running Autocad since Monday and it works well, no crashes, bugs or the usual problems.

Now, to my question. I have used scripts in the past to aid in doing things, but never written one to help others along. I would like to make a contribution here, and am wondering if writing a script is the way to do this properly.

Any responses would be appreciated, and again please excuse the Noob question. LOL!


Regards,

JJMacey
Tempe, Arizona
Salvatos Friday 4 May 2012 at 4:39
SalvatosAnonymous

To be honest I find it daunting myself and it's a process I've never approached, but this might help: http://www.playonmac.com/en/documentation.html

I think easier ways to contribute scripts are in the works, perhaps we'll see them released in the summer. At any rate thanks for trying!

Disclaimer: I'm a noob, not a dev; my advice is only a guess.
Attention : Je suis aussi noob que vous, prenez mes suggestions avec un grain de sel ;)
KoRnKloWn Wednesday 30 May 2012 at 3:45
KoRnKloWn

I submitted a script to install the first Command and Conquer, it's patched but it only works with the patch, plus the game was released as freeware quite some time ago. Anyways, the script works great, gets the game running perfect, but I can't figure out how to submit the icons and screen shots? Could someone inform me how that is done? I don't even want to get it signed until I can link the shortcut to the correct icon.
horsemanoffaith Thursday 10 January 2013 at 8:31
horsemanoffaithAnonymous

Hi, I would like to submit a script, but it is fairly long because it requires quite a bit of file transferring. It does not fit in your script window, and I do not believe I can make it any shorter... Anything I can do to submit the script?
Quentin PÂRIS Thursday 10 January 2013 at 10:02
Quentin PÂRISAnonymous

Why is it so long ?
Deleted Please make a separate topic for your script
horsemanoffaith Friday 18 January 2013 at 2:15
horsemanoffaithAnonymous

You asked me to create a separate topic, could you take a look at it? It's posted here: http://www.playonmac.com/en/topic-9937-Nox_Retail_CD_script.html

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