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 let package = "libguestfs"
17 (* Helper object which stores everything about a version. *)
19 version : string; (* The version as a normal string. *)
20 major : int; (* Broken-out version fields. *)
23 is_stable : bool; (* is a stable version of libguestfs? *)
24 branch : string; (* 'master' or 'stable-1.xx' *)
25 package_version : string; (* package-version *)
26 tarball : string; (* package-version.tar.gz *)
27 urlpath : string; (* download/1.X-(stable|development)/tarball *)
28 url : string; (* full download URL of tarball *)
31 (* Helper: Fetch latest gnulib into $buildtmp/repos/gnulib
32 * XXX Move to Gnulib module.
37 if [ ! -d gnulib ]; then git clone git://git.sv.gnu.org/gnulib.git; fi
39 git checkout --force master
43 (* Goal: the website has been updated to 'version'. *)
44 let rec goal website_updated version =
45 target (url_exists version.url);
47 require (tarball_created version);
48 require (tarball_tested version);
50 (* We only update the website for the development releases. *)
51 if not version.is_stable then
52 require (website_built version);
54 require (website_cvs_checked_in version);
55 require (website_rsync_done version)
57 (* Goal: website has been rsync'd. *)
58 and website_rsync_done version =
59 let key = sprintf "libguestfs_website_rsync_done_%s" version.version in
60 target (memory_exists key);
64 echo NOT RUNNING: . .rsync
65 " libguestfs_website_cvs;
68 (* Goal: Tarball added to CVS and CVS checked in. *)
69 and website_cvs_checked_in version =
70 let key = sprintf "libguestfs_website_cvs_checked_in_%s" version.version in
71 target (memory_exists key);
73 require (tarball_created version);
74 require (tarball_tested version);
79 echo NOT RUNNING: cvs add -kb %s
80 echo NOT RUNNING: cvs ci -m \"Version %s\"
81 " libguestfs_website_cvs
82 buildtmp version.tarball version.urlpath
86 (* Goal: website (local copy) has been built. *)
87 and website_built version =
88 let index_file = sprintf "%s/index.html" libguestfs_website_cvs in
89 target (file_contains_string index_file version.version);
91 require (tarball_created version);
92 require (tarball_tested version);
94 (* We should only update the website on development releases. *)
95 assert (not version.is_stable);
98 tar zxf %s/tarballs/%s
100 echo %s > localconfigure
101 chmod +x localconfigure
106 " buildtmp version.tarball
107 version.package_version
108 (quote (libguestfs_localconfigure `Tarball))
109 (quote libguestfs_localenv)
111 (* Goal: the tarball has passed the required set of tests before
112 * a release is allowed.
114 and tarball_tested version =
115 let key = sprintf "libguestfs_tarball_tested_%s" version.version in
116 target (memory_exists key);
118 require (tarball_created version);
121 tar zxf %s/tarballs/%s
123 echo %s > localconfigure
124 chmod +x localconfigure
129 " buildtmp version.tarball
130 version.package_version
131 (quote (libguestfs_localconfigure `Tarball))
132 (quote libguestfs_localenv)
134 (* Goal: the tarball has been created from git. *)
135 and tarball_created version =
136 let filename = sprintf "%s/tarballs/%s" buildtmp version.tarball in
137 target (file_exists filename);
139 let repodir = sprintf "%s/repos/%s-%s" buildtmp package version.branch in
140 require (directory_exists repodir);
147 echo %s > localconfigure
148 chmod +x localconfigure
157 (quote (libguestfs_localconfigure `Git))
158 (quote libguestfs_localenv)
159 version.tarball buildtmp version.tarball
161 (* Goal: test a commit. *)
162 and commit_tested branch commit =
163 let key = sprintf "libguestfs_commit_tested_%s" commit in
164 target (memory_exists key);
166 let repodir = sprintf "%s/repos/%s-%s" buildtmp package branch in
167 require (directory_exists repodir);
174 echo %s > localconfigure
175 chmod +x localconfigure
183 (quote (libguestfs_localconfigure `Git))
184 (quote libguestfs_localenv);
188 (* Helper function to make a full 'info' object from a version
191 let vernames version =
192 Scanf.sscanf version "%d.%d.%d" (
193 fun major minor release ->
194 let is_stable = minor mod 2 = 0 in
197 sprintf "stable-%d.%d" major minor
200 let package_version = sprintf "%s-%d.%d.%d" package major minor release in
201 let tarball = sprintf "%s.tar.gz" package_version in
204 sprintf "download/%d.%d-stable/%s" major minor tarball
206 sprintf "download/%d.%d-development/%s" major minor tarball in
207 let url = "http://libguestfs.org/" ^ urlpath in
209 major = major; minor = minor; release = release;
210 is_stable = is_stable;
212 package_version = package_version;
218 (* Helper function to read the latest version in a repo and return
221 let git_latest_version branch =
224 git describe --tags --abbrev=0
225 " buildtmp package (quote branch) in
228 (* Get the latest commit. *)
229 let git_latest_commit branch =
233 " buildtmp package (quote branch)
235 (* Clone or update a repo to the latest version on a branch, by force.
236 * It is cached in name = $buildtmp/repos/<package>-<branch>
238 let git_force url branch =
241 if [ ! -d %s-%s ]; then git clone %s %s-%s; fi
243 git checkout --force %s
245 # Copy or update gnulib
249 package (quote branch) (quote url) package (quote branch)
250 package (quote branch)
254 (* Add a periodic job to check for new git commits and test them. *)
255 every 5 minutes ~name:"new libguestfs commit" (
257 git_force "https://github.com/libguestfs/libguestfs.git" "master";
259 let commit = git_latest_commit "master" in
260 require (commit_tested "master" commit);
263 (* Periodic job to build new tarballs. *)
264 every 5 minutes ~name:"new libguestfs version" (
266 git_force "https://github.com/libguestfs/libguestfs.git" "master";
268 let version = git_latest_version "master" in
269 require (website_updated version)