[21709] | 1 | use File::Basename;
|
---|
| 2 | do "$ENV{'TASK_HOME'}/lib.pl";
|
---|
| 3 |
|
---|
| 4 | die "Could not determine your operating system"
|
---|
| 5 | unless ( $^O =~ "linux|darwin|MSWin32" );
|
---|
| 6 |
|
---|
| 7 | #arguments
|
---|
| 8 | our $action = "";
|
---|
| 9 |
|
---|
| 10 | #intervening variables
|
---|
| 11 | our $prefix = "";
|
---|
| 12 | our $release_dir = "";
|
---|
| 13 | our $rk = "";
|
---|
| 14 | our $snapshot_id = "";
|
---|
| 15 | our $branch_path = "";
|
---|
| 16 | our $major_version = 0;
|
---|
| 17 |
|
---|
| 18 | if ( exists $ARGV[0] ) {
|
---|
| 19 | $action = $ARGV[0];
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | if ( exists $ARGV[1] ) {
|
---|
| 23 | die "too many arguments to snapshot task\n";
|
---|
| 24 | }
|
---|
| 25 |
|
---|
[21723] | 26 | #default data dir
|
---|
| 27 | if ( ! exists $ENV{'DATA_DIR'} ) {
|
---|
| 28 | $ENV{'DATA_DIR'} = "$ENV{'HOME'}/snapshots";
|
---|
| 29 | }
|
---|
| 30 |
|
---|
[21709] | 31 | #choose the parameters of the build based on the task name
|
---|
| 32 | if ( $ENV{'TASK_NAME'} =~ "gs2-(caveat|stable)" ) {
|
---|
| 33 | $major_version = 2;
|
---|
| 34 | $prefix="2s";
|
---|
| 35 | $rk="rk2";
|
---|
| 36 | } elsif ( $ENV{'TASK_NAME'} =~ "gs3-(caveat|stable)" ) {
|
---|
| 37 | $major_version = 3;
|
---|
| 38 | $prefix="3s";
|
---|
| 39 | $rk="rk3";
|
---|
| 40 | } elsif ( $ENV{'TASK_NAME'} =~ "gs2-src-(caveat|stable)" ) {
|
---|
| 41 | $major_version = 2;
|
---|
| 42 | $prefix="2s";
|
---|
| 43 | $rk="sork2";
|
---|
| 44 | } elsif ( $ENV{'TASK_NAME'} =~ "gs3-src-(caveat|stable)" ) {
|
---|
| 45 | $major_version = 3;
|
---|
| 46 | $prefix="3s";
|
---|
| 47 | $rk="sork3";
|
---|
| 48 | } elsif ( $ENV{'TASK_NAME'} =~ "gs2-cd-(caveat|stable)" ) {
|
---|
| 49 | $major_version = 2;
|
---|
| 50 | $prefix="2s";
|
---|
| 51 | $rk="cdrk2";
|
---|
| 52 | } elsif ( $ENV{'TASK_NAME'} =~ "dec-(caveat|stable)" ) {
|
---|
| 53 | $prefix="";
|
---|
| 54 | $rk="derk";
|
---|
| 55 | } else {
|
---|
| 56 | die "unrecognised task name '$ENV{'TASK_NAME'}'\n";
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | #setup based on mode
|
---|
| 60 | if ( $ENV{'TASK_NAME'} =~ "caveat\$" ) {
|
---|
| 61 | $ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/caveat-emptor";
|
---|
| 62 |
|
---|
[21773] | 63 | if ( $major_version == 2 ) {
|
---|
| 64 | $ENV{'snapshot_id2'} = `wget -O - http://www.greenstone.org/next-release.txt`;
|
---|
| 65 | chomp($ENV{'snapshot_id2'});
|
---|
| 66 | } else {
|
---|
| 67 | $ENV{'snapshot_id3'} = `wget -O - http://www.greenstone.org/next-release-greenstone3.txt`;
|
---|
| 68 | chomp($ENV{'snapshot_id3'});
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[21709] | 71 | #change the filenames to have the date in them
|
---|
| 72 | $ENV{'munges'} = "s/$ENV{'snapshot_id2'}/$ENV{'snapshot_id2'}-candidate-" . get_date() . "/g ";
|
---|
| 73 | $ENV{'munges'} .= "s/$ENV{'snapshot_id3'}/$ENV{'snapshot_id3'}-candidate-" . get_date() . "/g";
|
---|
| 74 |
|
---|
| 75 | #set the path to server.exe
|
---|
| 76 | $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/caveat-emptor/server-$ENV{'snapshot_id2'}-candidate-" . get_date() . ".exe";
|
---|
| 77 |
|
---|
| 78 | } else {
|
---|
| 79 | if ( $ENV{'TASK_NAME'} =~ "stable\$" ) {
|
---|
[21730] | 80 | $ENV{'BRANCH_PATH'}="tags/stable";
|
---|
[21723] | 81 |
|
---|
| 82 | #dont proceed if main/stable is old
|
---|
| 83 | #get last changed date from svn
|
---|
[21730] | 84 | open( INFO, "svn info http://svn.greenstone.org/main/$ENV{'BRANCH_PATH'}|" )
|
---|
[21723] | 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";
|
---|
| 107 | }
|
---|
[21709] | 108 | }
|
---|
| 109 | $ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/release-snapshots";
|
---|
| 110 |
|
---|
| 111 | #set the path to server.exe
|
---|
| 112 | $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/release-snapshots/server-\$\\\{version\\\}.exe";
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | #always rename the log not to clash with other files on puka
|
---|
[21723] | 116 | $ENV{'munges'} = $ENV{'munges'} . " s/\.out/-" . get_date() . "-log.txt/";
|
---|
[21709] | 117 |
|
---|
[21723] | 118 |
|
---|
| 119 |
|
---|
[21709] | 120 | #choose a snapshot ID
|
---|
| 121 | if ( exists $ENV{'snapshot_id2'} && $major_version == 2 ) {
|
---|
| 122 | $snapshot_id = $ENV{'snapshot_id2'};
|
---|
| 123 | } elsif ( exists $ENV{'snapshot_id3'} && $major_version == 3 ) {
|
---|
| 124 | $snapshot_id = $ENV{'snapshot_id3'};
|
---|
| 125 | } else {
|
---|
| 126 | $snapshot_id = gen_snapshot_id($prefix);
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | #set a release directory
|
---|
| 130 | $release_dir = "$ENV{'DATA_DIR'}/$ENV{'TASK_NAME'}/from-" . get_date();
|
---|
| 131 |
|
---|
| 132 | print "creating a snapshot release\n";
|
---|
| 133 | print "release id : $snapshot_id\n";
|
---|
| 134 | print "release dir: $release_dir\n";
|
---|
| 135 |
|
---|
| 136 | if ( $action eq "create" ) {
|
---|
| 137 | create();
|
---|
| 138 | } elsif ( $action eq "upload" ) {
|
---|
| 139 | upload();
|
---|
| 140 | } elsif ( $action eq "all" || !$action ) {
|
---|
| 141 | create();
|
---|
| 142 | upload();
|
---|
| 143 | } else {
|
---|
| 144 | die "bad snapshot action\n";
|
---|
| 145 | }
|
---|
| 146 |
|
---|