joliclic blog

Aller au contenu | Aller au menu | Aller à la recherche

Tag - dist_xul_app_en

Fil des billets - Fil des commentaires

samedi, mai 21 2011

Distribute your XULRunner app - 2.1 - Linux common

Ce billet existe aussi en français

This post is part of a series about how to package a XULRunner application.
See the preamble for the context case.

2.1 Linux common

2.1.1 Generalities

We target the platform Linux in this part. And this is the simplest case.

For all distributions that I have take a look at, XULRunner is available from the package manager, and Firefox is based on it. So XULRunner can easily be a dependency of your application.

2.1.2 Create a launcher

It's easy to create a launcher, simply create a shell script named myapp.sh, into your main application folder (those which contains application.ini) with the following content:

#!/bin/sh

CUR_DIR=$(dirname $(readlink -f "$0"))

if [ -x /usr/bin/xulrunner ]; then
/usr/bin/xulrunner "$CUR_DIR/application.ini" $@
elif [ -x /usr/bin/firefox ]; then
/usr/bin/firefox -app "$CUR_DIR/application.ini" $@
else
echo "Error: unable to find XULRunner or Firefox!"
fi

and make it executable:

chmod +x myapp.sh

The script retrieves in which folder is it from, then launches the application.ini file via xulrunner if found, firefox with the -app argument otherwise. The script passes eventual additional arguments too (like -jsconsole for example).

Later in this howto, when we'll create the deb and rpm packages, we will add a symbolic link to this file into /usr/bin/ .

Note: the readlink -f argument used in this script is available only in the GNU version, so in all Linux distributions, but not in some other unix like systems, like Mac OSX for example.

2.1.3 Icons for our windows

As is, the app is launched, but the icon displayed in the task bar is the XULRunner generic one, or the Firefox icon. It's easy to display our own icon. Simply create a folder named 'icons' inside the main chrome folder of the app, then create inside another one named 'default'. Copy 3 png files, named default16.png, default32.png, and default48.png. That's all, now this is your own icon that's displayed.

    |- samples_chapter_2/
|- myapp/
|- chrome
|- icons/
|- default/
|- default16.png
|- default32.png
|- default48.png

 2.1.4 Desktop integration

For a complete desktop integration, we now need to create some additional files,  a .desktop file, and some associated icons. This allows our app to appear in the applications menu of the windows manager.

As example, here's the content of a myapp.desktop file:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=MyApp
Comment=a Hello World XULRunner app
Comment[fr]=un Bonjour Monde pour XULRunner.
Exec=/usr/bin/myapp
Terminal=false
Type=Application
Categories=Utility;
Icon=myapp

See this documentation for detail, and this one to choose Categories.

The Exec entry is described in detail here, we use a symbolic link to our launcher, from /usr/bin/ (the standard for executable on Linux). Its real location will be in /usr/lib/myapp/.

The Icon entry content the name of our icons that we will create below.

The Comment entry is optional, and can be localized (like some others entries, see the spec), here there's a default value, and a french (fr) one.

If the app handles some mime types, i.e. can open some type of files, you must add a line with a MimeType entry, for example:

MimeType=text/html;text/xml;application/xhtml+xml;

This myapp.desktop file is intended to be placed in the final stage into the /usr/share/applications/ folder.
(See http://www.freedesktop.org/wiki/Specifications/menu-spec and http://www.freedesktop.org/wiki/Specifications/basedir-spec for more details)

Now we need some icons. We will use png and svg (xpm is possible too, but seems deprecated, I don't use it). We can have several sizes, personaly I have restricted to 4 png (16x16, 22x22, 32x32, 48x48), as suggested by the Tango Guidelines, plus a 48x48 svg.

These images must be named myapp.png, and myapp.svg .

And they should be finally placed into the following folders:

  • /usr/share/icons/hicolor/16x16/apps/myapp.png
  • /usr/share/icons/hicolor/22x22/apps/myapp.png
  • /usr/share/icons/hicolor/32x32/apps/myapp.png
  • /usr/share/icons/hicolor/48x48/apps/myapp.png
  • /usr/share/icons/hicolor/scalable/apps/myapp.svg

 2.1.5 Distribute a tar.gz

Our application is runnable as is with its launcher, so you can distribute it as a simple tar.gz. To create it:

tar -zcvf myapp.tar.gz myapp

A user can download it, unpack it anywhere, and launch it via myapp.sh.

But to be more friendly, a package usuable by the package manager of the distribution, with the complete desktop integration, is preferable. That's what we will see in the next sections.

Nicolas Martin

You can download all the samples of this chapter 2 (Linux) in the samples_chapter_2.tar.gz archive.

The myapp application, from developer.mozilla.org is in the Public Domain.

The icon used is from the Tango Desktop Project, and is in the Public Domain.

All added data, and sample files, of this chapter 2, are in the Public Domain too.

vendredi, mai 20 2011

Distribute your XULRunner app - 1 - Preamble

Ce billet existe aussi en français

This is the first post of a series about how to package a XULRunner application.

1 - Preamble

Purpose: you have made a nice XULRunner application, that you want to distribute as friendly for all platforms supported by XULRunner.

This is a small piece of code, you don't want to distribute XULRunner itself with your application (*).

I will share with you the result of some of my experiments and web researches, to package it and resolve some platform specificities.

We will see how to create a launcher, sometime based on Firefox with the -app argument (which can be used as a XULRunner runtime), and how to create common installers, deb and rpm for Linux, a nsis installer for Windows, an application bundle and a dmg for Mac OSX.

We will use the 'Hello World' application as example, from developer.mozilla.org. And all of this will be performed from Linux.

All comments and feedback will be really welcome ;) , if something seems wrong to you, please comment.

(*) Note: but if you embed XULRunner into your application, this information should be still useful ;) .

Here's the complete incoming plan:

Distribute your XULRunner app

  • 1 Preamble
  • 2 Linux
    • 2.1 Linux common
      • 2.1.1 Generalities
      • 2.1.2 Create a launcher
      • 2.1.3 Icons for our windows
      • 2.1.4 Desktop integration
      • 2.1.5 Distribute a tar.gz
    • 2.2 Package as deb
      • 2.2.1 Synopsis
      • 2.2.2 Debian files
      • 2.2.3 Create the deb
    • 2.3 Special case : deb for Maemo
      • 2.3.1 Maemo generalities
      • 2.3.2 Adapt the launcher
      • 2.3.3 A new file system organization - Where place our app
      • 2.3.4 Additions to the .desktop file
      • 2.3.5 Changes to the Debian files
      • 2.3.6 Create the deb
    • 2.4 Package as rpm
      • 2.4.1 Prerequisites
      • 2.4.2 RPM files
      • 2.4.3 Create the rpm
  • 3 Windows
    • 3.1 Icons for Windows
    • 3.2 Create a launcher (batch or C)
    • 3.3 Create a NSIS script
    • 3.4 Create the installer
  • 4 Mac OSX
    • 4.1 Icons for Mac OSX
    • 4.2 Create a launcher
    • 4.3 Some Mac specificities
    • 4.4 Create a Application Bundle
    • 4.5 Package as tar.gz and dmg
  • 5 Synthesis - all platforms
    • 5.1 Changes to the app
    • 5.2 Added data
    • 5.3 Created installers
    • 5.4 A global and reusable script
    • 5.5 Conclusions
  • 6 Annexe - related links

Nicolas Martin

page 2 de 2 -