Scripting - Chapter 7: Installation Media

From PlayOnLinux
Jump to: navigation, search

In this chapter we will see how to install some software from a CD/DVD, or how to download it if it is available from the Internet.

CD/DVD media

PlayOnLinux allows to easily install a software from a CD/DVD.

Ask the user to select his/her CD/DVD

Syntax:

POL_SetupWindow_cdrom

Example:

POL_SetupWindow_cdrom

ch07-01.en.png

The path to the CD/DVD will be stored in the variable $CDROM (for example, $CDROM value could be: /media/cdrom0).

Check if the CD/DVD is the expected one (after having used POL_SetupWindow_cdrom)

Syntax:

POL_SetupWindow_check_cdrom "path/to/some/file/on/the/CD"

Example:

POL_SetupWindow_check_cdrom "Data/media1.dat"

Check if this file exists, otherwise run POL_SetupWindow_cdrom again. Try to choose some file specific to the expected CD, not Setup.exe, autorun.inf, and the like.

Download a program from the Internet

With PlayOnLinux you can easily download files from the Internet. This is specially useful for software that is available for free from the 'net.

Download a file

Syntax:

POL_Download "URL" "MD5 digest of the file"

MD5 digest? What is that?

The MD5 digest is some code that looks like b1bbd74395a34ff7fd069d3b6fe23016, that's unique for each file. It's used to make sure that the downloaded file is not corrupted (as it sometimes happens, because of download errors). To compute the MD5 digest of a file, use the following command in a console/terminal:

md5sum "/path/to/some/setup.exe"

The file downloaded will be written in the current working directory (as selected with the cd command). Most of the time, the right place for downloaded files is the temporary directory, created by the command POL_System_TmpCreate. To put files in the temporary directory, use the following command right before POL_Download:

cd "$POL_System_TmpDir"

Example:

cd "$POL_System_TmpDir"
POL_Download "http://www.example.com/download/setup.exe" "b1bbd74395a34ff7fd069d3b6fe23016"

The file will be named after the name of the file on the server, so if the URL looks like, say: http://www.example.com/download/setup.exe, the downloaded file will be called setup.exe.

Select installation method

How do I ask the user what installation method they wants to use? Poof! Here comes the function POL_SetupWindow_InstallMethod. This function will ask the user what type of media they want to use to install a program.

Function POL_SetupWindow_InstallMethod

Syntax:

POL_SetupWindow_InstallMethod "Installation methods"

Options

Many different installation methods exist, but let's start with the 4 most simple ones (and the most common):

  • LOCAL: The user will select a file from his computer.
  • DOWNLOAD: Download the installation file from the Internet.
  • CD: Install the program from a CD.
  • DVD: Install the program from a DVD.

The methods available to the user should be separated with commas. The method selected by the user will be returned in the variable $INSTALL_METHOD. You can then use a combination of if, then, elif, and fi (Bash conditional statements) to determine what method has been chosen, and act accordingly. Details will be given in the next chapter.

Example:

POL_SetupWindow_InstallMethod "LOCAL,DOWNLOAD"

ch07-02.en.png

Creating a launcher in PlayOnLinux

Creating a launcher (or shortcut) in PlayOnLinux is extremely easy, look:

Syntax:

POL_Shortcut "Executable.exe" "Name of the launcher"

Example:

POL_Shortcut "JediKnightII.exe" "Star Wars: Jedi Knight II"

You should not specify the whole path to the executable, PlayOnLinux will find it automatically.


Previous: Chapter 6: The Filesystem

Next: Chapter 8: My First Real Script