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

Last change on this file since 21723 was 21723, checked in by oranfry, 14 years ago

stable not to proceed unless tag is fresh

File size: 4.0 KB
Line 
1use File::Basename;
2do "$ENV{'TASK_HOME'}/lib.pl";
3
4die "Could not determine your operating system"
5 unless ( $^O =~ "linux|darwin|MSWin32" );
6
7#arguments
8our $action = "";
9
10#intervening variables
11our $prefix = "";
12our $release_dir = "";
13our $rk = "";
14our $snapshot_id = "";
15our $branch_path = "";
16our $major_version = 0;
17
18if ( exists $ARGV[0] ) {
19 $action = $ARGV[0];
20}
21
22if ( exists $ARGV[1] ) {
23 die "too many arguments to snapshot task\n";
24}
25
26#default data dir
27if ( ! exists $ENV{'DATA_DIR'} ) {
28 $ENV{'DATA_DIR'} = "$ENV{'HOME'}/snapshots";
29}
30
31#choose the parameters of the build based on the task name
32if ( $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
60if ( $ENV{'TASK_NAME'} =~ "caveat\$" ) {
61 $ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/caveat-emptor";
62 $ENV{'snapshot_id2'}=`ssh nzdl\@puka.cs.waikato.ac.nz cat /greenstone/greenstone.org/base/next-release.txt`;
63
64 #TODO: generalise this for all oses!
65 chomp($ENV{'snapshot_id2'});
66 $ENV{'snapshot_id3'}=`ssh nzdl\@puka.cs.waikato.ac.nz cat /greenstone/greenstone.org/base/next-release-greenstone3.txt`;
67 chomp($ENV{'snapshot_id3'});
68
69 #change the filenames to have the date in them
70 $ENV{'munges'} = "s/$ENV{'snapshot_id2'}/$ENV{'snapshot_id2'}-candidate-" . get_date() . "/g ";
71 $ENV{'munges'} .= "s/$ENV{'snapshot_id3'}/$ENV{'snapshot_id3'}-candidate-" . get_date() . "/g";
72
73 #set the path to server.exe
74 $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/caveat-emptor/server-$ENV{'snapshot_id2'}-candidate-" . get_date() . ".exe";
75
76} else {
77 if ( $ENV{'TASK_NAME'} =~ "stable\$" ) {
78 $ENV{'BRANCH_PATH'}="stable";
79
80 #dont proceed if main/stable is old
81 #get last changed date from svn
82 open( INFO, "svn info http://svn.greenstone.org/main/stable|" )
83 or die "Cant determine age of stable tag";
84 my $changed_date;
85 while ( my $line = <INFO>) {
86 chomp($line);
87 if ( $line =~ /^Last Changed Date:/ ) {
88 $changed_date = $line;
89 break;
90 }
91 }
92 close(INFO);
93 #change the format
94 $changed_date =~ s/.*: ([^ ]+) .*/\1/g;
95 if ( $changed_date !~ /^20[0-9]{2}-[0-9]{2}-[0-9]{2}$/ ) {
96 die "Cant determine age of stable tag";
97 }
98 $changed_date =~ s/-/./g;
99 #check if main/stable is new
100 if ( $changed_date ne get_date() ) {
101 print "main/stable is old, will not create snapshot\n";
102 exit;
103 } else {
104 print "main/stable is fresh, will create snapshot\n";
105 }
106 }
107 $ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/release-snapshots";
108
109 #set the path to server.exe
110 $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/release-snapshots/server-\$\\\{version\\\}.exe";
111}
112
113#always rename the log not to clash with other files on puka
114$ENV{'munges'} = $ENV{'munges'} . " s/\.out/-" . get_date() . "-log.txt/";
115
116
117
118#choose a snapshot ID
119if ( exists $ENV{'snapshot_id2'} && $major_version == 2 ) {
120 $snapshot_id = $ENV{'snapshot_id2'};
121} elsif ( exists $ENV{'snapshot_id3'} && $major_version == 3 ) {
122 $snapshot_id = $ENV{'snapshot_id3'};
123} else {
124 $snapshot_id = gen_snapshot_id($prefix);
125}
126
127#set a release directory
128$release_dir = "$ENV{'DATA_DIR'}/$ENV{'TASK_NAME'}/from-" . get_date();
129
130print "creating a snapshot release\n";
131print "release id : $snapshot_id\n";
132print "release dir: $release_dir\n";
133
134if ( $action eq "create" ) {
135 create();
136} elsif ( $action eq "upload" ) {
137 upload();
138} elsif ( $action eq "all" || !$action ) {
139 create();
140 upload();
141} else {
142 die "bad snapshot action\n";
143}
144
Note: See TracBrowser for help on using the repository browser.