CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Building a CPAN-Worthy distribution with module and a script

 



rpaskudniak
User


Feb 21, 2011, 6:04 PM

Post #1 of 2 (1455 views)
Building a CPAN-Worthy distribution with module and a script Can't Post

Greetings.

Although I am not (by own evaluation) and advanced Perl programmer, I am posting my question in this section because my post in the "Intermediate" section has yet to receive an answer.

The quick version of the story:
My dist contains a module and a script. When I install it, the module goes into a known place; the scripts seems to have been ignored.

Now the fuller story:

I have a Perl module for which I'd like to build a CPAN-worthy distribution. I also want to include a runnable script that uses the module, serving as both an example and a useful application. I started with h2xs to build the skeleton distribution and copied/edited my .pm file in there. What about the script that uses it? Taking what appears to be a cue in ExtUtils-ModuleMaker-0.51, I manually added a scripts directory parallel to the lib directory.

Here's what by directory structure looks like, with comments added:

Code
$ find UNLreport 
UNLreport # Top level directory
UNLreport/lib # Subdir generated by h2xs
UNLreport/lib/UNLreport.pm # The star module of this dist
UNLreport/Makefile # Generated by perl Makefile.PL
UNLreport/Makefile.PL # Makefile builder generated by h2xs
UNLreport/MANIFEST # See comments below
UNLreport/README # Edited from the original skeleton
UNLreport/scripts # I added this subdirectory
UNLreport/scripts/beautify-unl.pl # The script I was talking about
UNLreport/t # The test stuff. Leaving these
UNLreport/t/UNLreport.t # alone for now

Now about the MANIFEST file:

Code
Makefile.PL                      
MANIFEST
README
t/UNLreport.t
lib/UNLreport.pm
scripts/beautify-unl.pl # I added this entry to the MANIFEST


And, of course, I ran the appropriate:


Code
perl Makefile.pl 
make dist

The result was UNLreport-1.02.tar.gz.

Now, I built this all under Cygwin (Windows-7). I then booted Ubuntu, copied the gz to /Var/Downloads (my way of setting a private standard) and unpacked, untar'ed, ran the appropriate stuff through make install.

So where did my stuff end up? Well, the module ended up as:

Code
/usr/local/share/perl/5.10.1/UNLreport.pm

All fine and well for a simple module. Now what about the script I stuck into the scripts directory? Looks like my emulation of ExtUtils was misdirected.

Come to think of it, I'm not sure of where I did want the script to get installed. I think something like in /usr/local/share/scripts (which would have to create) but I was hoping there would be an attempt by the "make install" to put it someplace, get an error, and I would create the necessary directory.

BTW, here's the install session, as best as I could edit it from the messed up "scripts" output

Code
Script started on Mon 21 Feb 2011 07:45:19 PM EST 
rasputin@maxwell:/var/Downloads/UNLreport-1.02$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for UNLreport

rasputin@maxwell:/var/Downloads/UNLreport-1.02$ make
cp lib/UNLreport.pm blib/lib/UNLreport.pm
Manifying blib/man3/UNLreport.3pm

rasputin@maxwell:/var/Downloads/UNLreport-1.02$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/UNLreport.t ..
t/UNLreport.t .. 1/1
t/UNLreport.t .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.02 cusr 0.00 csys = 0.05 CPU)
Result: PASS

rasputin@maxwell:/var/Downloads/UNLreport-1.02$ sudo make install
[sudo] password for rasputin:
Installing /usr/local/share/perl/5.10.1/UNLreport.pm
Installing /usr/local/man/man3/UNLreport.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod
rasputin@maxwell: /var/Downloads/UNLreport-1.02
rasputin@maxwell:/var/Downloads/UNLreport-1.02$ exit

Script done on Mon 21 Feb 2011 07:46:35 PM EST

So now that you know what I'm up to:
- How do I get my distribution to include the script?
- How do I tell it where to put the script

Thank you, O Gurus, for your guidance here.
--------------------
-- Rasputin Paskudniak (In perpetual pursuit of undomesticated, semi-aquatic avians)


rpaskudniak
User


Feb 22, 2011, 9:18 PM

Post #2 of 2 (1432 views)
Re: [rpaskudniak] Building a CPAN-Worthy distribution with module and a script [In reply to] Can't Post

Solution found! (It had been seen but overlooked.)

I edited makefile.PL, adding one parameter to the WriteMakefile() call:

Code
WriteMakefile( 
NAME => 'UNLreport',
VERSION_FROM => 'lib/UNLreport.pm', # finds $VERSION
EXE_FILES => [ 'scripts/beautify-unl.pl' ],
PREREQ_PM => {}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/UNLreport.pm', # retrieve abstract from module
AUTHOR => 'U-Maxwell\Rasputin <rpaskudniak@x-ray.at>') : ()),
);

(Note: I have edited my name out of the AUTHOR hash to provide myself with token privacy.)

Result:

Code
$ sudo make install 
Installing /usr/local/share/perl/5.10.1/UNLreport.pm
Installing /usr/local/man/man3/UNLreport.3pm
Installing /usr/local/bin/beautify-unl.pl
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod

I will start another thread on controlling where to install the script. But right now I just want to celebrate!

--------------------
-- Rasputin Paskudniak (In perpetual pursuit of undomesticated, semi-aquatic avians)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives