Changeset 21762


Ignore:
Timestamp:
2010-03-03T15:02:08+13:00 (12 years ago)
Author:
kjdon
Message:

creating a cd currently copies all svn directories. added a cp_r_nosvn method to util, and use that when copying stuff to cd

Location:
main/trunk/greenstone2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/exportcol.pl

    r21664 r21762  
    281281    }
    282282
    283     &util::cp_r ($webdir, $gsdldir);
    284     &util::cp_r ($macrosdir, $gsdldir);
    285     &util::cp_r ($mappingsdir, $gsdldir);
     283    &util::cp_r_nosvn ($webdir, $gsdldir);
     284    &util::cp_r_nosvn ($macrosdir, $gsdldir);
     285    &util::cp_r_nosvn ($mappingsdir, $gsdldir);
    286286    &util::cp ($maincfg, $etcdir);
    287287    &util::cp ($serverexe, $gsdldir);
     
    318318
    319319    &util::mk_all_dir ($newcoldir);
    320     &util::cp_r ($colindexdir, $newcoldir);
     320    &util::cp_r_nosvn ($colindexdir, $newcoldir);
    321321    &util::rename_ldb_or_bdb_file(&util::filename_cat ($newcoldir, "index", "text", $c));
    322     &util::cp_r ($coletcdir, $newcoldir);
    323     &util::cp_r ($colmacrosdir, $newcoldir) if (-e $colmacrosdir);
    324     &util::cp_r ($colimagesdir, $newcoldir) if (-e $colimagesdir);
    325     &util::cp_r ($colscriptdir, $newcoldir) if (-e $colscriptdir);
    326     &util::cp_r ($coljavadir, $newcoldir) if (-e $coljavadir);
    327     &util::cp_r ($colstyledir, $newcoldir) if (-e $colstyledir);
    328     &util::cp_r ($colflashdir, $newcoldir) if (-e $colflashdir);
     322    &util::cp_r_nosvn ($coletcdir, $newcoldir);
     323    &util::cp_r_nosvn ($colmacrosdir, $newcoldir) if (-e $colmacrosdir);
     324    &util::cp_r_nosvn ($colimagesdir, $newcoldir) if (-e $colimagesdir);
     325    &util::cp_r_nosvn ($colscriptdir, $newcoldir) if (-e $colscriptdir);
     326    &util::cp_r_nosvn ($coljavadir, $newcoldir) if (-e $coljavadir);
     327    &util::cp_r_nosvn ($colstyledir, $newcoldir) if (-e $colstyledir);
     328    &util::cp_r_nosvn ($colflashdir, $newcoldir) if (-e $colflashdir);
    329329
    330330    # now we need to check the collect.cfg file to make sure it's public
  • main/trunk/greenstone2/perllib/util.pm

    r21719 r21762  
    248248    }
    249249}
     250# recursively copies a file or group of files
     251# syntax: cp_r (sourcefiles, destination directory)
     252# destination must be a directory - to copy one file to
     253# another use cp instead
     254sub cp_r_nosvn {
     255    my $dest = pop (@_);
     256    my (@srcfiles) = @_;
     257
     258    # a few sanity checks
     259    if (scalar (@srcfiles) == 0) {
     260    print STDERR "util::cp_r no destination directory given\n";
     261    return;
     262    } elsif (-f $dest) {
     263    print STDERR "util::cp_r destination must be a directory\n";
     264    return;
     265    }
     266   
     267    # create destination directory if it doesn't exist already
     268    if (! -d $dest) {
     269    my $store_umask = umask(0002);
     270    mkdir ($dest, 0777);
     271    umask($store_umask);
     272    }
     273
     274    # copy the files
     275    foreach my $file (@srcfiles) {
     276
     277    if (!-e $file) {
     278        print STDERR "util::cp_r $file does not exist\n";
     279
     280    } elsif (-d $file) {
     281        # make the new directory
     282        my ($filename) = $file =~ /([^\\\/]*)$/;
     283        $dest = &util::filename_cat ($dest, $filename);
     284        my $store_umask = umask(0002);
     285        mkdir ($dest, 0777);
     286        umask($store_umask);
     287
     288        # get the contents of this directory
     289        if (!opendir (INDIR, $file)) {
     290        print STDERR "util::cp_r could not open directory $file\n";
     291        } else {
     292        my @filedir = readdir (INDIR);
     293        closedir (INDIR);
     294        foreach my $f (@filedir) {
     295            next if $f =~ /^\.\.?$/;
     296            next if $f =~ /^\.svn$/;
     297            # copy all the files in this directory
     298            my $ff = &util::filename_cat ($file, $f);
     299            &cp_r ($ff, $dest);
     300        }
     301        }
     302
     303    } else {
     304        &cp($file, $dest);
     305    }
     306    }
     307}
    250308
    251309# copies a directory and its contents, excluding subdirectories, into a new directory
Note: See TracChangeset for help on using the changeset viewer.