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'.
16 (* Enable debugging. *)
18 Unix.putenv "LIBGUESTFS_DEBUG" "1";
19 Unix.putenv "LIBGUESTFS_TRACE" "1"
21 (* Log program output. *)
22 let from = "rjones@redhat.com"
23 let to_ = "rjones@redhat.com"
25 let logfile = log_program_output ()
26 let () = eprintf "logging to %s\n%!" logfile
29 let package = "libguestfs"
31 (* Goal: the website has been updated to 'version'. *)
32 let rec goal website_updated version =
33 target (url_exists version.url &&
34 (if version.is_stable then
35 url_exists version.python_url
39 require (tarball_created version);
40 require (tarball_tested version);
42 (* Python sdists only generated for stable releases. *)
43 if version.is_stable then (
44 require (python_tarball_created version);
45 require (python_tarball_tested version)
48 (* We only update the website for the development releases. *)
49 if not version.is_stable then
50 require (website_built version);
52 require (website_checked_in version);
53 if version.is_stable then
54 require (python_website_checked_in version);
55 require (website_rsync_done version)
57 (* Goal: website has been rsync'd. *)
58 and website_rsync_done version =
59 target (url_contains_string "http://libguestfs.org" version.version &&
60 url_exists version.url);
67 (* Goal: Tarball added to repository and checked in. *)
68 and website_checked_in version =
69 let key = sprintf "libguestfs_website_checked_in_%s" version.version in
70 target (memory_exists key);
71 onrun (fun () -> memory_set key "1");
73 require (tarball_created version);
74 require (tarball_tested version);
83 git commit -m \"Version %s\"
84 " libguestfs_download_repo
85 buildtmp version.tarball version.urlpath
87 libguestfs_website_repo
91 (* Goal: website (local copy) has been built. *)
92 and website_built version =
93 let index_file = sprintf "%s/index.html" libguestfs_website_repo in
94 target (file_contains_string index_file version.version);
96 require (tarball_created version);
97 require (tarball_tested version);
99 (* We should only update the website on development releases. *)
100 assert (not version.is_stable);
103 tar zxf %s/tarballs/%s
106 echo %s > localconfigure
107 chmod +x localconfigure
112 make maintainer-upload-website WEBSITESDIR=%s
113 " buildtmp version.tarball
114 version.package_version
115 (quote (libguestfs_localconfigure `Tarball))
116 (quote (libguestfs_localenv (supermin version)))
117 (quote websites_repo)
119 (* Goal: the tarball has passed the required set of tests before
120 * a release is allowed.
122 and tarball_tested version =
123 let key = sprintf "libguestfs_tarball_tested_%s" version.version in
124 target (memory_exists key);
125 onrun (fun () -> memory_set key "1");
127 require (tarball_created version);
130 tar zxf %s/tarballs/%s
133 echo %s > localconfigure
134 chmod +x localconfigure
140 " buildtmp version.tarball
141 version.package_version
142 (quote (libguestfs_localconfigure `Tarball))
143 (quote (libguestfs_localenv (supermin version)))
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 require (repo_up_to_date version.branch);
152 let repodir = sprintf "%s/repos/%s-%s" buildtmp package version.branch in
154 (* Branches <= 1.32 are tagged with "1.32.11",
155 * branches >= 1.33 are tagged with "v1.33.11".
158 if version.minor >= 33 then "v" ^ version.version
159 else version.version in
166 echo %s > localconfigure
167 chmod +x localconfigure
172 # Ensure the po-docs are updated. Grrr this is ugly ...
175 make -C po-docs update-po
180 # Ensure redhat hardening flags didn't leak into the tarball.
181 # https://bugzilla.redhat.com/show_bug.cgi?id=1214506
182 if zcat %s | grep -q redhat-hardened; then exit 1; fi
187 (quote (libguestfs_localconfigure `Git))
188 (quote (libguestfs_localenv (supermin version)))
190 version.tarball buildtmp version.tarball
192 (* Goal: test a commit. *)
193 and commit_tested branch commit =
196 let subject = sprintf "goal: %s: FAILED" goalname in
197 mailto ~from ~subject (*~attach:[logfile]*) to_
200 let key = sprintf "libguestfs_commit_tested_%s" commit in
201 target (memory_exists key);
202 onrun (fun () -> memory_set key "1");
204 require (repo_up_to_date branch);
206 let repodir = sprintf "%s/repos/%s-%s" buildtmp package branch in
213 echo %s > localconfigure
214 chmod +x localconfigure
222 (quote (libguestfs_localconfigure `Git))
223 (quote (libguestfs_localenv None))
225 and repo_up_to_date branch =
228 (* Goals for Python sdists. *)
229 and python_website_checked_in version =
230 let key = sprintf "libguestfs_python_website_checked_in_%s" version.version in
231 target (memory_exists key);
232 onrun (fun () -> memory_set key "1");
234 require (python_tarball_created version);
235 require (python_tarball_tested version);
241 git commit -m \"Python sdist version %s\"
242 " libguestfs_download_repo
243 buildtmp version.python_tarball version.python_urlpath
244 version.python_urlpath
247 and python_tarball_tested version =
248 let key = sprintf "libguestfs_python_tarball_tested_%s" version.version in
249 target (memory_exists key);
250 onrun (fun () -> memory_set key "1");
252 require (python_tarball_created version);
256 source ./venv/bin/activate
257 pip install %s/tarballs/%s
258 " buildtmp version.python_tarball
260 and python_tarball_created version =
261 let filename = sprintf "%s/tarballs/%s" buildtmp version.python_tarball in
262 target (file_exists filename);
264 require (tarball_created version);
267 tar zxf %s/tarballs/%s
270 echo %s > localconfigure
271 chmod +x localconfigure
278 " buildtmp version.tarball
279 version.package_version
280 (quote (libguestfs_localconfigure `Tarball))
281 (quote (libguestfs_localenv (supermin version)))
282 version.python_tarball filename
285 (* Add a periodic job to check for new git commits and test them. *)
286 every libguestfs_query_mins minutes ~name:"new libguestfs commit" (
288 require (repo_up_to_date "master");
289 let commit = git_latest_commit "master" in
290 require (commit_tested "master" commit);
293 (* Periodic job to build new tarballs. *)
294 every libguestfs_query_mins minutes ~name:"new libguestfs version" (
296 require (repo_up_to_date "master");
297 let version = git_latest_version "master" in
298 require (website_updated version)
301 (* Allow these jobs to run from the command line. *)
305 | [commit] -> require (commit_tested "master" commit)
306 | [branch; commit] -> require (commit_tested branch commit)
308 failwith "use './libguestfs_upstream commit [<branch>] <commit>'"
312 | [version] -> require (website_updated (vernames version))
314 failwith "use './libguestfs_upstream release <version>'"