Sign In/My Account | View Cart  
advertisement


Listen Print Discuss

Painless Windows Module Installation with PPM
by Josh Stroschein | Pages: 1, 2, 3

Registering a Repository

Creating a local repository requires just a few commands. From within the PPM program type:

rep add <name> <location>

Suppose that you have created the packages directory at C:\Perl\bin\packages. You have also created the x86 directory inside the packages directory: C:\Perl\bin\packages\x86. When you perform a search with PPM, it queries the PPD files. More specifically, it queries the metadata inside the XML of the PPD file, matching the title tag against your search. Executing:

ppm> rep add MyRep C:\Perl\bin\packages

... creates a repository named MyRep that uses PPD files in the packages directory. After this command completes, check to see that it's now in the repository list:

ppm> rep
Repositories:
[1] ActiveState Package Repository
[2] ActiveState PPM2 Repository
[3] MyRep

This will return a list of all the available repositories. You should now see the repository that you just created, which will be set to active by default. The numbers in the list serves two purposes: the first is to define the order in which the search executes. PPM searches first the repository at position one, followed by two, and so forth. Second, it eases the management of the repositories much in the same way it eases installing modules. Instead of referring to a repository by name, you can refer to it by its number.

A More Public Repository

The new local repository is only accessible by the machine where it resides. If desired, you can modify the PPD files and the steps involved in creating a repository to use an HTTP-based repository over a local network. You could use this repository outside of an installation package to manage and provide module access over a large network. For a straight-forward HTTP-based repository, all you need is a web-server accessible to a local Intranet or over the Internet.

Even though I did not implement an HTTP-based repository, is well worth covering a simple setup. This essentially involves creating two repositories: one on the server and the other on any PC. I chose the Windows version of the Apache 2 web server. After a default installation of Apache 2, I configured it as a repository. There are only a couple of steps involved to accomplish this.

By default, Apache serves its pages from C:\Program Files\Apache2\htdocs.. I created the repository directories as previously discussed: C:\Program Files\Apache2\htdocs\packages\x86. As long as the packages directory is web-accessible, it will allow the server to act as a simple web-based repository. If you don't plan to run PPM on the server then the ActivePerl installation is not even necessary. Now when you create a repository, if you supply the url to the server instead of a directory path it will access the repository over the network or Internet. To create a web-based repository in PPM, type:

ppm> rep add <name> <url>

Now the PPM program on that machine will be able to search the modules available on the repository located at the specified URL.

In order to test the installation of the repository, I usually disable the other repositories. There are multiple ways to do this, but I find it easiest to turn off the repositories. This keeps the repository available on the system; however, PPM will not use them when you perform a search. To disable searching of the repository at position two, type:

ppm> rep off 2
Repositories:
[1] ActiveState Package Repository
[2] MyRep
[ ] ActiveState PPM2 Repository

You can also remove a repository from your system:

ppm> rep delete <name or num>

This will completely remove that repository from the system. Removing a repository is safe if you are confident that you will not use that repository again.

Maybe you are not sure if a repository is active. Listing the repositories on your system will provide the information you need to know if a repository is active:

ppm> rep
[1] ActiveState Package Repository
[2] MyRep
[ ] ActiveState PPM2 Repository

If there is not a number assigned to a repository, then it is not active. In this example, the ActiveState PPM2 Repository is still configured on the system but it is not active, so PPM will not search through it. To begin searching it again, all you need to do is to reactivate it:

ppm> rep on ActiveState PPM2 Repository

Conclusion

PPM is a small but useful program for managing Perl modules needed on your systems. It provides a simple command line interface and the capability to customize the way it searches for modules. PPM allowed me to install the modules I needed without relying on Internet access. This led to the creation of an installation package that was truly Internet independent. It also enabled me to create an installation package that was completely automated, requiring no user interaction.