Packaging CPAN modules from Windows in Linux Style

| No Comments | No TrackBacks
Packaging CPAN modules from Windows in Linux Style


You're a CPAN author, but against the trend you develop on Windows rather than Linux.
This is fine, helps a lot with your modules cross platform compatibility, but when you come to package your modules for CPAN you hit a snag. Windows doesn't have tar or gzip, or even make... You can get nmake as a download from Microsoft, you could use .zip rather than .tar.gz, but this isn't going to make the Linux buffs very happy.

The solution is pretty simple, luckily there is a package called UnxUtils (yes no i in Unx) available on sourceforge. This has Win32 ports of gzip, tar and make. Although you'll still need nmake from Microsoft as you'll find make won't read windows paths properly.

Here is a quick step by step:-

1. Create your module, I suggest starting with Module::Starter rather than h2xs as it gives you a better starting point.

2. Download UnxUtils.zip

3. Unzip to a temp folder, for some reason the folder you want is in temp\usr\local\wbin. Move this wbin folder into your c:\ root to make c:\wbin, then rename to something sensible like c:\UnixUtils. (yes I added the i).

4. Update your path environment variable to include this folder on the end. In Vista32 in go Start->(Right click on)Computer->Properties->Advanced System Settings, then click the Advanced tab at the top of the window, then the Environment Variables button near the bottom. Finally under 'System Variables' scroll  to find Path, select then click the edit button. Scroll to the end of the list and add ";c:\UnixUtils". Click Ok and Ok again. You may need to reboot for this to take full effect.

5. Now you need to grab nmake from Microsoft.
(this link is subject to change, you may need to search their site). Move the downloaded nmake15.exe file to c:\windows, then run it. It'll extract the nmake.exe executable.

6. You are ready to build your distribution :) Open a command prompt and navigate to your modules folder that you created in step 1. Run:-
perl Makefile.pl
nmake test
nmake dist

7. It's important to note, that although at this point you'll have what seems to be a perfectly acceptable .tar.gz file for your module. If you upload this module to PAUSE you'll get an error because it contains world writeable files and folders. This is because tar perceives windows files permissions as being equivalent to open Linux file permissions.

When I first hit this snag I thought I was going to have to write a script to fix it, but luckily someone else has already done it :) Visit the PerlMonks node 731935 and save the code to c:\UnixUtils as tarfixer.pl (use the Download code link at the bottom, don't just copy and paste).

8. Now you can fix your distribution with perl c:\UnixUtils\tarfixer.pl -i.bak Module-Name.tar.gz
Hopefully bart will be good enough to upload this script to CPAN and create a nice tarfixer.bat file for us.


VoilĂ ! A nice Linuxy .tar.gz Perl module built on Windows.


Lyle

No TrackBacks

TrackBack URL: http://perl.bristolbath.org/cgi-bin/mt/mt-tb.cgi/8

Leave a comment

About this Entry

This page contains a single entry by Lyle published on January 8, 2009 2:24 AM.

Giving CGI::Application internationalization (I18N) part4 was the previous entry in this blog.

Making .po and .mo files is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.