1 (* This goal script is responsible for:
2 * - testing each new commit to the libguestfs source repo
3 * - checking for new upstream releases of libguestfs
4 * - testing new upstream releases
5 * - packaging them as a source tarball
6 * - testing the source tarball on a variety of systems
7 * - if all the above works, uploading the external website
8 * Note this doesn't build the Fedora releases. See 'libguestfs_fedora.ml'.
15 (* Enable debugging. *)
17 Unix.putenv "LIBGUESTFS_DEBUG" "1";
18 Unix.putenv "LIBGUESTFS_TRACE" "1"
20 (* Log program output. *)
21 let from = "rjones@redhat.com"
22 let to_ = "rjones@redhat.com"
23 let logfile = log_program_output ()
24 let () = eprintf "logging to %s\n%!" logfile
26 let package = "libguestfs"
28 (* Helper object which stores everything about a version. *)
30 version : string; (* The version as a normal string. *)
31 major : int; (* Broken-out version fields. *)
34 is_stable : bool; (* is a stable version of libguestfs? *)
35 branch : string; (* 'master' or 'stable-1.xx' *)
36 package_version : string; (* package-version *)
37 tarball : string; (* package-version.tar.gz *)
38 urlpath : string; (* download/1.X-(stable|development)/tarball *)
39 url : string; (* full download URL of tarball *)
42 (* Helper: Fetch latest gnulib into $buildtmp/repos/gnulib
43 * XXX Move to Gnulib module.
48 if [ ! -d gnulib ]; then git clone git://git.sv.gnu.org/gnulib.git; fi
50 git checkout --force master
54 (* Goal: the website has been updated to 'version'. *)
55 let rec goal website_updated version =
56 target (url_exists version.url);
58 require (tarball_created version);
59 require (tarball_tested version);
61 (* We only update the website for the development releases. *)
62 if not version.is_stable then
63 require (website_built version);
65 require (website_cvs_checked_in version);
66 require (website_rsync_done version)
68 (* Goal: website has been rsync'd. *)
69 and website_rsync_done version =
70 let key = sprintf "libguestfs_website_rsync_done_%s" version.version in
71 target (memory_exists key);
75 echo NOT RUNNING: . .rsync
76 " libguestfs_website_cvs;
79 (* Goal: Tarball added to CVS and CVS checked in. *)
80 and website_cvs_checked_in version =
81 let key = sprintf "libguestfs_website_cvs_checked_in_%s" version.version in
82 target (memory_exists key);
84 require (tarball_created version);
85 require (tarball_tested version);
90 echo NOT RUNNING: cvs add -kb %s
91 echo NOT RUNNING: cvs ci -m \"Version %s\"
92 " libguestfs_website_cvs
93 buildtmp version.tarball version.urlpath
97 (* Goal: website (local copy) has been built. *)
98 and website_built version =
99 let index_file = sprintf "%s/index.html" libguestfs_website_cvs in
100 target (file_contains_string index_file version.version);
102 require (tarball_created version);
103 require (tarball_tested version);
105 (* We should only update the website on development releases. *)
106 assert (not version.is_stable);
109 tar zxf %s/tarballs/%s
111 echo %s > localconfigure
112 chmod +x localconfigure
117 " buildtmp version.tarball
118 version.package_version
119 (quote (libguestfs_localconfigure `Tarball))
120 (quote libguestfs_localenv)
122 (* Goal: the tarball has passed the required set of tests before
123 * a release is allowed.
125 and tarball_tested version =
126 let key = sprintf "libguestfs_tarball_tested_%s" version.version in
127 target (memory_exists key);
129 require (tarball_created version);
132 tar zxf %s/tarballs/%s
134 echo %s > localconfigure
135 chmod +x localconfigure
140 " buildtmp version.tarball
141 version.package_version
142 (quote (libguestfs_localconfigure `Tarball))
143 (quote libguestfs_localenv)
145 (* Goal: the tarball has been created from git. *)
146 and tarball_created version =
147 let filename = sprintf "%s/tarballs/%s" buildtmp version.tarball in
148 target (file_exists filename);
150 let repodir = sprintf "%s/repos/%s-%s" buildtmp package version.branch in
151 require (directory_exists repodir);
158 echo %s > localconfigure
159 chmod +x localconfigure
168 (quote (libguestfs_localconfigure `Git))
169 (quote libguestfs_localenv)
170 version.tarball buildtmp version.tarball
172 (* Goal: test a commit. *)
173 and commit_tested branch commit =
176 let subject = sprintf "goal: %s: FAILED" goalname in
177 mailto ~from ~subject ~attach:[logfile] to_
180 let key = sprintf "libguestfs_commit_tested_%s" commit in
181 target (memory_exists key);
183 let repodir = sprintf "%s/repos/%s-%s" buildtmp package branch in
184 require (directory_exists repodir);
191 echo %s > localconfigure
192 chmod +x localconfigure
200 (quote (libguestfs_localconfigure `Git))
201 (quote libguestfs_localenv);
205 (* Helper function to make a full 'info' object from a version
208 let vernames version =
209 Scanf.sscanf version "%d.%d.%d" (
210 fun major minor release ->
211 let is_stable = minor mod 2 = 0 in
214 sprintf "stable-%d.%d" major minor
217 let package_version = sprintf "%s-%d.%d.%d" package major minor release in
218 let tarball = sprintf "%s.tar.gz" package_version in
221 sprintf "download/%d.%d-stable/%s" major minor tarball
223 sprintf "download/%d.%d-development/%s" major minor tarball in
224 let url = "http://libguestfs.org/" ^ urlpath in
226 major = major; minor = minor; release = release;
227 is_stable = is_stable;
229 package_version = package_version;
235 (* Helper function to read the latest version in a repo and return
238 let git_latest_version branch =
241 git describe --tags --abbrev=0
242 " buildtmp package (quote branch) in
245 (* Get the latest commit. *)
246 let git_latest_commit branch =
250 " buildtmp package (quote branch)
252 (* Clone or update a repo to the latest version on a branch, by force.
253 * It is cached in name = $buildtmp/repos/<package>-<branch>
255 let git_force url branch =
258 if [ ! -d %s-%s ]; then git clone %s %s-%s; fi
260 git checkout --force %s
262 # Copy or update gnulib
266 package (quote branch) (quote url) package (quote branch)
267 package (quote branch)
271 (* Add a periodic job to check for new git commits and test them. *)
272 every libguestfs_query_mins minutes ~name:"new libguestfs commit" (
274 git_force "https://github.com/libguestfs/libguestfs.git" "master";
276 let commit = git_latest_commit "master" in
277 require (commit_tested "master" commit);
280 (* Periodic job to build new tarballs. *)
281 every libguestfs_query_mins minutes ~name:"new libguestfs version" (
283 git_force "https://github.com/libguestfs/libguestfs.git" "master";
285 let version = git_latest_version "master" in
286 require (website_updated version)