=head2 build_distro() build_distro() takes a source directory with a properly formatted MANIFEST file and produces a tar.gzipped package of the files 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 files 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 = ; 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(){ 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;