Skip to content

Commit e600029

Browse files
committed
Merged revision(s) 163-164 from utplsql/branches/feature-8:
Created the build script [feature-requests/8]
1 parent 5c30d77 commit e600029

File tree

1 file changed

+205
-0
lines changed

1 file changed

+205
-0
lines changed

build/build.pl

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
#!/usr/bin/perl -w
2+
# ************************************************************************
3+
# GNU General Public License for utPLSQL
4+
#
5+
# Copyright (C) 2014
6+
# Steven Feuerstein and the utPLSQL Project
7+
# (steven@stevenfeuerstein.com)
8+
#
9+
# This program is free software; you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation; either version 2 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program (see license.txt); if not, write to the Free Software
21+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22+
# ************************************************************************
23+
#
24+
# This perl script builds and optionally uploads a release of utPLSQL.
25+
#
26+
# Please see <https://sourceforge.net/p/utplsql/wiki/Release%20Procedure/> for
27+
# the Release Procedure.
28+
#
29+
# Creating a release does the following:
30+
# - Creates a "release" directory underneath the current directory.
31+
# - Copies all the files for a release into this new directory.
32+
# - Creates a zip file (the file that gets released) with the correct name.
33+
#
34+
# Uploading a release does all the above, plus the following:
35+
# - Uploads the release zip to Sourceforge (it will become visible in the File
36+
# Download area, but will not be the default).
37+
# - Uploads the website.
38+
#
39+
# $Id$
40+
#
41+
42+
use strict;
43+
use warnings;
44+
use 5.010;
45+
46+
use File::Copy;
47+
use File::Copy::Recursive qw(dircopy);
48+
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
49+
50+
say "Which build option do you require:";
51+
say " 1) Create release";
52+
say " 2) Create and upload release";
53+
print "Please make selection: ";
54+
my $selection = <>;
55+
56+
given($selection) {
57+
when(1) {create_zip_release();}
58+
when(2) {upload_release();}
59+
default {
60+
die "Invalid selection - exiting \n";
61+
}
62+
}
63+
64+
65+
sub version_number {
66+
state $version;
67+
my $confirmed;
68+
69+
if (!defined $version) {
70+
print "What is the new version number? ";
71+
$version = <>;
72+
chomp $version;
73+
print "Please confirm new version number: [$version] (Y/N)? ";
74+
$confirmed = <>;
75+
76+
chomp $confirmed;
77+
78+
if (!($confirmed eq "Y" || $confirmed eq "y")) {
79+
die "Not confirmed - aborting \n";
80+
}
81+
}
82+
83+
return $version;
84+
}
85+
86+
87+
sub release_dir {
88+
return "release-" . version_number();
89+
}
90+
91+
92+
sub release_code_dir {
93+
return release_dir() . "/code";
94+
}
95+
96+
97+
sub release_doc_dir {
98+
return release_dir() . "/doc";
99+
}
100+
101+
sub release_examples_dir {
102+
return release_dir() . "/examples";
103+
}
104+
105+
106+
sub create_release_directories {
107+
make_dir(release_dir());
108+
make_dir(release_code_dir());
109+
make_dir(release_doc_dir());
110+
make_dir(release_examples_dir());
111+
}
112+
113+
114+
sub make_dir {
115+
my($dir) = @_;
116+
unless(mkdir $dir) {
117+
die "Unable to create $dir - aborting \n";
118+
}
119+
}
120+
121+
122+
sub populate_release_directories {
123+
create_release_directories();
124+
populate_code_directory();
125+
populate_doc_directory();
126+
populate_examples_directory();
127+
copy ("../documentation/readme.txt", release_dir());
128+
}
129+
130+
131+
sub populate_code_directory {
132+
dircopy ("../source", release_code_dir());
133+
}
134+
135+
136+
sub populate_doc_directory{
137+
dircopy ("../website/Doc", release_doc_dir());
138+
}
139+
140+
141+
sub populate_examples_directory{
142+
dircopy ("../examples", release_examples_dir());
143+
}
144+
145+
146+
sub zip_filename {
147+
my $zipname = "utplsql-" . version_number() ;
148+
$zipname =~ s/[\.]/-/g;
149+
$zipname .= ".zip";
150+
}
151+
152+
153+
sub create_zip_release {
154+
populate_release_directories();
155+
my $zip = Archive::Zip->new();
156+
157+
# Add a directory
158+
my $dir_member = $zip->addTree(release_dir());
159+
160+
161+
unless ( $zip->writeToFileNamed(zip_filename()) == AZ_OK ) {
162+
die "Error creating zip file " . zip_filename() . " \n";
163+
}
164+
}
165+
166+
167+
sub upload_release {
168+
my $confirmed;
169+
170+
print "Please confirm you wish to upload this release: [".version_number()."] (Y/N)? ";
171+
$confirmed = <>;
172+
chomp $confirmed;
173+
174+
if (!($confirmed eq "Y" || $confirmed eq "y")) {
175+
die "Not confirmed - aborting \n";
176+
}
177+
178+
create_zip_release();
179+
upload_zip();
180+
upload_website();
181+
#set_default_download();
182+
}
183+
184+
185+
sub upload_zip {
186+
system 'rsync -avP -e ssh ' . zip_filename() . ' ' . username() . '@frs.sourceforge.net:/home/pfs/project/utplsql/utPLSQL/' . version_number() . '/' . zip_filename();
187+
}
188+
189+
190+
sub upload_website {
191+
system 'rsync -avP -chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r -e ssh ../website/ ' . username() . '@web.sourceforge.net:/home/project-web/utplsql/htdocs/';
192+
}
193+
194+
195+
sub username {
196+
state $username;
197+
198+
if (!defined $username) {
199+
print "Please enter your Sourceforge username: ";
200+
$username = <>;
201+
chomp $username;
202+
}
203+
204+
return $username;
205+
}

0 commit comments

Comments
 (0)