hesco has asked for the wisdom of the Perl Monks concerning the following question:
Spent some time in the archives reading How to make a CPAN Module Distribution, José's Guide for creating Perl modules, ExtUtils::ModuleMaker and a few distractions along the way.
These all seem to assume a much cleaner development environment than I deal with. I'm a pack rat. I'll throw together half-baked notes, save back sample data or test results, sample code and leave it in my primary work directory. cvs does not seem to mind until I do a cvs add _some_new_file_. But I need a way of easily extracting the files I'm interested in sharing, without destroying my work environment, in a ready to distribute form. I call this: build_distro.pl, on its way to being something more useful. Here is a snippet of the docs.
=head2 build_distro() build_distro() takes a source directory with a properly formatted MANIFEST file and produces a tar.gzipped package of the file +s specified in the MANIFEST file. =cut
#!/usr/bin/perl -w use strict; use warnings; # name of tar package to build my $pkg = "Foo_Bar_0_01.tar"; # expressed as a relative path to directory with MANIFEST my $basedir = "Foo_Bar_0_01"; =head1 NAME build_distro.pl - build a tar.gz from a MANIFEST =head1 VERSION Version 0.01 =cut our $VERSION = '0.01'; =head1 SYNOPSIS This script will accept a package name and a source directory and use them to build a gzipped tarball for distribution of only those files and directories not commented out from a MANIFEST list in the source directory. To use, at the moment: /path/to/build_distro.pl after hard coding in the values for $pkg and $basedir and changing the current directory to the path where you want to package written to. Longrange the interface is imagined as: use Module::BuildDistro; my $pkg = Module::BuildDistro->new({ -source => 'Your_New_Module' +}); $pkg->build_distro(); or, perhaps simply: module-build-distro --source=Your_New_Module/ =head1 EXPORT build_distro() =head1 FUNCTIONS =head2 build_distro() build_distro() takes a source directory with a properly formatted MANIFEST file and produces a tar.gzipped package of the file +s specified in the MANIFEST file. =cut sub build_distro { } print "Our working directory is: ", `pwd`,"\n"; if(-f $pkg){ warn "$pkg already exists."; print "Shall I delete $pkg (y/n)?"; my $response = <STDIN>; chomp($response); if($response eq 'y'){ unlink($pkg); print "I have just deleted $pkg.\n"; } else { die "I can not build new distribution without deleting old one."; } } open(MANIFEST,"$basedir/MANIFEST") or die "Unable to open $basedir/MANIFEST. ?: $?, !: $!"; my $result = `tar -cf $pkg $basedir/MANIFEST`; if(!defined($result)){ warn "Failed to create tar ball: $pkg. ?: $?, !: $!"; } FILE: while(<MANIFEST>){ chomp($_); if(/^#/){ print "Skipping $_.\n"; next FILE; } unless ($_ eq ""){ $result = `tar -rf $pkg $basedir/$_`; if(!defined($result)){ warn "Failed to append $basedir/$_ to the tar ball: $pkg. ?: $?, + !: $!"; } } } $result = `gzip $pkg`; if(!defined($result) ){ warn "Failed to gzip the package file.i ?: $?, !: $!"; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Building a package for distribution: How do the pros do it?
by Joost (Canon) on Dec 26, 2006 at 00:12 UTC | |
by hesco (Deacon) on Dec 26, 2006 at 01:01 UTC | |
by Joost (Canon) on Dec 26, 2006 at 01:09 UTC | |
|
Re: Building a package for distribution: How do the pros do it?
by ysth (Canon) on Dec 26, 2006 at 00:09 UTC | |
|
Re: Building a package for distribution: How do the pros do it?
by brian_d_foy (Abbot) on Dec 26, 2006 at 22:27 UTC |