Foreword
So, you have the source code of the program you really need and some number of servers under Solaris to which you need to deploy it. Moreover, for successful compilation you need a bunch of Perl modules.
Not so long ago, I was faced with such a task, and, after lengthy attempts, I can not share the solution found.
Task: Collect the munin-node client source code under SPARC Solaris and distribute across multiple servers.
')
The whole process will be described on the example of the Solaris 10 SPARC operating system (update, it seems to me that it doesn’t play a special role, I had both U6 and U9) and the free munin application (http://muninmonitoring.org/).
Training
To build the package, you need the following:
I fully admit that there may be problems with the last item. Although usually the developer clearly indicates which modules are needed. The problem is that the developer is unlikely to indicate the dependencies of the required modules.
Assembly
First you need to install Perl modules. In part, it was for the successful build of a package that included Perl modules that it was stated above that a test server with a clean axis is needed. The fact is that all modules are stored in one place. Usually this is / usr / perl5 / site_perl /
<version> /. It is desirable that at the time of installation of the modules for your program, this folder, like / usr / local / perl5 /
<version> /, was empty. This will facilitate the process of integrating the modules into the package.
Note: under
<version > - it means the working version of Perl on the server.
The easiest way is to install using CPAN.
cpan> install Module::Name
The necessary module will be installed, pulling up all dependencies. There is enough information on the CPAN on the network, so I’ll omit the moment with the installation of the modules. I note only that it is much more efficient to deploy a CPAN mirror somewhere in one place than to download them separately. Moreover, the mirror is configured very quickly, and the total volume at the moment does not exceed 2GB! Manual installation is fraught with an extremely long and unpleasant search for dependent modules.
When all modules are installed, run:
I will return to the / tmp / perl_files file later.
Now about the source codes.
Most sorts allow you to specify the path to the assembly when compiling. In other words, it is possible to specify explicitly in which directory to put all the compiled files.
Compile the source code in the desired directory (/ pkg):
The source code of the munin-node program is compiled and installed.
I will explain a little what this was done for. In the usual compilation, without specifying DESTDIR, the program will be installed in those directories that are registered in the Makefile.config. In this case, it will be difficult to put together all the information about the directories in which files were installed.
Now you need to make a list of all the files in our program:
In this case, the find command will list the contents of / pkg, then the output of the command is sent to the / tmp / files file.
After that, you need to edit the / tmp / files file, removing the / pkg directory from all paths.
Now you can install the program, as expected, without specifying DESTDIR.
Earlier, I made the file / tmp / perl_files using the find command. The contents of this file must be placed in / tmp / files, and you must view the file and delete duplicate lines. Lines should not be repeated!
You can start creating a package. First we create the “content” of the package:
This command will create a / tmp / Prototype file of approximately the same type:
d none /opt 0755 root root d none /opt/munin 0755 root root d none /opt/munin/man 0755 root root d none /opt/munin/man/man3 0755 root root f none /opt/munin/man/man3/Munin::Common::TLSClient.3 0555 root root f none /opt/munin/man/man3/Munin::Common::TLS.3 0555 root root f none /opt/munin/man/man3/Munin::Common::Config.3 0555 root root f none /opt/munin/man/man3/Munin::Common::Timeout.3 0555 root root f none /opt/munin/man/man3/Munin::Common::Defaults.3 0555 root root f none /opt/munin/man/man3/Munin::Common::TLSServer.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Config.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Server.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Service.3 0555 root root f none /opt/munin/man/man3/Munin::Node::OS.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Configure::HostEnumeration.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Configure::PluginList.3 0555 root root f none /opt/munin/man/man3/Munin::Node::SNMPConfig.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Session.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Logger.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Configure::Debug.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Utils.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Configure::Plugin.3 0555 root root f none /opt/munin/man/man3/Munin::Node::Configure::History.3 0555 root root f none /opt/munin/man/man3/Munin::Plugin::Pgsql.3 0555 root root f none /opt/munin/man/man3/Munin::Plugin::SNMP.3 0555 root root f none /opt/munin/man/man3/Munin::Plugin.3 0555 root root d none /opt/munin/man/man1 0755 root rootf none /opt/munin/man/man1/munin-node.1 0555 root root f none /opt/munin/man/man1/munin-run.1 0555 root rootf none /opt/munin/man/man1/munindoc.1 0555 root root f none /opt/munin/man/man1/munin-node-configure.1 0555 root rootd none /opt/munin/bin 0755 root root f none /opt/munin/bin/munindoc 0555 root rootd none /opt/munin/sbin 0755 root rootf none /opt/munin/sbin/munin-run 0555 root root f none /opt/munin/sbin/munin-node-configure 0555 root rootf none /opt/munin/sbin/munin-node 0555 root root
If desired, you can edit the level of access to each file.
Now, at the beginning of this file you need to add a pointer to the pkginfo file, in which information about the package will be stored. You can also add pointers to checkinstall, preinstall and postinstall to the beginning, if they are needed. Short description:
- checkinstall is used to check before installation. Runs as nobody. This script can check dependencies or permissions on directories. If the conditions are unsatisfactory, the script will terminate the pkgadd utility.
- preinstall is run as root during the installation of the package. This script, for example, can create a user for the package being installed. If you abort its execution, you will need to run pkgrm to remove the unsuccessful package installation.
- The postinstall is started after the main part of the package is installed. This script, for example, can create an SMF service, or display any information for the end user. There are lots of options.
All of these files in our case must be in / tmp.
Pkginfo, in turn, looks like this:
PKG="Munin-node" NAME="Munin-node 1.44" VERSION="1.44" ARCH="sparc" CLASSES="none" CATEGORY="application" VENDOR="GNU" PSTAMP="Creator Name" EMAIL="Creator.Name@mail" BASEDIR="/"
The syntax for adding pkginfo, checkinstall, preinstall and postinstall is as follows:
i pkginfo i checkinstall i preinstall i postinstall
So. Configuration files are ready. You can start creating a package:
Create a package, overwriting all previous attempts (-o), using / as the root directory (-r), build the package in / tmp, using the list from the Prototype file (-f).
Now in / tmp you can find the directory with the package compiled, not yet packed. The directory will have the name specified by the PKG string in the pkginfo file. All scripts, if they were added to Prototype, are located in the install directory. The program files are in the root directory. In the process of debugging the package installation, you can safely edit the contents of the files. However, it should be borne in mind that the checksum and file size may change and these changes must be reflected in the pkgmap file, otherwise the installation will fail. It's nice that when you start pkgadd -d, the installer will indicate a mismatch between the size and the amount, and it will write the correct value.
It remains a trifle:
The resulting archive can be transferred to other servers and run the installation:
The main part is complete.
application
Below we will give an example of the postinstall script, in which the initial configuration of the munin-node client is made and a service (daemon?) For munin-node is created.
The munin-node.xml file was created separately.
Its contents are:
<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> <service_bundle type="manifest" name="export"> <service name="application/munin-node" type="service" version="0"> <create_default_instance enabled="true"/> <single_instance/> <dependency name="fs" grouping="require_all" restart_on="none" type="service"> <service_fmri value="svc:/system/filesystem/local"/> </dependency> <dependency name="network" grouping="require_all" restart_on="none" type="service"> <service_fmri value="svc:/milestone/network:default"/><code> </dependency> <dependency name="name-services" grouping="require_all" restart_on="none" type="service"> <service_fmri value="svc:/milestone/name-services:default"/> </dependency> <code><exec_method name="start" type="method" exec="munin-node" timeout_seconds="60"> <method_context> <method_credential user="root" group="root"/> <method_environment> <envvar name="PATH" value="/opt/munin/sbin:/usr/bin:/bin:/opt/csw/bin"/> </method_environment> </method_context> </exec_method> <exec_method name="stop" type="method" exec=":kill" timeout_seconds="60"> <method_context/> </exec_method> </service> <code></service_bundle>
Here you just have to pay attention to the path to the executive file munin-node.
preinstall: