Changeset 21774


Ignore:
Timestamp:
2010-03-09T15:57:52+13:00 (11 years ago)
Author:
oranfry
Message:

different method for uploading

Location:
other-projects/nightly-tasks/snapshot/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • other-projects/nightly-tasks/snapshot/trunk/lib.pl

    r21709 r21774  
    9393
    9494    if ( ! -d "$release_dir/products" ) {
    95         die "error: products directory doesn't exist, exiting\n";
     95        die "error: products directory doesn't exist, exiting. (Well, not that exciting, a bit of a downer really...)";
    9696    }
     97
     98    #copy products to a temporary folder, giving them their new names
     99        if ( ! -d "$release_dir/uploads" ) {
     100        system( "rm -rf '$release_dir/uploads'" );
     101    }
     102    mkdir "$release_dir/uploads";
    97103
    98104    @files = <$release_dir/products/*>;
     
    100106    for my $file ( @files ) {
    101107        my $filename = basename($file);
    102         if ( !$only_upload || $filename =~ $only_upload ) {
     108        #munge
     109        for my $m ( @munges ) {
     110            $doit="\$filename =~ $m"; eval "$doit";
     111        }
    103112
    104             #munge
    105             for my $m ( @munges ) {
    106                 $doit="\$filename =~ $m"; eval "$doit";
    107             }
    108 
    109             #upload
    110             print "Uploading '" . basename($file) . "' to '$filename'\n";
    111             my $command = "scp";
    112             if ( $^O eq "MSWin32" ) {
    113                 $command = "pscp";
    114             }
    115             if ( exists $ENV{'UPLOAD_IDENTITY_FILE'} ) {
    116                 $command .= " -i \"$ENV{'UPLOAD_IDENTITY_FILE'}\"";
    117             }
    118             $command .= " \"$file\" \"$ENV{'UPLOAD_DIR'}/$filename\"";
    119             system($command);
    120 
    121         } else {
    122             print "Skipping upload of '$filename'\n";
    123         }
     113        #upload
     114        print "Will upload '" . basename($file) . "' to '$filename'\n";
     115        system( "cp '$file' '$release_dir/uploads/$filename'" );
    124116    }
     117    my $command = "cd $release_dir/uploads && tar -cz * | ";
     118    $command .= ($^O eq "MSWin32" ? "putty" : "ssh");
     119    $command .= " -i '$ENV{'IDENTITY_FILE'}' nzdl\@puka.cs.waikato.ac.nz";
     120    #system("$command");
     121    print "$command\n";
    125122}
  • other-projects/nightly-tasks/snapshot/trunk/task.pl

    r21773 r21774  
    2727if ( ! exists $ENV{'DATA_DIR'} ) {
    2828    $ENV{'DATA_DIR'} = "$ENV{'HOME'}/snapshots";
     29}
     30
     31#default identity dir
     32if ( ! exists $ENV{'IDENTITY_DIR'} ) {
     33    $ENV{'IDENTITY_DIR'} = "$ENV{'HOME'}/.ssh";
    2934}
    3035
     
    5964#setup based on mode
    6065if ( $ENV{'TASK_NAME'} =~ "caveat\$" ) {
    61     $ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/caveat-emptor";
     66    $ENV{'SNAPSHOT_MODE'} = "caveat";
    6267
    6368    if ( $major_version == 2 ) {
     
    7681    $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/caveat-emptor/server-$ENV{'snapshot_id2'}-candidate-" . get_date() . ".exe";
    7782
    78 } else {
    79     if ( $ENV{'TASK_NAME'} =~ "stable\$" ) {
    80         $ENV{'BRANCH_PATH'}="tags/stable";
     83} elsif ( $ENV{'TASK_NAME'} =~ "stable\$" ) {
     84    $ENV{'SNAPSHOT_MODE'} = "stable";
     85    $ENV{'BRANCH_PATH'} = "tags/stable";
    8186
    82         #dont proceed if main/stable is old
    83         #get last changed date from svn
    84         open( INFO, "svn info http://svn.greenstone.org/main/$ENV{'BRANCH_PATH'}|" )
    85             or die "Cant determine age of stable tag";
    86         my $changed_date;
    87         while ( my $line = <INFO>) {
    88             chomp($line);
    89             if ( $line =~ /^Last Changed Date:/ ) {
    90                 $changed_date = $line;
    91                 break;
    92             }
    93         }
    94         close(INFO);
    95         #change the format
    96         $changed_date =~ s/.*: ([^ ]+) .*/\1/g;
    97         if ( $changed_date !~ /^20[0-9]{2}-[0-9]{2}-[0-9]{2}$/ ) {
    98             die "Cant determine age of stable tag";
    99         }
    100         $changed_date =~ s/-/./g;
    101         #check if main/stable is new
    102         if ( $changed_date ne get_date() ) {
    103             print "main/stable is old, will not create snapshot\n";
    104             exit;
    105         } else {
    106             print "main/stable is fresh, will create snapshot\n";
     87    #dont proceed if main/stable is old
     88    #get last changed date from svn
     89    open( INFO, "svn info http://svn.greenstone.org/main/$ENV{'BRANCH_PATH'}|" )
     90        or die "Cant determine age of stable tag";
     91    my $changed_date;
     92    while ( my $line = <INFO>) {
     93        chomp($line);
     94        if ( $line =~ /^Last Changed Date:/ ) {
     95            $changed_date = $line;
     96            break;
    10797        }
    10898    }
    109     $ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/release-snapshots";
     99    close(INFO);
     100    #change the format
     101    $changed_date =~ s/.*: ([^ ]+) .*/\1/g;
     102    if ( $changed_date !~ /^20[0-9]{2}-[0-9]{2}-[0-9]{2}$/ ) {
     103        die "Cant determine age of stable tag";
     104    }
     105    $changed_date =~ s/-/./g;
     106    #check if main/stable is new
     107    if ( $changed_date ne get_date() ) {
     108        print "main/stable is old, will not create snapshot\n";
     109        exit;
     110    } else {
     111        print "main/stable is fresh, will create snapshot\n";
     112    }
    110113
    111114    #set the path to server.exe
     
    113116}
    114117
     118#use the  correct key for uploading
     119$ENV{'IDENTITY_FILE'} =
     120    "$ENV{'IDENTITY_DIR'}/upload-" . $ENV{'SNAPSHOT_MODE'} . ($^O eq "MSWin32" ? ".ppk" : "");
     121
     122
    115123#always rename the log not to clash with other files on puka
    116124$ENV{'munges'} = $ENV{'munges'} . " s/\.out/-" . get_date() . "-log.txt/";
    117 
    118 
    119125
    120126#choose a snapshot ID
Note: See TracChangeset for help on using the changeset viewer.