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

Last change on this file since 21774 was 21774, checked in by oranfry, 12 years ago

different method for uploading

File size: 4.1 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#default identity dir
32if ( ! exists $ENV{'IDENTITY_DIR'} ) {
33 $ENV{'IDENTITY_DIR'} = "$ENV{'HOME'}/.ssh";
34}
35
36#choose the parameters of the build based on the task name
37if ( $ENV{'TASK_NAME'} =~ "gs2-(caveat|stable)" ) {
38 $major_version = 2;
39 $prefix="2s";
40 $rk="rk2";
41} elsif ( $ENV{'TASK_NAME'} =~ "gs3-(caveat|stable)" ) {
42 $major_version = 3;
43 $prefix="3s";
44 $rk="rk3";
45} elsif ( $ENV{'TASK_NAME'} =~ "gs2-src-(caveat|stable)" ) {
46 $major_version = 2;
47 $prefix="2s";
48 $rk="sork2";
49} elsif ( $ENV{'TASK_NAME'} =~ "gs3-src-(caveat|stable)" ) {
50 $major_version = 3;
51 $prefix="3s";
52 $rk="sork3";
53} elsif ( $ENV{'TASK_NAME'} =~ "gs2-cd-(caveat|stable)" ) {
54 $major_version = 2;
55 $prefix="2s";
56 $rk="cdrk2";
57} elsif ( $ENV{'TASK_NAME'} =~ "dec-(caveat|stable)" ) {
58 $prefix="";
59 $rk="derk";
60} else {
61 die "unrecognised task name '$ENV{'TASK_NAME'}'\n";
62}
63
64#setup based on mode
65if ( $ENV{'TASK_NAME'} =~ "caveat\$" ) {
66 $ENV{'SNAPSHOT_MODE'} = "caveat";
67
68 if ( $major_version == 2 ) {
69 $ENV{'snapshot_id2'} = `wget -O - http://www.greenstone.org/next-release.txt`;
70 chomp($ENV{'snapshot_id2'});
71 } else {
72 $ENV{'snapshot_id3'} = `wget -O - http://www.greenstone.org/next-release-greenstone3.txt`;
73 chomp($ENV{'snapshot_id3'});
74 }
75
76 #change the filenames to have the date in them
77 $ENV{'munges'} = "s/$ENV{'snapshot_id2'}/$ENV{'snapshot_id2'}-candidate-" . get_date() . "/g ";
78 $ENV{'munges'} .= "s/$ENV{'snapshot_id3'}/$ENV{'snapshot_id3'}-candidate-" . get_date() . "/g";
79
80 #set the path to server.exe
81 $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/caveat-emptor/server-$ENV{'snapshot_id2'}-candidate-" . get_date() . ".exe";
82
83} elsif ( $ENV{'TASK_NAME'} =~ "stable\$" ) {
84 $ENV{'SNAPSHOT_MODE'} = "stable";
85 $ENV{'BRANCH_PATH'} = "tags/stable";
86
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;
97 }
98 }
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 }
113
114 #set the path to server.exe
115 $ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/release-snapshots/server-\$\\\{version\\\}.exe";
116}
117
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
123#always rename the log not to clash with other files on puka
124$ENV{'munges'} = $ENV{'munges'} . " s/\.out/-" . get_date() . "-log.txt/";
125
126#choose a snapshot ID
127if ( exists $ENV{'snapshot_id2'} && $major_version == 2 ) {
128 $snapshot_id = $ENV{'snapshot_id2'};
129} elsif ( exists $ENV{'snapshot_id3'} && $major_version == 3 ) {
130 $snapshot_id = $ENV{'snapshot_id3'};
131} else {
132 $snapshot_id = gen_snapshot_id($prefix);
133}
134
135#set a release directory
136$release_dir = "$ENV{'DATA_DIR'}/$ENV{'TASK_NAME'}/from-" . get_date();
137
138print "creating a snapshot release\n";
139print "release id : $snapshot_id\n";
140print "release dir: $release_dir\n";
141
142if ( $action eq "create" ) {
143 create();
144} elsif ( $action eq "upload" ) {
145 upload();
146} elsif ( $action eq "all" || !$action ) {
147 create();
148 upload();
149} else {
150 die "bad snapshot action\n";
151}
152
Note: See TracBrowser for help on using the repository browser.