Orangevolt ANT Tasks » Tasks
TasksExample

2.1.  sfx

sfx creates self extracting executables for various platforms.

sfx takes an archive and makes it executable for a variete of platforms. The started executable extracts to contents of the archive to a platform depended temp directory [temp-dir]/[executable] and executes an command int the extracted path.

sfx is very handy to create setup's. Zip the required resources of your application and make start script available for each platform. That's all you need.

Version 1.2 introduced new customization features for dynamic commandline parameters. Both enviroment and registry (for win32* modes only :-) expressions can be used in the execute and workingDirectoryparameter (See chapter Dynamic commandline(s) for details).

Version 1.2 also includes the often requested custom icon feature (for win32* and java modeonly). The icon parameter lets you define a custom icon (provided as gif file) which is patched into the executable as its default icon.

Attributes

Name Description Required
archive the zip/jar archive to use yes
mode 5 types of self executables can be created by sfx
  • win32

    Creates a win32 executable (exe file) which is executed without opening a shell window. Use this mode for silent extraction.

  • win32-console

    Creates a win32 executable (exe file) which is executed by opening a shell window. All output goes to the console.

  • unix

    Creates an executable shell script (sh file) which is executed

    1. silent when opened outside a shell
    2. with output when opened in a shell

  • java

    Creates a executable java jar file which opens a status window with extraction progress bar.

  • java-console

    Creates a executable java jar file which opens a console shell window. All output goes to the console.

yes
icon

The icon parameter defines an executable icon. The icon is used in mode win32, win32-console, java and java-console.

The icon can be provided in any format readable from Java (gif, jpg, png and so on).

The icon SHOULD be provided in 256 color depth. Otherwise the displayed icon may shown incorrect. It is also a good advise to provide the icon with 32x32 pixels. Otherwise it is reduced to 32x32 which may sometimes look ugly.

For windows executables the icon is also patched into the executable binary.

no
execute

The command to execute after successful extraction.

The command is executed

  1. in the temp directory where the files were extracted when no workingDir was defined.
  2. in the workingDir inside the temp directory if workingDir was defined.

In case of executables created for windows the execute will be executed with "command /B" (for Windows 95/98) or "cmd /B" (Windows NT/2000/XP).

The execute parameter may contain Dynamic commandline(s) which are evaluated at runtime.

Version 1.2: execute can also be defined using a child element <execute>.

yes
output The name of the output file (setup.exe or setup.sh for example). yes
workingDirectory

The working directory were the command defined in execute should be executed.

If not defined the command will be executed with the extraction path as working directory.

The path separator used in workingDir can always be a slash (/). It is transformed to the platform dependend path separator by sfx.

The workingDirectory parameter may contain Dynamic commandline(s) which are evaluated at runtime.

Version 1.2: workingDirectory can also be defined using a child element <workingDirectory>.

no

How does it work ?

For win32 and unix modes the zip file will be appended to a native stub (an exe for win32, shell script for unix).

At execution time the executable unzips itself ! In general the magic behind extraction is the ZLib library. The ZLib library library tries not to read the zip stream at start of file instead the library seeks forward until the zip header signature is found. Is'nt it easy and elegant ?