-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.rb
202 lines (183 loc) · 7.39 KB
/
commands.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# @BEGIN_LICENSE
#
# Halyard - Multimedia authoring and playback system
# Copyright 1993-2009 Trustees of Dartmouth College
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
# @END_LICENSE
# Run +cvs+ with the specified arguments.
# cvs :checkout, 'MyProgram'
def cvs command, *args
run 'cvs', command.to_s, *args
end
# Run +svn+ with the specified arguments.
# svn :checkout, 'MyProgram'
def svn command, *args
run 'svn', command.to_s, *args
end
# Run +git+ with the specified arguments.
# git :clone, 'git://imlsrc.dartmouth.edu/program'
def git command, *args
run 'git', command.to_s, *args
end
# Check out a project from SVN, and tag it with the release_id of this
# build. This will always checkout from /trunk, and tag to
# /tags/builds/#{release_id}
def svn_co_and_tag working_copy, svn_base, release_id
svn :co, "#{svn_base}/trunk", working_copy
svn(:copy, '-m', "Tagging build #{release_id}", working_copy,
"#{svn_base}/tags/builds/#{release_id}")
end
# Clone a git project, update submodules, and tag that version with
# the release_id of this build. This will always check out master,
# and always tag to builds/#{release_id}
def git_clone_and_tag working_copy, git_url, release_id
git :clone, git_url, working_copy
cd working_copy do
git :submodule, 'update', '--init'
git :tag, "builds/#{release_id}"
git :push, 'origin', "builds/#{release_id}:builds/#{release_id}"
end
end
# Build an installer using Inno Setup 4, which must be installed in
# the default location. For best results, run this from the directory
# containing your application.
# inno_setup_4 'myprogram.iss'
def inno_setup_4 iss_file, options={}
defines = (options[:define] || {}).map {|var,value| "-d#{var}=#{value}" }
run 'c:/Program Files/Inno Setup 4/iscc', iss_file, *defines
end
# ditto, for Inno Setup 5
def inno_setup_5 iss_file, options={}
defines = (options[:define] || {}).map {|var,value| "-d#{var}=#{value}" }
run 'c:/Program Files/Inno Setup 5/iscc', iss_file, *defines
end
# Launch Halyard and have it compile all the Scheme scripts in the current
# directory. Automatically manages the TRUST-PRECOMPILED file.
def compile_scheme_scripts
rm_f 'config/TRUST-PRECOMPILED'
# We need to give a real path here, because "." will cause problems for
# the engine. And it needs to be a Windows path, not a Cygwin path!
# We need to be in command line mode, not runtime mode, so we will write
# out our file count for our progress bar.
run './engine/win32/Halyard', '-c', '(exit-script)', absolute_path(pwd)
run 'touch', 'config/TRUST-PRECOMPILED'
end
# Search through _dirs_ for files referenced in an Inno Setup script as
# external install-time resources, and add them to our release list.
def release_installer_support_files iss_file, options, *dirs
# Figure out what files are available in dirs. This code is fairly
# fragile if you're trying to access network drives under Cygwin, which
# confuse various bits of the Ruby standard library.
filemap = {}
dirs.each do |d|
Dir.new(d).each do |file|
next if file == '.' or file == '..'
filemap[file] = "#{d}/#{file}"
end
end
# Search through iss_file, and release any sources that we have.
File.readlines(iss_file).each do |source|
if source =~ /^Source: \{src\}\\([^;]+);.*external/
release filemap[$1], options if filemap[$1]
end
end
end
# Parse the iss_file, and generate the manifest files for this release.
# Include update_url in the manifest files, so that the installed program
# knows where to find updates.
def generate_manifest_files iss_file, update_url
iss = InnoSetup::SourceFile.new(iss_file, Dir.getwd, 'CD_INSTALLER' => 1)
iss.components.each do |name, component|
next unless component.includes_manifest?
manifest = component.manifest
# TODO - We need to include *.iss file's directory when creating this file.
File.open(component.manifest_name, 'w') {|f| f.write(manifest) }
end
File.open("release.spec", 'w') do |f|
f.write(iss.spec_file("Build" => release_id || "DIRTY",
"Update-URL" => update_url))
end
sign_file_with_gpg 'release.spec'
end
# Copy files to update server, and put them in the right places for us to
# update from.
# TODO - could probably still use some refactoring, as could MANIFEST section
# TODO - don't copy .svn directories
def upload_files_for_updater(update_ssh_host, update_ssh_user, update_path,
update_temp_path, program_unix_name)
server = remote_host(update_ssh_host, :user => update_ssh_user)
program_temp = "#{update_temp_path}/#{program_unix_name}"
buildscript_temp = "#{update_temp_path}/buildscript"
server.upload('./', program_temp, :exclude => '.git')
server.upload("#{buildscript_source_dir}/", buildscript_temp,
:exclude => '.git')
server.run('chmod', '-R', 'a+r', program_temp, buildscript_temp)
server.run('chmod', '-R', 'ug+wX', program_temp, buildscript_temp)
server.run('ruby', "-I#{update_temp_path}",
"#{buildscript_temp}/build_update_server.rb",
program_temp, update_path)
end
# Create a tarball of directory dir, named dir.tar.gz by default, and
# mark it for release, excluding any version control files as well as
# any files explicitly excluded.
def make_tarball dir, options={}
options[:filename] = options[:filename] || "#{dir}.tar.gz"
make_tarball_from_files [dir], options
end
def exclude_each exclude
if (exclude)
if (exclude.is_a? Array)
exclude.each do |glob|
yield glob
end
else
yield exclude
end
end
end
# Create a tarball of the given files, and mark it for release,
# excluding any version control files as well as any files explicitly
# excluded.
def make_tarball_from_files files, options={}
tarball = options[:filename]
args = ['czf', tarball, '--exclude-vcs']
exclude_each options[:exclude] do |exclude|
args.push '--exclude', exclude
end
args.concat files
run 'tar', *args
release tarball, :cd => 1
end
# Create a ZIP file of directory dir, named dir.zip by default, and
# mark it for release, excluding any version control files as well as
# any files explicitly excluded.
#
# Note that excludes work a bit differently for zip; you need to pass
# a glob that matches the full path, excluding a directory does not
# actually exclude the files within it, you must exclude them with a
# glob as well, and in order to exclude a directory, you need to
# include the trailing slash.
def make_zipfile dir, options={}
zipfile = options[:filename] || "#{dir}.zip"
excludes = ['-x', '*/.git/*', '-x', '*/.gitignore']
exclude_each options[:excludes] do |exclude|
excludes.push '-x', exclude
end
run 'zip', '-r', zipfile, dir, *excludes
release zipfile, :cd => 1
end