Marking files for execution

<executable> - mark file as executable and optionally execute it

The <executable> tag is a very useful thing if you need to execute something during the installation process. It can also be used to set the executable flag on Unix-like systems.

Files must be first added to the pack using <singlefile><file> or <fileset> before they can be marked executable.

The permission changes (Unix) and/or execution happens before afterpack listeners are executed.

Attributes

Attribute

Description

Required

Values 
(Default)

targetfile

Relative or absolute target path of a pack file added before, which should reeceive executable permissions or which should be executed.

May contain IzPack variables resolved during installation.

Example: $INSTALL_PATH/bin/launch-script.sh

no
(required, if no nested fileset is used) 

File path

type

bin or jar (the default is bin)

no

"bin" | "jar" 
("bin")

class

If the executable is a jar file, this is the class to run for a Java program

no

A valid Java class within the jar file

stage

Specifies at which stage when to launch the executable:

  • never 
    will never launch it (useful to set the +x flag on Unix)
  • postinstall 
    just after the installation of the given pack is done (not whole of the installation - IZPACK-1291).
  • uninstall 
    when the application is uninstalled. The executable is executed before any files are deleted.

no

"never" | "postinstall" | "uninstall" 
("never")

failure

specifies what to do when an error occurs:

  • ask (default) will ask the user what to do
  • abort will abort the installation process
  • warn will just tell the user that something is wrong
  • ignore don't tell the user, just continue

no

"ask" | "abort" | "warn" | "ignore" 
("ask")

keep

Whether the file will be kept after execution

no

"true" | "false" 
("false")

os

Limits this action on a particular OS family, works like for <file>

no

No recommended to use any longer, use the nested <os> tag, instead.

condition

ID of a condition which has to be fulfilled to execute this file

no

A valid condition ID

Nested Elements

  • <os> - restrict parsing depending on the target operating system, see the OS Restriction element
  • <args>
    Pass one or more arguments with nested <arg> tags  (one <arg> tag per argument) to the executable
    Attributes: value - the argument value
    Example:
    <args><arg value="-version"/></args>

<pack name="core" required="yes">
...
	<file targetdir="$INSTALL_PATH" src="projectNotification.bat" />
	<executable targetfile="$INSTALL_PATH/projectNotification.bat" type="bin" stage="postinstall" failure ="warn" keep="true" >
		<os family="windows" />
		<args>
			<arg value="-version"/>
		</args>
	</executable>
...
</pack>

Slashes get special handling (see attribute targetfile of tag <parsable>.)

If you need to preserve a slash in front of an argument you will need to quote the slash.

<os family="windows" />
<args>
  <arg value="\/arg"/>
</args>

Executing Multiple Files

One or more <fileset> tags can be used to specify multiple files executable at once. The <fileset> which can be used here does not have all of the attributes and nested tags of a Pack FileSet. Only the attributes targetdir, includes and excludes and the children <include> and <exclude> are allowed. The children <include> and <exclude> only can have the attribute name.

There can be filesets defined here without any attribute, but just one or more includes (targetDir defaults to "${INSTALL_PATH}" in that case).

The order of execution is not defined when multiple files are specified in the include.

If you want the the files executed in a certain order, use multiple <execute> sections.
There is no access to the filesystem for a <parsable> fileset, but just to files that are packed into the installer at compile time.

See the example below.

<pack name="core" required="yes">
...
	<file targetdir="$INSTALL_PATH" src="projectExtractor.bat" >
	<file targetdir="$INSTALL_PATH" src="projectInstaller.bat" >
	<executable type="bin" stage="postinstall" failure ="warn" keep="true">
		<os family="windows" />
		<fileset targetdir="$INSTALL_PATH" includes="fileCleaner.bat,projectNotification.bat" />
	</executable>
...
<pack>

Note that there is no guarantee that fileCleaner.bat will run before projectNotification.bat.