Just adding a -r to the cp statement for the docs folder
[koha.git] / buildrelease
1 #!/usr/bin/perl
2
3 my $kohadir=`pwd`;
4 chomp $kohadir;
5 my $kohahtmldir="/koha/koha/koha-html/";
6
7 if (-e "/root/.kohaautobuild.conf") {
8     open C, "/root/.kohaautobuild.conf";
9     while (<C>) {
10         chomp;
11         if (/kohadir=(.*)/) {
12             $kohadir=$1;
13         }
14         if (/kohahtmldir=(.*)/) {
15             $kohahtmldir=$1;
16         }
17     }
18 }
19
20 my $input;
21
22 print qq |
23 ***************************************
24 * Welcome to the Koha Release Builder *
25 ***************************************
26
27 This script will automatically build a release tarball.
28
29 The script assumes that you already have the koha and koha-html modules checked
30 out for the release that you want to build, although it will update the modules
31 before building.
32
33 |;
34 print "\nWhere is the 'koha' cvs module located [$kohadir]: ";
35 chomp($input = <STDIN>);
36 if ($input) {
37     $kohadir=$input;
38 }
39
40
41 print "\nWhere is the 'koha-html' cvs module located [$kohahtmldir]: ";
42 chomp($input = <STDIN>);
43 if ($input) {
44     $kohahtmldir=$input;
45 }
46
47 open (C, ">/root/.kohaautobuild.conf");
48 print C qq|
49 kohadir=$kohadir
50 kohahtmldir=$kohahtmldir
51 |;
52
53 print "\n\nGuessing at next release version.  You may need to enter your SourceForge password...\n";
54 chdir $kohadir;
55 open (CVSLOG, "cvs log buildrelease|");
56 my $symbolicnamessection=0;
57 my $symbolicnames;
58 my $highestversion;
59 my $highestrc;
60 my $released;
61 while (<CVSLOG>) {
62     if (/^symbolic names:/) {
63         $symbolicnamessection=1;
64     }
65     if ($symbolicnamessection && (/^\s+([^:]*):/)) {
66         my $tag=$1;
67         if ($tag=~/R_(.*)/) {
68             my $version='';
69             my $rc=0;
70             my $id=$1;
71             $id=~s/-/\./g;
72             if ($id =~/(.*)RC(.*)/) {
73                 $version=$1;
74                 $rc=$2;
75                 if (versioncompare($version, $highestversion)) {
76                     $highestversion=$version;
77                     $released=0;
78                     $highestrc=$rc;
79                 }
80             } else {
81                 $version=$id;
82                 if (versioncompare($version, $highestversion)) {
83                     $highestversion=$version;
84                     $released=1;
85                     $highestrc=0;
86                 }
87             }
88             $symbolicnames->{$version}->{$rc}=1;
89         }
90     }
91 }
92
93
94 my $releaseversion='';
95 my $currentversion='';
96
97 if ($released) {
98     $releaseversion=($highestversion+1)."RC1";
99     $currentversion=$highestversion;
100 } else {
101     $releaseversion="$highestversion\RC".($highestrc+1);
102     $currentversion="$highestversion\RC$highestrc";
103 }
104
105 print "Current release tag is $currentversion.\n";
106 print "\nWould you like to bump that up to $releaseversion?  [Y]/N: ";
107 chomp($input = <STDIN>);
108 if ($input =~ /^n/i) {
109     print "\nWould you like to rebuild the $currentversion tarball?  Y/[N]: ";
110     chomp($input = <STDIN>);
111     if ($input =~ /^y/i) {
112         $releaseversion=$currentversion;
113         print "\n\n";
114         print "Do not do this if you have released the tarball to anybody, as it will\n";
115         print "overwrite the tag marking the files that were in the tarball.\n\n";
116         print "Confirm that you want to overwrite the tag for $releaseversion? Y/[N]: ";
117         chomp($input = <STDIN>);
118         if ($input =~ /^n/i || $input eq '') {
119             print "\nStopping.  Please re-run buildrelease now.\n";
120             exit;
121         }
122     } else {
123         print "What should the new version be? [$releaseversion]: ";
124         chomp ($input=<STDIN>);
125         if ($input) {
126             $releaseversion=$input;
127         }
128     }
129 }
130
131
132 my $sfuserid='';
133 if ($cvsroot=$ENV{'CVSROOT'}) {
134     $cvsroot=~m#(.*)\@cvs#;
135     $sfuserid=$1;
136 } else {
137     $ENV{'CVS_RSH'}='ssh';
138     print "\nWhat is your userid at SourceForge: ";
139     chomp($input = <STDIN>);
140     if ($input) {
141         $sfuserid=$input;
142     }
143     $ENV{'CVSROOT'}="$sfuserid\@cvs.koha.sourceforge.net:/cvsroot/koha";
144 }
145 my $tagname=$releaseversion;
146 $tagname=~s/\./-/g;
147
148 print qq|
149 Updating the 'koha' CVS files.  You may need to enter your SourceForge password.
150 Using $kohadir.
151 |;
152 chdir($kohadir);
153 system("cvs update");
154 print qq|
155 Tagging koha with tag R_$tagname
156 |;
157 system("cvs tag -F R_$tagname");
158 print qq|
159 Updating the 'koha-html' CVS files.  You may need to enter your SourceForge password.
160 Using $kohahtmldir.
161 |;
162 chdir($kohahtmldir);
163 system("cvs update");
164 print qq|
165 Tagging koha-html with tag R_$tagname
166 |;
167 system("cvs tag -F R_$tagname");
168
169
170
171
172 my $rootdir="/tmp/koha-".$releaseversion;
173 system("rm -rf $rootdir");
174 mkdir ($rootdir, 0700);
175 chdir($rootdir);
176
177 mkdir("intranet-cgi", 0755);
178 mkdir("intranet-html", 0755);
179 mkdir("opac-cgi", 0755);
180 mkdir("opac-html", 0755);
181 mkdir("scripts", 0755);
182 mkdir("scripts/z3950daemon", 0755);
183 mkdir("modules", 0755);
184 mkdir("docs", 0755);
185
186 # Copy all CVS files to intranet-cgi
187 system("cp -a $kohadir/* $rootdir/intranet-cgi");
188
189 # Move C4 to modules directory
190 system("mv $rootdir/intranet-cgi/C4 $rootdir/modules");
191
192 # Move files from intranet-cgi to root of tarball
193 system("mv $rootdir/intranet-cgi/INSTALL $rootdir");
194 system("mv $rootdir/intranet-cgi/ChangeLog $rootdir");
195 system("mv $rootdir/intranet-cgi/Hints $rootdir");
196 system("mv $rootdir/intranet-cgi/LICENSE $rootdir");
197 system("mv $rootdir/intranet-cgi/News $rootdir");
198 system("mv $rootdir/intranet-cgi/README $rootdir");
199 system("mv $rootdir/intranet-cgi/TODO $rootdir");
200 system("mv $rootdir/intranet-cgi/databaseinstall.sh $rootdir");
201 system("mv $rootdir/intranet-cgi/installer.pl $rootdir"); 
202 system("mv $rootdir/intranet-cgi/koha.conf $rootdir");
203 system("mv $rootdir/intranet-cgi/koha.mysql $rootdir");
204 system("mv $rootdir/intranet-cgi/sampledata-1.2 $rootdir");
205 system("gzip -9 $rootdir/sampledata-1.2");
206
207 # Copy files from intranet-cgi to opac-cgi
208 system("cp $rootdir/intranet-cgi/detail.pl $rootdir/opac-cgi");
209 system("cp $rootdir/intranet-cgi/moredetail.pl $rootdir/opac-cgi");
210 system("cp $rootdir/intranet-cgi/search.pl $rootdir/opac-cgi");
211
212
213 # Move files from intranet-cgi to /scripts/ directory
214 system("mv $rootdir/intranet-cgi/telnet $rootdir/scripts");
215 system("mv $rootdir/intranet-cgi/tkperl $rootdir/scripts");
216 system("mv $rootdir/intranet-cgi/translator $rootdir/scripts");
217 system("mv $rootdir/intranet-cgi/updater $rootdir/scripts");
218 system("mv $rootdir/intranet-cgi/misc $rootdir/scripts");
219 system("mv $rootdir/intranet-cgi/acqui.simple/processz3950queue $rootdir/scripts/z3950daemon/");
220 system("mv $rootdir/intranet-cgi/acqui.simple/z3950-daemon-launch.sh $rootdir/scripts/z3950daemon/");
221 system("mv $rootdir/intranet-cgi/acqui.simple/z3950-daemon-shell.sh $rootdir/scripts/z3950daemon/");
222
223
224 # Remove extraneous files from intranet-cgi
225 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
226 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
227 system("rm -f $rootdir/intranet-cgi/SendMessages");
228 system("rm -f $rootdir/intranet-cgi/buildrelease");
229 system("rm -f $rootdir/intranet-cgi/database.mysql");
230 system("rm -f $rootdir/intranet-cgi/installer-lite.pl");
231 system("rm -f $rootdir/intranet-cgi/koha-1.2.0.tar.gz");
232 system("rm -f $rootdir/intranet-cgi/rel-1-2");
233 system("rm -f $rootdir/intranet-cgi/testKoha.pl");
234 system("rm -rf $rootdir/intranet-cgi/html-template");
235 system("rm -rf $rootdir/intranet-cgi/t");
236
237 # Copy all CVS files to intranet-html and opac-html
238 system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html");
239 system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html");
240
241 # Remove extraneous files from opac-html
242 system("rm -f $rootdir/opac-html/koha.mo");
243 system("rm -f $rootdir/opac-html/koha.pot");
244 system("rm -f $rootdir/opac-html/test");
245
246 # Remove extraneous files from intranet-html
247 system("rm -f $rootdir/intranet-html/koha.pot");
248 system("rm -f $rootdir/intranet-html/results.html");
249 system("rm -f $rootdir/intranet-html/test");
250
251 # Remove junk from directory
252 system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null");
253 system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null");
254 system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null");
255
256 if (-e "/root/docs") {
257     print "Copying docs folder from /root/docs...";
258     system("cp -r /root/docs/* $rootdir/docs/");
259 } else {
260     print "I would have copied the docs from from /root/docs, but I couldn't find it.\n";
261     print "Press <ENTER> to continue...\n";
262     <STDIN>;
263 }
264
265 chdir("/tmp");
266 system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion);
267 system("rm -rf $rootdir");
268
269 print qq|
270 ============
271 = ALL DONE =
272 ============
273
274 Your new tarball is located in /tmp/koha-$releaseversion.tar.gz
275
276 |;
277
278
279 sub versioncompare {
280     my $v1=shift;
281     my $v2=shift;
282     my @v1=split(/\./, $v1);
283     my @v2=split(/\./, $v2);
284     my $count=$#v1;
285     ($#v2>$count) && ($count=$#v2);
286     for (my $index=0; $index<$count; $index++) {
287         if ($v1[$index]>$v2[$index]) {
288             return 1;
289         }
290     }
291     return 0;
292 }