Changeset 76
- Timestamp:
- 10/29/06 15:32:02 (3 years ago)
- Location:
- branches/refactoring
- Files:
-
- 6 modified
-
brackup (modified) (4 diffs)
-
brackup-restore (modified) (3 diffs)
-
lib/Brackup/Config.pm (modified) (1 diff)
-
lib/Brackup/File.pm (modified) (1 diff)
-
lib/Brackup/Root.pm (modified) (2 diffs)
-
lib/Brackup/Target/Filesystem.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/refactoring/brackup
r63 r76 67 67 my $opt_du_stats; 68 68 69 my $config_file = Brackup::Config->default_config_file_name; 70 69 71 usage() unless 70 72 GetOptions( … … 76 78 'dry-run' => \$opt_dryrun, 77 79 'du-stats' => \$opt_du_stats, 80 'config=s' => \$config_file, 78 81 ); 79 82 … … 84 87 } 85 88 86 my $config = eval { Brackup::Config->load( "$ENV{HOME}/.brackup.conf") } or89 my $config = eval { Brackup::Config->load($config_file) } or 87 90 usage($@); 88 91 … … 116 119 my @now = localtime(); 117 120 $backup_file ||= $root->name . "-" . sprintf("%04d%02d%02d", $now[5]+1900, $now[4]+1, $now[3]) . ".brackup"; 118 $backup_file =~ s!^~/!$ENV{HOME}/! ;121 $backup_file =~ s!^~/!$ENV{HOME}/! if $ENV{HOME}; 119 122 $backup_file = "$cwd/$backup_file" unless $backup_file =~ m!^/!; 120 123 -
branches/refactoring/brackup-restore
r52 r76 70 70 my ($opt_verbose, $meta_file, $opt_help, $restore_dir, $opt_all, $prefix); 71 71 72 my $config_file = Brackup::Config->default_config_file_name; 73 72 74 usage() unless 73 75 GetOptions( … … 78 80 'all' => \$opt_all, 79 81 'just=s' => \$prefix, 82 'config=s' => \$config_file, 80 83 ); 81 84 … … 86 89 } 87 90 88 my $config = eval { Brackup::Config->load( "$ENV{HOME}/.brackup.conf") } or91 my $config = eval { Brackup::Config->load($config_file) } or 89 92 usage($@); 90 93 -
branches/refactoring/lib/Brackup/Config.pm
r69 r76 53 53 54 54 return $self; 55 } 56 57 sub default_config_file_name { 58 my ($class) = @_; 59 60 if ($ENV{HOME}) { 61 # Default for UNIX folk 62 return "$ENV{HOME}/.brackup.conf"; 63 } 64 elsif ($ENV{APPDATA}) { 65 # For Windows users 66 return "$ENV{APPDATA}/brackup.conf"; 67 } 68 else { 69 # Fall back on the current directory 70 return "brackup.conf"; 71 } 72 55 73 } 56 74 -
branches/refactoring/lib/Brackup/File.pm
r69 r76 53 53 sub is_link { 54 54 my $self = shift; 55 return S_ISLNK($self->stat->mode); 55 my $result = eval { S_ISLNK($self->stat->mode) }; 56 $result = -l $self->fullpath unless defined($result); 57 return $result; 56 58 } 57 59 -
branches/refactoring/lib/Brackup/Root.pm
r69 r76 6 6 use Brackup::Dict::SQLite; 7 7 use File::Temp qw(tempfile); 8 use IPC::Open2; 9 use Symbol; 8 10 9 11 sub new { … … 185 187 unless -s $tmpfn == length $$data; 186 188 187 my ($etmpfh, $etmpfn) = tempfile(); 188 189 system($self->gpg_path, $self->gpg_args, 190 "--recipient", $gpg_rcpt, 191 "--trust-model=always", 192 "--batch", 193 "--encrypt", 194 "--output=$etmpfn", 195 "--yes", $tmpfn) 196 and die "Failed to run gpg: $!\n"; 197 open (my $enc_fh, $etmpfn) or die "Failed to open $etmpfn: $!\n"; 198 return do { local $/; <$enc_fh>; }; 189 my $cout = Symbol::gensym(); 190 my $cin = Symbol::gensym(); 191 192 my $pid = IPC::Open2::open2($cout, $cin, 193 $self->gpg_path, $self->gpg_args, 194 "--recipient", $gpg_rcpt, 195 "--trust-model=always", 196 "--batch", 197 "--encrypt", 198 "--output=-", # Send output to stdout 199 "--yes", 200 $tmpfn 201 ); 202 203 binmode $cout; 204 205 my $ret = do { local $/; <$cout>; }; 206 207 waitpid($pid, 0); 208 die "GPG failed: $!" if $? != 0; # If gpg return status is non-zero 209 210 return $ret; 199 211 } 200 212 -
branches/refactoring/lib/Brackup/Target/Filesystem.pm
r69 r76 9 9 my $self = $class->SUPER::new($confsec); 10 10 $self->{path} = $confsec->path_value("path"); 11 $self->{nocolons} = $confsec->value("no_filename_colons"); 12 $self->{nocolons} = ($^O eq 'MSWin32') unless defined $self->{nocolons}; # LAME: Make it work on Windows 11 13 return $self; 12 14 } … … 35 37 my $fulldig = $dig; 36 38 $dig =~ s/^\w+://; # remove the "hashtype:" from beginning 39 $fulldig =~ s/:/./g if $self->{nocolons}; # Convert colons to dots if we've been asked to 37 40 while (length $dig && @parts < 4) { 38 41 $dig =~ s/^(.{1,4})//; … … 80 83 } 81 84 open (my $fh, ">$path") or die "Failed to open $path for writing: $!\n"; 85 binmode($fh); 82 86 my $chunkref = $chunk->chunkref; 83 87 print $fh $$chunkref; … … 86 90 my $actual_size = -s $path; 87 91 my $expected_size = length $$chunkref; 92 unless (defined($actual_size)) { 93 die "Chunk output file $path does not exist. Do you need to set no_filename_colons=1?"; 94 } 88 95 unless ($actual_size == $expected_size) { 89 die "Chunk was written to disk wrong: size is $actual_size, expecting $expected_size\n";96 die "Chunk $path was written to disk wrong: size is $actual_size, expecting $expected_size\n"; 90 97 } 91 98
