2016-03-22 09:14:24 +01:00
# App packaging <img src="/images/yunohost_package.png" width=100/>
2013-11-27 13:08:12 +01:00
2016-11-07 23:58:27 +01:00
The purpose of this document is to teach you how to package an application for YunoHost.
2015-06-18 20:00:03 +02:00
### Requirements
To package an application, here are the requirements:
2016-02-25 13:15:31 +01:00
* An account on a git server (e.g. [GitHub ](https://github.com/ )) to publish the application;
2016-02-25 13:19:49 +01:00
* Basic knowledge of `git` , bash shell and other programming stuff;
2017-02-03 18:00:49 +01:00
* A testing [virtual machine or a distant server ](/install_en ), or a development environement, [ynh-dev ](https://github.com/yunohost/ynh-dev ) or [VirtualBox ](/packaging_apps_virtualbox_fr ), to package and test the package.
2013-11-27 13:08:12 +01:00
### Content
2014-11-04 09:39:30 +01:00
A YunoHost package is composed of:
2013-11-27 13:08:12 +01:00
2015-06-18 20:00:03 +02:00
* A `manifest.json` file
* A `scripts` directory, which contains five Shell scripts: `install` , `remove` , `upgrade` , `backup` and `restore`
* Optional directories, containing `sources` or `conf` files
* A `LICENSE` file containing the license of the package
* A presentation page of your package in a `README.md` file
2014-11-04 09:39:30 +01:00
2016-02-19 12:10:40 +01:00
< a class = "btn btn-lg btn-default" href = "https://github.com/YunoHost/example_ynh" > A basic package< / a >
feel free to use it as a framework.
2013-11-27 13:08:12 +01:00
2016-01-26 17:33:28 +01:00
## Manifest
< a class = "btn btn-lg btn-default" href = "packaging_apps_manifest_en" > Manifest< / a >
2013-11-27 13:08:12 +01:00
## Scripts
2016-02-19 12:28:09 +01:00
< a class = "btn btn-lg btn-default" href = "packaging_apps_scripts_en" > Scripts< / a >
2013-11-27 13:08:12 +01:00
2013-11-27 13:32:06 +01:00
### Architecture and arguments
2014-01-01 16:28:01 +01:00
Since YunoHost has a unified architecture, you will be able to guess most of the settings you need. But if you need variable ones, like the domain or web path, you will have to ask the administrator at installation (see `arguments` section in the manifest above).
2013-11-27 13:08:12 +01:00
2016-01-26 20:25:32 +01:00
< a class = "btn btn-lg btn-default" href = "packaging_apps_arguments_management_en" > Arguments management< / a >
2013-11-27 13:08:12 +01:00
2016-01-30 19:46:54 +01:00
### Nginx configuration
< a class = "btn btn-lg btn-default" href = "packaging_apps_nginx_conf_en" > Nginx configuration< / a >
2016-02-24 23:23:31 +01:00
### Multi-instance
< a class = "btn btn-lg btn-default" href = "packaging_apps_multiinstance_en" > Multi-instance< / a >
2013-12-12 18:11:03 +01:00
### Hooks
2018-06-04 19:57:05 +02:00
YunoHost provides a hook system, which is accessible via the packager's script callbacks in command line.
2014-01-01 16:28:01 +01:00
The scripts have to be placed in the `hooks` repository at the root of the YunoHost package, and must be named `priority-hook_name` , for example: `hooks/50-post_user_create` will be executed after each user creation.
2013-12-12 18:11:03 +01:00
2013-12-12 18:12:30 +01:00
**Note**: `priority` is optional, default is `50` .
2014-01-01 16:28:01 +01:00
Take a look at the [ownCloud package ](https://github.com/Kloadut/owncloud_ynh ) for a working example.
2013-12-12 18:11:03 +01:00
2013-11-27 13:32:06 +01:00
### Helpers
2016-02-24 21:40:21 +01:00
< a class = "btn btn-lg btn-default" href = "packaging_apps_helpers_en" > Helpers< / a >
2013-11-27 13:29:05 +01:00
2014-01-01 16:28:01 +01:00
### Test it!
In order to test your package, you can execute your script standalone as `admin` (do not forget to append required arguments):
2013-11-27 13:29:05 +01:00
```bash
su - admin -c "/bin/bash /path/to/my/script my_arg1 my_arg2"
```
2018-06-04 19:57:05 +02:00
Or you can use [command line ](/commandline_en ):
2013-11-27 13:29:05 +01:00
```bash
yunohost app install /path/to/my/app/package
```
Note that it also works with a Git URL:
```bash
yunohost app install https://github.com/author/my_app_package.git
```
2015-08-10 18:46:45 +02:00
2016-11-07 23:58:27 +01:00
### Packaging best practices
Here is a list of best practices for application install scripts:
2015-08-10 18:46:45 +02:00
* scripts should use `sudo cp -a ../sources/. $final_path` instead of `sudo cp -a ../sources/* $final_path` ;
2016-05-26 06:27:31 +02:00
* install script must contain support in case of script errors to delete residuals files thanks to `set -e` and [trap ](packaging_apps_trap_fr );
2016-11-07 23:58:27 +01:00
* install script should use the command-line method instead of calls to curl through web install form;
2015-08-10 18:46:45 +02:00
* install script should save install answers;
* application sources should be checked with a control sum (sha256, sha1 or md5) or a PGP signature;
2016-02-25 13:19:49 +01:00
* scripts should be tested on Debian Jessie as well as 32 bits, 64 bits and ARM architectures;
* backup and restore scripts should be present and functional.
2015-08-10 18:46:45 +02:00
2017-01-26 17:36:48 +01:00
To be define the quality of a package, it'll obtained a [level ](packaging_apps_levels_fr ), determined according to somes criteria of installation and according to respect to [package guidelines ](packaging_apps_guidelines_fr ).
2016-02-24 21:34:31 +01:00
### Package script checker
< a class = "btn btn-lg btn-default" href = "https://github.com/YunoHost/package_checker" > Package checker< / a >
2016-11-07 23:58:27 +01:00
This Python script checks:
2016-02-24 21:34:31 +01:00
* that the package is up to date wich last specifications
* that all files are present
2016-11-07 23:58:27 +01:00
* that the manifest doesn't have syntax errors
* that scripts exit well before modifing the system during verification.
2016-02-24 21:34:31 +01:00
2015-06-18 20:00:03 +02:00
### Publish and ask for testing your application
2016-11-07 23:58:27 +01:00
* Publishing a [post on the Forum ](https://forum.yunohost.org/ ) with the [`App integration` category ](https://forum.yunohost.org/c/app-integration ), to ask for testing and feedback on your application.
2015-06-18 20:00:03 +02:00
2017-09-05 22:38:25 +02:00
* Ask your application to be added to the [app repository ](https://github.com/YunoHost/apps ) to be displayed in the [non-official apps list ](apps_en ). Specify its progress state: `notworking` , `inprogress` , or `working` .
2016-03-09 16:17:29 +01:00
2016-11-07 23:58:27 +01:00
- Subscribe to the [Apps mailing list ](https://list.yunohost.org/cgi-bin/mailman/listinfo/apps ) to be informed about packaging evolution.
2014-11-09 13:16:25 +01:00
2015-06-18 20:00:03 +02:00
### Officalization of an application
2016-11-07 23:58:27 +01:00
To become an official application, it must be tested well enough, be stable and should work on 64 bits, 32 bits et ARM processor architectures, and on Debian Jessie. If you think those conditions are met, ask for [official integration ](https://github.com/YunoHost/apps ) of your application.