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
112 echo %s > localconfigure
113 chmod +x localconfigure
119 " buildtmp version.tarball
120 version.package_version
121 (quote (libguestfs_localconfigure `Tarball))
122 (quote libguestfs_localenv)
124 (* Goal: the tarball has passed the required set of tests before
125 * a release is allowed.
127 and tarball_tested version =
128 let key = sprintf "libguestfs_tarball_tested_%s" version.version in
129 target (memory_exists key);
131 require (tarball_created version);
134 tar zxf %s/tarballs/%s
137 echo %s > localconfigure
138 chmod +x localconfigure
144 " buildtmp version.tarball
145 version.package_version
146 (quote (libguestfs_localconfigure `Tarball))
147 (quote libguestfs_localenv)
149 (* Goal: the tarball has been created from git. *)
150 and tarball_created version =
151 let filename = sprintf "%s/tarballs/%s" buildtmp version.tarball in
152 target (file_exists filename);
154 let repodir = sprintf "%s/repos/%s-%s" buildtmp package version.branch in
155 require (directory_exists repodir);
162 echo %s > localconfigure
163 chmod +x localconfigure
172 (quote (libguestfs_localconfigure `Git))
173 (quote libguestfs_localenv)
174 version.tarball buildtmp version.tarball
176 (* Goal: test a commit. *)
177 and commit_tested branch commit =
180 let subject = sprintf "goal: %s: FAILED" goalname in
181 mailto ~from ~subject ~attach:[logfile] to_
184 let key = sprintf "libguestfs_commit_tested_%s" commit in
185 target (memory_exists key);
187 let repodir = sprintf "%s/repos/%s-%s" buildtmp package branch in
188 require (directory_exists repodir);
195 echo %s > localconfigure
196 chmod +x localconfigure
204 (quote (libguestfs_localconfigure `Git))
205 (quote libguestfs_localenv);
209 (* Helper function to make a full 'info' object from a version
212 let vernames version =
213 Scanf.sscanf version "%d.%d.%d" (
214 fun major minor release ->
215 let is_stable = minor mod 2 = 0 in
218 sprintf "stable-%d.%d" major minor
221 let package_version = sprintf "%s-%d.%d.%d" package major minor release in
222 let tarball = sprintf "%s.tar.gz" package_version in
225 sprintf "download/%d.%d-stable/%s" major minor tarball
227 sprintf "download/%d.%d-development/%s" major minor tarball in
228 let url = "http://libguestfs.org/" ^ urlpath in
230 major = major; minor = minor; release = release;
231 is_stable = is_stable;
233 package_version = package_version;
239 (* Helper function to read the latest version in a repo and return
242 let git_latest_version branch =
245 git describe --tags --abbrev=0
246 " buildtmp package (quote branch) in
249 (* Get the latest commit. *)
250 let git_latest_commit branch =
254 " buildtmp package (quote branch)
256 (* Clone or update a repo to the latest version on a branch, by force.
257 * It is cached in name = $buildtmp/repos/<package>-<branch>
259 let git_force url branch =
262 if [ ! -d %s-%s ]; then git clone %s %s-%s; fi
264 git checkout --force %s
266 # Copy or update gnulib
270 package (quote branch) (quote url) package (quote branch)
271 package (quote branch)
275 (* Add a periodic job to check for new git commits and test them. *)
276 every libguestfs_query_mins minutes ~name:"new libguestfs commit" (
278 git_force "https://github.com/libguestfs/libguestfs.git" "master";
280 let commit = git_latest_commit "master" in
281 require (commit_tested "master" commit);
284 (* Periodic job to build new tarballs. *)
285 every libguestfs_query_mins minutes ~name:"new libguestfs version" (
287 git_force "https://github.com/libguestfs/libguestfs.git" "master";
289 let version = git_latest_version "master" in
290 require (website_updated version)