CGI-Ex-Recipes

 view release on metacpan or  search on metacpan

erecipes/perl/lib/CGI/Ex/Recipes/Install.pm  view on Meta::CPAN

                    my $dest_dir = $File::Find::dir;
                    $dest_dir =~s/^$src/$dest/;
                    print "Copying $file $/"
                         ."to:     $file_dest" . $/;
                    if ( !-e $dest_dir ){ mkpath($dest_dir)  }
                    if (  -d $file     ){ mkpath($file_dest) }
                    if ( !-d $file     ){
                        copy( $file, $file_dest) or die "Copy failed: $!";
                        
                        if($file_dest =~/\.(pl|cgi)$/) {
                            chmod 0755,$file_dest and change_shebang_sitepackage_and_siteroot($file_dest);
                        }elsif($file_dest =~/(httpd\.conf)$/){
                            my $fh = IO::File->new("< $file_dest");
                            my @lines;
                            ( $fh->binmode and @lines =  $fh->getlines and $fh->close ) || die $!;
                            foreach ( 0 .. @lines-1 ) {
                               $lines[$_] =~ s|#Include (.*?)|#Include $dest|;
                                $lines[$_] =~ s|Directory "(.*?)"|Directory "$dest"| ;
                                $lines[$_] =~ s|PerlRequire\s+(.*?)/perl/bin/startup.pl|PerlRequire $dest/perl/bin/startup.pl|;

                            }
                            $fh = IO::File->new("> $file_dest");     
                            $fh->binmode and $fh->print(@lines) and $fh->close;
                        }
                        
                    }
                        #make (tmp|conf|logs|data|files) and below world writable so the server can write there
                        #TODO:think about a safer/smarter way
                        chmod 0777,$file_dest
                            if($file_dest =~/(tmp|conf|logs|data|files)/);
                        #TODO:REMEMBER to write a script which will change permissions as needed
                    #sleep 1;

                }
    
            },
            no_chdir => 1,
        },
        $src



( run in 0.221 second using v1.01-cache-2.11-cpan-496ff517765 )