# Updates

The following directory structure shows how a update/patch package has to be structured.The purpose of the different files will be
covered afterwards.

```
* {UniquePackageName.tar.gz}
    * signature.cert
    * Files
        * package.json
        * {other_files_or_subdirectories}
```

## Package Name

The unique package name is generated by the update server. Usually they are called:

* Modules: {Module Name}_{New Version}.tar.gz
* Framework: {Framework Name}_{New Version}.tar.gz
* Resources: {Resource Name}_{New Version}.tar.gz
* Other Components: {Component Name}\_{New Version}.tar.gz

By providing unique package names it's possible to define other updates as dependencies and prevent overwriting update packages.

## signature.cert

The `signature.cert` contains the signature for the package which will be used to certify the origin of the package.
The public key provided with the application is used to decrypt the certificate and compare it to the actual package data.

## Files

In the files directory all files are stored.

### package.json

The `package.json` file contains information of the package.

```json
{
    "name": "{NAME|RESOURCE_NAME|phpOMS|jsOMS|cssOMS}",
    "type": "Modules",
    "version": "1.0.1",
    "update": [
        {
            "download": {
                "{download_uri}": "{save_to_path/file_name}"
            },
            "move": {
                "{file_or_directory_to_move}": "{new_destination}"
            },
            "copy": {
                "{file_or_directory_to_copy}": [
                    "{new_destination}"
                ]
            },
            "delete": [
                "{file_or_directory_to_delete}"
            ],
            "cmd": [
                "{php|sh|batch_script_to_execute}",
            ]
        }
    ]
}
```

### Other

All other files are related to updates, patches, extensions and installation. These files can be simple assets that will be used or replaced in modules, classes in the framework that need to be updated and sql methods for updating the database schema.
