Plugin File Structure

Version 2 (Anil Gulecha, 01/04/2011 02:43 am)

1 1
Plugin File Structure
2 1
=====================
3 1
4 1
We will take a look at how a plugin is organized, and what files consist a plugin.
5 1
6 1
NexentaStor plugins are a collection of debian packages. Typically, a plugin can consist of any plugin that extends the three components of the Nexenta Appliance, namely: **nms** (Nexenta Management Service), **nmc** (Nexenta Management Console), **nmv** (Nexenta Management View).
7 1
8 1
Let's the the following two example plugins and discuss their structure: *ddclient* and *simple-encryption*.
9 1
10 1
## Package: ddclient ##
11 1
12 2 Anil Gulecha
![ddclient](http://www.nexentastor.org/attachments/download/104/ddclient.png)
13 2 Anil Gulecha
14 1
This image shows the file structure of the ddclient package. You can download this package offline via the commands listed on the [repository page](http://www.nexentastor.org/projects/ddclient/repository).
15 1
16 1
<ins>**Files**</ins>
17 2 Anil Gulecha
18 2 Anil Gulecha
The main package directory nmc-ddcleint forms all of plugin, i.e, the plugin only has the nmc component. This folder has another directory (*debian*) and 2 perl modules (*Ddclient.pm*, *metafile.pm*)
19 2 Anil Gulecha
20 2 Anil Gulecha
* *<ins>Ddclient.pm</ins>* - This is the main plugin module, that provides the functionality required. In this particular case, the plugin is basically a wrapper over underlying ddclient facilities. We will go into a line by line explanation later on.
21 2 Anil Gulecha
22 2 Anil Gulecha
* *<ins>metafile.pm</ins>* - This module is included in all plugin packages. This includes basic plugin information like name, description, plugin group, etc. We will go into a line by line explanation later on.
23 2 Anil Gulecha
24 2 Anil Gulecha
* *<ins>debian/</ins>* - This directory is present in any debian package, and contains package meta-information (name, dependencies), and build rules (like a Makefile) that builds the packages. This folder can also optionally contain post/pre install/removal scripts if required by your plugin package.
25 2 Anil Gulecha
26 2 Anil Gulecha
* *<ins>debian/control</ins>* - This file lays out the information official package name, version, dependencies.
27 2 Anil Gulecha
28 2 Anil Gulecha
* *<ins>debian/changelog</ins>* - This is a plain text changelog that maintains a log of what changes were made subsequent versions. An entry is to be added manually for every version of the package released. The 'dch' command makes it easy to edit this file, and maintain the syntax required.
29 2 Anil Gulecha
30 2 Anil Gulecha
* *<ins>debian/rules</ins>* - This is the main build file. It is a Makefile that lays out the targets *clean*, *deploy-dirs*, *binary-arch* and *binary*. These respectively clean the workspace, install files in temporary directory structure, builds the binary debian package respectively. 
31 2 Anil Gulecha
32 2 Anil Gulecha
* *<ins>debian/copyright</ins>* - This file includes the licensing information about the package.