source: other-projects/nightly-tasks/snapshot/trunk/task.pl@ 29346

Last change on this file since 29346 was 29346, checked in by ak19, 10 years ago

Creating release binaries and not just nightly caveat binaries using envi from now on. Needed because a GS3 release bin generated on windows could not successfully build the lucene demo collection whereas in the caveat it was properly built. Caveat uses envi and release binary process doesn't. And since only the caveats are tested against the tutorials and not release binaries, we want them to go through an identical binary-generation process and have an identical environment when generated. Tested on Windows.

File size: 5.7 KB
Line 
1use File::Basename;
2my $sep = $^O eq "MSWin32" ? "\\" : "/";
3do "$ENV{'TASK_HOME'}/lib.pl";
4
5die "Could not determine your operating system"
6 unless ( $^O =~ "linux|darwin|MSWin32" );
7
8#arguments
9our $action = "";
10
11#intervening variables
12our $prefix = "";
13our $release_dir = "";
14our $rk = "";
15our $snapshot_id = "";
16our $branch_path = "";
17our $major_version = 0;
18
19# for Darwin, specify if this binary is for (Mountain)Lions in the filename, otherwise it's for Leopards
20# http://en.wikipedia.org/wiki/Darwin_(operating_system)
21# darwin11* Lion, darwin12* Mountain Lion, darwin9* and darwin10* are Leopard and Snow Leopard
22my $osversion = "";
23if($^O eq "darwin") {
24 #$osversion=`uname -r | sed 's/\..*$//'`;
25 $osversion=`uname -r`; #$osversion =~ s@\..*$@@;
26 $osversion = ($osversion =~ m@^1[1-9]@i) ? "-Lion" : "";
27}
28
29# if the first arg is a digit, it's the new envi verbosity param. Take it off the array
30my $envi_verbose = shift(@ARGV) if(exists $ARGV[0] && $ARGV[0] =~ m/^\d+$/);
31
32if ( exists $ARGV[0] ) {
33 $action = $ARGV[0];
34}
35
36if ( exists $ARGV[1] ) {
37 die "too many arguments to snapshot task\n";
38}
39
40#default data dir
41if ( ! exists $ENV{'DATA_DIR'} ) {
42 $ENV{'DATA_DIR'} = "$ENV{'HOME'}${sep}snapshots";
43}
44
45#default identity dir
46if ( ! exists $ENV{'IDENTITY_DIR'} ) {
47 $ENV{'IDENTITY_DIR'} = "$ENV{'HOME'}${sep}.ssh";
48}
49
50#choose the parameters of the build based on the task name
51if ( $ENV{'TASK_NAME'} =~ "release" ) { # run as release 306rc1 (or as different as gs-3.06-rc1)
52 if(exists $ARGV[0] && $ARGV[0] =~ m/^(gs-?)?(3|2)\.?\d\d+-?rc\d$/) {
53 create_release($ARGV[0]);
54 exit;
55 } else {
56 die "Run snapshot task with gs<full-version>[rc#]\n";
57 }
58} elsif ( $ENV{'TASK_NAME'} =~ "gs2-(caveat|stable)" ) {
59 $major_version = 2;
60 $prefix="2s";
61 $rk="rk2";
62} elsif ( $ENV{'TASK_NAME'} =~ "gs3-(caveat|stable)" ) {
63 $major_version = 3;
64 $prefix="3s";
65 $rk="rk3";
66} elsif ( $ENV{'TASK_NAME'} =~ "gs2-src-(caveat|stable)" ) {
67 $major_version = 2;
68 $prefix="2s";
69 $rk="sork2";
70} elsif ( $ENV{'TASK_NAME'} =~ "gs3-src-(caveat|stable)" ) {
71 $major_version = 3;
72 $prefix="3s";
73 $rk="sork3";
74} elsif ( $ENV{'TASK_NAME'} =~ "gs2-cd-(caveat|stable)" ) {
75 $major_version = 2;
76 $prefix="2s";
77 $rk="cdrk2";
78} elsif ( $ENV{'TASK_NAME'} =~ "dec-(caveat|stable)" ) {
79 $prefix="";
80 $rk="derk";
81} else {
82 die "unrecognised task name '$ENV{'TASK_NAME'}'\n";
83}
84
85#keep wget/curl base command in a variable
86my $httpRetrieve = $^O eq "darwin" ? "curl" : "wget -O -";
87
88#setup based on mode
89if ( $ENV{'TASK_NAME'} =~ "caveat\$" ) {
90 $ENV{'SNAPSHOT_MODE'} = "caveat";
91
92 if ( $major_version == 2 ) {
93 $ENV{'snapshot_id2'} = `$httpRetrieve http://www.greenstone.org/next-release.txt`;
94 chomp($ENV{'snapshot_id2'});
95 } else {
96 $ENV{'snapshot_id3'} = `$httpRetrieve http://www.greenstone.org/next-release-greenstone3.txt`;
97 chomp($ENV{'snapshot_id3'});
98 }
99
100 #change the filenames to have the date in them
101 my $id2 = $ENV{'snapshot_id2'};
102 (my $id2re = $id2) =~ s@\.@\\.@g; #copy id2 and then change id2re, see http://www.perlmonks.org/?node_id=366431
103
104 my $id3 = $ENV{'snapshot_id3'};
105 (my $id3re = $id3) =~ s@\.@\\.@g;
106
107 $ENV{'munges'} = "s/-$id2re/-$id2-candidate-" . get_date() . "$osversion" . "/g " if ($id2 =~ m/\S/);
108 $ENV{'munges'} .= "s/-$id3re/-$id3-candidate-" . get_date() . "$osversion". "/g" if ($id3 =~ m/\S/);
109 #$ENV{'munges'} = $ENV{'munges'} . " s/\\.dmg\$/$osversion.dmg/";
110
111 # the above generates a list of regex. Have a \D (non-digit) prefixed to the value to be substituted, else
112 # Greenstone-documented-examples-2013.06.18.tar.gz gets changed to Greenstone-documented-examples-2013.06-candidate-<daterepeat of 2013.06.18>.18.tar.gz
113
114 #set the path to server.exe
115 $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/caveat-emptor/latest-server.exe";
116
117} elsif ( $ENV{'TASK_NAME'} =~ "stable\$" ) {
118 $ENV{'SNAPSHOT_MODE'} = "stable";
119 $ENV{'BRANCH_PATH'} = "tags/stable";
120
121 #dont proceed if main/stable is old
122 #get last changed date from svn
123 open( INFO, "svn info http://svn.greenstone.org/main/$ENV{'BRANCH_PATH'}|" )
124 or die "Cant determine age of stable tag";
125 my $changed_date;
126 while ( my $line = <INFO>) {
127 chomp($line);
128 if ( $line =~ /^Last Changed Date:/ ) {
129 $changed_date = $line;
130 break;
131 }
132 }
133 close(INFO);
134 #change the format
135 $changed_date =~ s/.*: ([^ ]+) .*/\1/g;
136 if ( $changed_date !~ /^20[0-9]{2}-[0-9]{2}-[0-9]{2}$/ ) {
137 die "Cant determine age of stable tag";
138 }
139 $changed_date =~ s/-/./g;
140 #check if main/stable is new
141 if ( $changed_date ne get_date() ) {
142 print "main/stable is old, will not create snapshot\n";
143 exit;
144 } else {
145 print "main/stable is fresh, will create snapshot\n";
146 }
147
148 #set the path to server.exe
149 $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/release-snapshots/server-\$\\\{version\\\}.exe";
150}
151
152#use the correct key for uploading
153$ENV{'IDENTITY_FILE'} =
154 "$ENV{'IDENTITY_DIR'}${sep}upload-" . $ENV{'SNAPSHOT_MODE'} . ($^O eq "MSWin32" ? ".ppk" : "");
155
156
157#always rename the log not to clash with other files on puka
158$ENV{'munges'} = $ENV{'munges'} . " s/\\.out\$/-" . get_date() . "-" . $^O . $osversion . "-log.txt/";
159
160#choose a snapshot ID
161if ( exists $ENV{'snapshot_id2'} && $major_version == 2 ) {
162 $snapshot_id = $ENV{'snapshot_id2'};
163} elsif ( exists $ENV{'snapshot_id3'} && $major_version == 3 ) {
164 $snapshot_id = $ENV{'snapshot_id3'};
165} else {
166 $snapshot_id = gen_snapshot_id($prefix);
167}
168
169#set a release directory
170$release_dir = "$ENV{'DATA_DIR'}${sep}$ENV{'TASK_NAME'}${sep}from-" . get_date();
171
172print "creating a snapshot release\n";
173print "release id : $snapshot_id\n";
174print "release dir: $release_dir\n";
175
176if ( $action eq "create" ) {
177 create();
178} elsif ( $action eq "upload" ) {
179 upload();
180} elsif ( $action eq "all" || !$action ) {
181 create();
182 upload();
183} else {
184 die "bad snapshot action\n";
185}
186
Note: See TracBrowser for help on using the repository browser.