Interis installer is written with Perl in an object oriented manner. It has mainly 3 component
The executbale perl scrupt is the installer.pl file. The other 2 .pm files are helper files. Actually installer.pl is a wrapper of install.pm perl module. It calls the member functions of Installer.pm perl module.
The perl script installer.pl has a simple content. It mainly has 2 lines as below
| my $installer = new Installer('server_host' => 'localhost'); $installer->start ( startpoint => 5100, execution_type => "onlythis" ); |
1. line show the instantiation of Installer Perl modeul which is defined in Installer.pm file. 2. line shows how the start function is called.
You see that installer.pm perl module is the main installer file of Interis.
Now, I will explain the structure of installer.pm module, but before starting to explain, i have to make the requierements clear.
Why Interis need such an installer?, how its functionality orginized?
Now, you know that constructing a mail server, supporting virtual accounts, anti-spam, anti-virus and quota management system, requires a lot of packages, and there is a dependency tree between packages and this dependency tree becomes the root of problems while installing packages. To solve this problem, you have to explore that which package is more dependent to other and which package is less dependent or has no dependency to other packages. When you resolve this dependency tree, you will see that there must exist an install order between packages. In addition, the ordering may change in the future. Therefore, our installer has to support ordering mechanism to make installations of package easy and configurable.
Next, there is a configuration problem between packages. Since some packages are dependent to each other, the configuration between these packages are also dependent. Some configurations are needed at build time, but some configurations are needed before the execution time, meanly after build time. while constructing the structure of installer, we have to take attention to this point.
There is one more problem. We mention that there have to be an ordering between installation of packages, and there have to be an order between building and configuring between dependent packages. Meanly, we have a start point, and a long building process and after that again a long configuration process. Bu we have nearly 30 packages and if our installer starts installing from 1. package, it will not stop until it reaches 30. packages. What will happen if there occur an error at the compilation process of 15. package. We have to remove all the installed packages, and starts again from 1. package. I have to say that building of 30 packages takes nearly 30 minitues. Now, I think you see that we have to find a solution to make this process, which takes 30. minutes, more manageable. We have to split this long process into small process and manage easily. Meanly, we must be able to start only 16. installation or 21. installation process and be able to see what happened at the end of that installation. If the installation process finished without an error, we will be able to continue from 22. installation process. This solution will help us while testing the installer script.
Now, lets explain installer.pm.
First, i want to show you that how the packages are numbered. Installer package has a member function named as start. This memeber function has a main loop. Its content is as below
#################### the Package numbered as 0 ##################3 if ($execution_type=~ /^startfrom$/){ #################### the Package numbered as 100 ##################3 if ($execution_type=~ /^startfrom$/){ } |
Here, there are mainly tree variable $this->{'state'}, $startpoint and $execution_type.
$this->{'state'} variable is a member variable of Installer package and it stores the installation order. It starts from $startpoint value which is passed as a parameter to the 'start' function and at the end of each loop or when the 'next' statement is reached, $this->{'state'} member variable is incremented by one. If $this->{'state'} value reaches 0 $this->init function is executed, If $this->{'state'} value reaches 100, $this->bind_maker function is executed. After, execution of bind_maker function, $this->{'state'} value will be incremented by one at each loop until 200 value. At $this->{'state'} becomes 200, another member function will be executed.
Now, lets explain $execution_type. Above, $execution_type is compared with two value : "startfrom" and "onlythis" . If $execution_type is equal to "startfrom", the installation process start from $startpoint and goes to the end. If $execution_type is equal to "onlythis", the installation process start from $startpoint, and will execute only the function whose number equals to $startpoint and will end the loop.