X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_zipCreate;h=bebea7ac1fb8b45f47e1284c6f84f33a59aa790d;hp=4fa7f4a5e7d9c3a49e0d96c96f64c24b20abf5df;hb=e951f787a66c5bd9e9955c3f657a5b44289c0fe1;hpb=e9453b7611be63303572ae443d5fb56b73364678 diff --git a/bin/BackupPC_zipCreate b/bin/BackupPC_zipCreate index 4fa7f4a..bebea7a 100755 --- a/bin/BackupPC_zipCreate +++ b/bin/BackupPC_zipCreate @@ -1,4 +1,4 @@ -#!/bin/perl -T +#!/bin/perl #============================================================= -*-perl-*- # # BackupPC_zipCreate: create a zip archive of an existing dump @@ -33,7 +33,7 @@ # Based on Backup_tarCreate by Craig Barratt # # COPYRIGHT -# Copyright (C) 2002 Craig Barratt and Guillaume Filion +# Copyright (C) 2002-2003 Craig Barratt and Guillaume Filion # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,13 +51,14 @@ # #======================================================================== # -# Version 1.6.0_CVS, released 10 Dec 2002. +# Version 2.1.0, released 20 Jun 2004. # # See http://backuppc.sourceforge.net. # #======================================================================== use strict; +no utf8; use lib "/usr/local/BackupPC/lib"; use Archive::Zip qw(:ERROR_CODES); use File::Path; @@ -75,16 +76,15 @@ my $BinDir = $bpc->BinDir(); my %Conf = $bpc->Conf(); my %opts; -getopts("th:n:p:r:s:c:", \%opts); -if ( @ARGV < 1 ) { +if ( !getopts("th:n:p:r:s:c:", \%opts) || @ARGV < 1 ) { print(STDERR "usage: $0 [-t] [-h host] [-n dumpNum] [-s shareName]" . " [-r pathRemove] [-p pathAdd] [-c compressionLevel]" . " files/directories...\n"); exit(1); } -if ( $opts{h} !~ /^([\w\.-]+)$/ ) { +if ( $opts{h} !~ /^([\w\.\s-]+)$/ ) { print(STDERR "$0: bad host name '$opts{h}'\n"); exit(1); } @@ -133,6 +133,7 @@ my $fh = new IO::Handle; $fh->fdopen(fileno(STDOUT),"w"); my $zipfh = Archive::Zip->new(); +binmode(STDOUT); foreach my $dir ( @ARGV ) { archiveWrite($zipfh, $dir); } @@ -270,8 +271,14 @@ sub ZipWriteFile } return if ( !$zipmember ); - # Set the attributes and permissions - $zipmember->setLastModFileDateTimeFromUnix($hdr->{mtime}); + # + # Set the attributes and permissions. The standard zip file + # header cannot handle dates prior to 1/1/1980, or 315561600 + # unix seconds, so we round up the mtime. + # + my $mtime = $hdr->{mtime}; + $mtime = 315561600 if ( $mtime < 315561600 ); + $zipmember->setLastModFileDateTimeFromUnix($mtime); $zipmember->unixFileAttributes($hdr->{mode}); # Zip files don't accept uid and gid, so we put them in the comment field. $zipmember->fileComment("uid=".$hdr->{uid}." gid=".$hdr->{gid})