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

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

bringing across the snapshot task

File size: 3.3 KB
RevLine 
[21709]1use File::Basename;
2do "$ENV{'TASK_HOME'}/lib.pl";
3
4#check key environment vars are set
5die "Please set a DATA_DIR in the nightly snapshot environment\n"
6 if ! exists $ENV{'DATA_DIR'};
7die "Could not determine your operating system"
8 unless ( $^O =~ "linux|darwin|MSWin32" );
9
10#arguments
11our $action = "";
12
13#intervening variables
14our $prefix = "";
15our $release_dir = "";
16our $rk = "";
17our $snapshot_id = "";
18our $branch_path = "";
19our $major_version = 0;
20
21if ( exists $ARGV[0] ) {
22 $action = $ARGV[0];
23}
24
25if ( exists $ARGV[1] ) {
26 die "too many arguments to snapshot task\n";
27}
28
29#choose the parameters of the build based on the task name
30if ( $ENV{'TASK_NAME'} =~ "gs2-(caveat|stable)" ) {
31 $major_version = 2;
32 $prefix="2s";
33 $rk="rk2";
34} elsif ( $ENV{'TASK_NAME'} =~ "gs3-(caveat|stable)" ) {
35 $major_version = 3;
36 $prefix="3s";
37 $rk="rk3";
38} elsif ( $ENV{'TASK_NAME'} =~ "gs2-src-(caveat|stable)" ) {
39 $major_version = 2;
40 $prefix="2s";
41 $rk="sork2";
42} elsif ( $ENV{'TASK_NAME'} =~ "gs3-src-(caveat|stable)" ) {
43 $major_version = 3;
44 $prefix="3s";
45 $rk="sork3";
46} elsif ( $ENV{'TASK_NAME'} =~ "gs2-cd-(caveat|stable)" ) {
47 $major_version = 2;
48 $prefix="2s";
49 $rk="cdrk2";
50} elsif ( $ENV{'TASK_NAME'} =~ "dec-(caveat|stable)" ) {
51 $prefix="";
52 $rk="derk";
53} else {
54 die "unrecognised task name '$ENV{'TASK_NAME'}'\n";
55}
56
57#setup based on mode
58if ( $ENV{'TASK_NAME'} =~ "caveat\$" ) {
59 $ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/caveat-emptor";
60
61 if ( $major_version == 2 ) {
62 $ENV{'snapshot_id2'} = `wget -O - http://www.greenstone.org/next-release.txt 2>nul`;
63 chomp($ENV{'snapshot_id2'});
64 } else {
65 $ENV{'snapshot_id3'} = `wget -O - http://www.greenstone.org/next-release-greenstone3.txt 2>nul`;
66 chomp($ENV{'snapshot_id3'});
67 }
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 $ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/release-snapshots";
81
82 #set the path to server.exe
83 $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/release-snapshots/server-\$\\\{version\\\}.exe";
84}
85
86#always rename the log not to clash with other files on puka
87$ENV{'munges'} = $ENV{'munges'} . " s/\.out/-" . get_date() . "-" . $^O . "-log.txt/";
88
89#choose a snapshot ID
90if ( exists $ENV{'snapshot_id2'} && $major_version == 2 ) {
91 $snapshot_id = $ENV{'snapshot_id2'};
92} elsif ( exists $ENV{'snapshot_id3'} && $major_version == 3 ) {
93 $snapshot_id = $ENV{'snapshot_id3'};
94} else {
95 $snapshot_id = gen_snapshot_id($prefix);
96}
97
98#set a release directory
99$release_dir = "$ENV{'DATA_DIR'}/$ENV{'TASK_NAME'}/from-" . get_date();
100
101print "creating a snapshot release\n";
102print "release id : $snapshot_id\n";
103print "release dir: $release_dir\n";
104
105if ( $action eq "create" ) {
106 create();
107} elsif ( $action eq "upload" ) {
108 upload();
109} elsif ( $action eq "all" || !$action ) {
110 create();
111 upload();
112} else {
113 die "bad snapshot action\n";
114}
115
Note: See TracBrowser for help on using the repository browser.