This is an old revision of the document!
Adding Perl module dependencies
- intern met.no info - flyttes til dokit
To deal with Perl module dependencies in a safe way the METAMOD project has developed its own dependencies handler that at all times keeps track of a dependency graph. The dependency graph contains information on which modules depend on each other and what version is needed. The dependency handler was mainly created to solve the following problems:
- If installing Perl modules from an OS repository (like the Ubuntu repo) you are dependent on the version used by the OS version.
- This modules can often be out-dated.
- You are not guaranteed that the version X and version Y of the OS use compatible versions of the same module.
- The module might not be available.
- If installing Perl modules via a CPAN client you will always get the lastest version of a module. The module version will therefore depend on the time of installation and different machines will get different configurations. This often leads to bugs that are hard to track down and are a complete waste of time.
The dependency handler used in METAMOD is one possible approach to this problem. The rest of the document describes how a new module can be added to graph.
Checking out dependency handler with graphs
svn checkout https://svn.met.no/dependency_handler/trunk
Check what is required for adding the module to the graph
Before adding a module to the graph is recommended to check what this will required of module upgrades and adding of new modules.
$ perl ./script/dependency_handler.pl --config dep-graphs/metno-perl-webdeb-ver1/deps-config.json --check POE The following modules needs to be added: Module: IO Required for phase(s): runtime Module: IO::Handle Required for phase(s): runtime Module: IO::Tty Required for phase(s): runtime Module: JSON::PP Required for phase(s): runtime Module: Version::Requirements Required for phase(s): runtime Module: CPAN::Meta Required for phase(s): runtime Module: POE::Test::Loops Required for phase(s): configure,build,runtime Module: POE Required for phase(s): configure,build,test,runtime,develop The following modules needs to be updated: Module: Parse::CPAN::Meta Current version: 1.40 Wanted version: 1.4401
This output tells you the list of modules that will be added and that we need to upgrade 'Parse::CPAN::Meta' before we add the module to the graph.
Upgrade necessary modules
If you want to update a module or are required to upgrade a module before adding a new dependency do as follows. Note that modules will NEVER be auto-update to a new version. This is prevent nasty surprises that can arise when modules are updated to a new version.
$ dependency_handler.pl --config deps-config.json --update Parse::CPAN::Meta [INFO] Starting download of Parse-CPAN-Meta-1.4401 [INFO] Download complete for Parse-CPAN-Meta-1.4401
Add a new module
Now we can add the module that we wanted. Adding a module will also automatically add all dependencies.
$ dependency_handler.pl --config deps-config.json --add POE [INFO] Skipping download of ExtUtils-MakeMaker-6.56, already in repository [INFO] Skipping download of PathTools-3.33, already in repository ... [INFO] Starting download of POE-1.311 [INFO] Download complete for POE-1.311
Build all modules in the graph
Now that we have added a new module to the graph it is recommended to re-build all the dependencies in the graph. Depending on the size of your graph this will take quite a lot of time.
$ cd dep-graphs/metno-perl-webdeb-ver1 $ make
Please note that is not un-common that the install step fails on the first try. When it fails check the cpanminus log and try to discover what the problems is. Also try to build the failing module in isolation. Often a failing tests is the problem and in that case you can set the dependency handler to force install the module in the config file.
Check-in the graph to the repository
Since you have now have changed the dependencies graph you also need to update the changelog for the debian. Open 'debian/changelog
' in an editor and add a new entry at the top of file similar to the other entries. Remember to update the version number.
Check you changes into the repository.
Build Debian packages
As the build process takes a long time it is recommended to build Debian packages for targeted platforms. For METAMOD that is currently:
- Lucid 64-bit kernel, 32-bit userland (dev-vm129)
- Lucid 64-bit kernel, 64-bit userland (dev-vm130)
- Hardy 64-bit kernel, 32-bit userland (dev-vm131)
- Hardy 64-bit kernel, 64-bit userland (dev-vm132)
Log in to the development machine
$ ssh root@dev-vm129
Enter the dependency handler directory and update it with the latest changes.
$ cd dependency_handler # NOT dependency-handler $ svn up
Note that dependency-handler
is the obsolete, Git-based system. Delete if found on server.
Build the debian package.
$ cd dep-graphs/metno-perl-webdeb-ver1 $ make create_package
If everything works you should now have a brand new debian package that you can upload the repository.
dupload --to <hardy-devel or lucid-devel>