You are not logged in Log in Join
You are here: Home » Members » andym » Creating Tar Files for Products

Log in
Name

Password

 

Creating Tar Files for Products

Released products should be in some sort of tar file. To help do this, especially on Windows where tar file support is lacking here's a quick Perl Script that can create a tar file for you.

To use enter the perl script, argument one is the directory containing the product, argument two the name.

Eg: tar.pl lib/python/products/Foo Foo

use Archive::Tar;
use File::Recurse;

# usage and args...
if (scalar(@ARGV) < 2) {
    print < 
path to directory: eg lib/python/products/Foo
product name: eg Foo
EOF
}

# get arguments
$dirname = $ARGV[0];
$name = $ARGV[1];

# get a file list
@filelist = undef;
recurse { push(@filelist, $_) } $dirname;

# make tar
$tar = Archive::Tar->new();
for (@filelist) {
    if (!-d $_ && $_ !~ /.pyc/) {
        print "Adding $_\n";
        $tar->add_files("$_");
    }
 }

# write, and finish
$tar->write("$name.tar");
print "\nArchive $name.tar created.";