File:  [mozdev] / annozilla / src / zip.pl
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Mon Apr 12 11:17:23 2004 UTC (13 years, 8 months ago) by matthew
Branches: MAIN
CVS tags: HEAD, ANNOZILLA-ES-CHANGES, ANNOZILLA-ES, ANNOZILLA-CGH-CHANGES, ANNOZILLA-0-7-0, ANNOZILLA-0-6-7-BRANCH, ANNOZILLA-0-6-7, ANNOZILLA-0-6-6, ANNOZILLA-0-6-5, ANNOZILLA-0-6-1, ANNOZILLA-0-5-4
Script to zip up files, giving them 666 permissions

#!/bin/perl -w
# Taken from the Archive::Zip distribution examples/ directory.
# Creates a zip file, adding the given directories and files.
# Usage:
#	perl zip.pl zipfile.zip file [...]

use strict;
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);

die "usage: $0 zipfile.zip file [...]\n"
	if (scalar(@ARGV) < 2);

my $zipName = shift(@ARGV);
my $zip = Archive::Zip->new();

foreach my $memberName (map { glob } @ARGV)
{
	if (-d $memberName )
	{
		warn "Can't add tree $memberName\n"
			if $zip->addTree( $memberName, $memberName ) != AZ_OK;
	}
	else
	{
		$zip->addFile( $memberName )
			or warn "Can't add file $memberName\n";
	}
}

foreach my $member ($zip->members()) {
    $member->unixFileAttributes(0666);
}

my $status = $zip->writeToFileNamed($zipName);
exit $status;


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>