2020-11-11 11:47:10 +01:00
---
title: App packaging
template: docs
taxonomy:
category: docs
2021-02-06 18:22:00 +01:00
routes:
default: '/packaging_apps'
2020-11-11 11:47:10 +01:00
---
2021-02-06 22:41:01 +01:00
![](image://yunohost_package.png?resize=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:
2020-10-01 13:31:16 +02:00
* An account on a Git server (e.g. [GitHub ](https://github.com/ )) to publish the application;
* Basic knowledge of [Git ](/packaging_apps_git ), bash shell and other programming stuff;
2020-12-28 09:39:51 +01:00
* A testing [virtual machine or a distant server ](/install ) or [VirtualBox ](/packaging_apps_virtualbox ), to package and test the package. Alternatively you can also use [ynh-dev ](https://github.com/yunohost/ynh-dev ), it is meant for the core but can totally be used for developping apps, but be aware that for now the documentation on this part is lacking.
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
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [ A basic package ](https://github.com/YunoHost/example_ynh ) [/div]
2016-02-19 12:10:40 +01:00
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
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [Manifest ](/packaging_apps_manifest ) [/div]
2013-11-27 13:08:12 +01:00
## Scripts
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [Scripts ](/packaging_apps_scripts ) [/div]
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
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [Arguments management ](/packaging_apps_arguments_management ) [/div]
2013-11-27 13:08:12 +01:00
2020-09-15 13:57:31 +02:00
### NGINX configuration
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [NGINX configuration ](/packaging_apps_nginx_conf ) [/div]
2016-01-30 19:46:54 +01:00
2016-02-24 23:23:31 +01:00
### Multi-instance
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [Multi-instance ](/packaging_apps_multiinstance ) [/div]
2016-02-24 23:23:31 +01:00
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` .
2019-01-14 15:10:36 +01:00
Take a look at the [Nextcloud package ](https://github.com/YunoHost-Apps/nextcloud_ynh/ ) for a working example.
2013-12-12 18:11:03 +01:00
2013-11-27 13:32:06 +01:00
### Helpers
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [Helpers ](/packaging_apps_helpers ) [/div]
2013-11-27 13:29:05 +01:00
2018-08-26 17:47:18 +02:00
### Registering a log file
2018-06-05 17:40:31 +02:00
2018-08-26 17:47:18 +02:00
In a lot of case, you might want to register a log file created by your app, to make it available in the webadmin. To register a log, you can create a reference file `/var/log/yunohost/categories/app/APPNAME.yml` .
2018-06-05 17:40:31 +02:00
2018-08-26 17:47:18 +02:00
You can specify a start date by starting the file name with the date formatted as `YYYYMMDD-HHMMSS` .
Example of yml metadata log file:
```bash
2018-06-05 17:40:31 +02:00
log_path: /path/to/your/log/file.log
```
2018-08-26 17:47:18 +02:00
If you want display some context info, you can add:
```bash
2018-06-05 17:40:31 +02:00
extra:
env:
args1: value1
args2: value2
args3: value3
```
2018-08-26 17:47:18 +02:00
You can attach the log to an app, domain, service or user like this :
```bash
2018-06-05 17:40:31 +02:00
related_to:
- ['app', 'APPNAME']
- ['service', 'SERVICE1']
- ['service', 'SERVICE2']
- ['domain', 'DOMAIN.TLD']
```
2018-08-26 17:47:18 +02:00
This will be used to filter logs and display all log related to an entity like a user, a domain, an app or a service.
2018-06-05 17:40:31 +02: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"
```
2020-03-28 06:54:10 +01:00
Or you can use [command line ](/commandline ):
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` ;
2020-03-28 06:54:10 +01:00
* install script must contain support in case of script errors to delete residuals files thanks to `set -e` and [trap ](/packaging_apps_trap );
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;
2020-07-27 18:55:33 +02:00
* scripts should be tested on Debian Buster 32 bits, 64 bits and ARM architectures;
2016-02-25 13:19:49 +01:00
* backup and restore scripts should be present and functional.
2015-08-10 18:46:45 +02:00
2021-02-06 18:22:00 +01:00
To be define the quality of a package, it'll obtained a [level ](/packaging_apps_levels ), determined according to somes criteria of installation and according to respect to [package guidelines ](/packaging_apps_guidelines ).
2017-01-26 17:36:48 +01:00
2016-02-24 21:34:31 +01:00
### Package script checker
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [Package checker ](https://github.com/YunoHost/package_checker ) [/div]
2016-02-24 21:34:31 +01:00
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
2019-03-10 00:37:25 +01:00
### Continuous integration
A continuous integration server is available for packagers who want to test their apps.
2021-02-07 04:34:04 +01:00
[div class="btn btn-lg btn-default"] [Continuous integration ](packaging_apps_ci ) [/div]
2019-03-10 00:37:25 +01:00
2015-06-18 20:00:03 +02:00
### Publish and ask for testing your application
2019-03-08 17:07:57 +01:00
2021-01-18 15:24:49 +01:00
* Publishing a [post on the Forum ](https://forum.yunohost.org/ ) in the [`Discuss > Apps` category ](https://forum.yunohost.org/c/discuss/discuss-apps/ ), to ask for testing and feedback on your application.
2015-06-18 20:00:03 +02:00
2020-03-28 06:54:10 +01:00
* If your application is released under a free software license, you may ask the YunoHost app team to integrate your application to the [app repository ](https://github.com/YunoHost/apps ) (c.f. also the [app list ](/apps )). You can add your application even if it is not stable or working yet : the current state can be specified to `notworking` , `inprogress` , or `working` .
2019-03-08 17:07:57 +01:00
* If your application is *not* free software, then in the future, a non-official list might be created to handle them but is non-existent yet.
2016-03-09 16:17:29 +01:00
2015-06-18 20:00:03 +02:00
### Officalization of an application
2019-03-08 17:07:57 +01:00
2019-03-08 15:51:42 +01:00
**!! This section is obsolete as of 08/03/19** - The project's organization regarging this point is to be changed.
2020-07-27 18:55:33 +02:00
To become an official application, it must be tested well enough, be stable and should work on Debian Buster 64 bits, 32 bits and ARM architectures. If you think those conditions are met, ask for [official integration ](https://github.com/YunoHost/apps ) of your application.