PLESK MODULES

Chapter 4. Creating RPM Installation Package

To create an installation package in the form of an RPM file, follow these steps:

- create the file structure that would correspond to the future location of module files.

For example:

<PRODUCT_ROOT_DIR>/admin
                      /bin
                          /modules
                              /firewall
                                 !<symbolic link to binary utility>
                          /htdocs
                              /modules
                                  /firewall
                                     /images
                                     /locales
                                         /en-US
                          /plib
                              /modules
                                  /firewall
                                     /locales
                              /templates
                                  /modules
                                     /firewall
                          /sbin
                              /modules
                                  /firewall
                                     <binary utility>
                      /etc
                          /modules
                              /firewall
                                  <database_structure>
                      /var
                          /modules
                              /firewall
                                  <emergency_script>
/etc
    /init.d
        <scripts>
<PRODUCT_ROOT_DIR> - root dir of Plesk installation, e.g. /usr/local/psa

- place module files (control scripts and utilities, functionality, other files) in the necessary subdirectories of the created file structure.

- create the SPEC file describing the process of an RPM package creation.

A SPEC file is obligatory for building an RPM package. It includes the package description, instructions on the building process, lists of the files included in the package and lists of third-party applications that need to be installed. A standard SPEC file should look as follows: <package name>-<version number>-<release number>.spec.

A SPEC file should include info on the path the application will be installed by, the correct built number, version number and application name.

Note: The Provides section must include the plesk-module value.

 In this case, the package name is psa_<module_name>-<version>.<release>.rpm.

The example of the SPEC file for firewall module:

%define module firewall
%define rpmname psa-%{module}
%define prodvers 7.5

Summary: The Firewall module helps protect your host and private network from unauthorized access
Name: %{rpmname}
Version: 1.0
Release: 1
Copyright: Commercial license
Vendor: SWsoft
Group: Networking/Daemons
Packager: SWSoft Inc <info@sw-soft.com>
BuildRoot: /modules/%{module}
Provides: plesk-module
Prefix: /usr/local/psa
Prereq: psa >= %{prodvers}
URL: http://www.sw-soft.com/

%description
The Firewall module allows you to configure the firewall on your machine. Typical firewall administration tasks, such as controlling access to your WWW or FTP server, are done in several clicks. More complex configurations are possible with custom rules.

%files

%defattr(750, root, psaadm) // defattr(access_mode, owner, group)
%{product_root_d}/etc/modules/%{module}/
%{product_root_d}/admin/htdocs/modules/%{module}/
%{product_root_d}/admin/plib/modules/%{module}/
%{product_root_d}/admin/plib/templates/modules/%{module}/

%defattr(550, root, psaadm)
%{product_root_d}/admin/sbin/modules/%{module}/
%{product_root_d}/admin/bin/modules/%{module}/

%defattr(770, root, psaadm)
%{product_root_d}/var/modules/%{module}/
%attr(700, root, root) %{product_root_d}/var/modules/%{module}/firewall-emergency.sh

%defattr(755, root, root)
%config /etc/init.d/%{rpmname}
%config /etc/init.d/%{rpmname}-forward

%prep

[ -f %{buildroot}/../rpm_%{module}_install_pre.sh ]
[ -f %{buildroot}/../rpm_%{module}_install_post.sh ]
[ -f %{buildroot}/../rpm_%{module}_uninstall_pre.sh ]

%pre
%include %{buildroot}/../rpm_%{module}_install_pre.sh

%post
%include %{buildroot}/../rpm_%{module}_install_post.sh

%preun
%include %{buildroot}/../rpm_%{module}_uninstall_pre.sh

- indicate in the % section the location of files that should be included in the package, and also access permissions for them that should be set after the RPM package is installed.

- use in the %pre, %post, %preun sections the files with scenarios responsible for preinstall and postinstall preparation and preparation before a module removal. By preparation the following actions are meant: creation, setting and removal of databases, configuration files, etc. See the example.

- build the RPM package.

Note: Information on what rights one must have to be able to create an RPM package can be found in the documentation for the used operation system.

To launch an assembly package, the following command must be executed (on the example of Linux Red Hat):

# rpmbuild --bb  --target=noarch /usr/src/redhat/SPECS/<a spec file name for your locale>.spec

At the end of this utility operation, the message on where the created package is located is displayed. For example, in the Red Hat Linux it can be found in the /usr/src/redhat/RPMS/noarch directory.

A more detailed information on creation of RPM packages can be found at http://www.rpm.org/RPM-HOWTO/build.html.

to top