8 use File::Path qw(make_path);
9 use File::Basename qw (fileparse dirname);
10 use File::Copy::Recursive qw(fcopy dirmove);
11 use File::Temp qw (tempdir);
17 #rule to match git directorys
18 my $git = File::Find::Rule->directory
24 my $file_rule = File::Find::Rule->file();
27 my @files = File::Find::Rule->or( $git, $file_rule )
31 my $tempdir = tempdir( CLEANUP => 0 );
33 #initialize template toolkit
35 my $template = Template->new;
37 foreach my $file (@files) {
38 next if $file =~ /^$out_dir/;
39 next if $file =~ /$0$/;
40 if ($file =~ /\.tt2$/) {
42 $template->process($file, undef, \$output)
43 || die "Could not process file \"$file\": $!";
45 my ($name,$path,$suffix) = fileparse($file,qw (.tt2));
46 make_path("$tempdir/$path") unless -d "$tempdir/$path";
47 open (my $fh, '>', "$tempdir/$path/$name")
48 or die "Could not write to $file: $!";
52 fcopy ($file, "$tempdir/$file") or die "Could not copy $file to $tempdir/$file: $!";
58 mv ($out_dir, dirname($out_dir) . ".bak")
59 or die "Could not move $out_dir to $out_dir.bak: $!";
61 dirmove ($tempdir, "$out_dir")
62 or die "Could not move $tempdir to $out_dir: $!";