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 let package = "libguestfs"
22 (* Helper object which stores everything about a version. *)
24 version : string; (* The version as a normal string. *)
25 major : int; (* Broken-out version fields. *)
28 is_stable : bool; (* is a stable version of libguestfs? *)
29 branch : string; (* 'master' or 'stable-1.xx' *)
30 package_version : string; (* package-version *)
31 tarball : string; (* package-version.tar.gz *)
32 urlpath : string; (* download/1.X-(stable|development)/tarball *)
33 url : string; (* full download URL of tarball *)
36 (* Helper: Fetch latest gnulib into $buildtmp/repos/gnulib
37 * XXX Move to Gnulib module.
42 if [ ! -d gnulib ]; then git clone git://git.sv.gnu.org/gnulib.git; fi
44 git checkout --force master
48 (* Goal: the website has been updated to 'version'. *)
49 let rec goal website_updated version =
50 target (url_exists version.url);
52 require (tarball_created version);
53 require (tarball_tested version);
55 (* We only update the website for the development releases. *)
56 if not version.is_stable then
57 require (website_built version);
59 require (website_cvs_checked_in version);
60 require (website_rsync_done version)
62 (* Goal: website has been rsync'd. *)
63 and website_rsync_done version =
64 let key = sprintf "libguestfs_website_rsync_done_%s" version.version in
65 target (memory_exists key);
69 echo NOT RUNNING: . .rsync
70 " libguestfs_website_cvs;
73 (* Goal: Tarball added to CVS and CVS checked in. *)
74 and website_cvs_checked_in version =
75 let key = sprintf "libguestfs_website_cvs_checked_in_%s" version.version in
76 target (memory_exists key);
78 require (tarball_created version);
79 require (tarball_tested version);
84 echo NOT RUNNING: cvs add -kb %s
85 echo NOT RUNNING: cvs ci -m \"Version %s\"
86 " libguestfs_website_cvs
87 buildtmp version.tarball version.urlpath
91 (* Goal: website (local copy) has been built. *)
92 and website_built version =
93 let index_file = sprintf "%s/index.html" libguestfs_website_cvs 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
105 echo %s > localconfigure
106 chmod +x localconfigure
111 " buildtmp version.tarball
112 version.package_version
113 (quote (libguestfs_localconfigure `Tarball))
114 (quote libguestfs_localenv)
116 (* Goal: the tarball has passed the required set of tests before
117 * a release is allowed.
119 and tarball_tested version =
120 let key = sprintf "libguestfs_tarball_tested_%s" version.version in
121 target (memory_exists key);
123 require (tarball_created version);
126 tar zxf %s/tarballs/%s
128 echo %s > localconfigure
129 chmod +x localconfigure
134 " buildtmp version.tarball
135 version.package_version
136 (quote (libguestfs_localconfigure `Tarball))
137 (quote libguestfs_localenv)
139 (* Goal: the tarball has been created from git. *)
140 and tarball_created version =
141 let filename = sprintf "%s/tarballs/%s" buildtmp version.tarball in
142 target (file_exists filename);
144 let repodir = sprintf "%s/repos/%s-%s" buildtmp package version.branch in
145 require (directory_exists repodir);
152 echo %s > localconfigure
153 chmod +x localconfigure
162 (quote (libguestfs_localconfigure `Git))
163 (quote libguestfs_localenv)
164 version.tarball buildtmp version.tarball
166 (* Goal: test a commit. *)
167 and commit_tested branch commit =
168 let key = sprintf "libguestfs_commit_tested_%s" commit in
169 target (memory_exists key);
171 let repodir = sprintf "%s/repos/%s-%s" buildtmp package branch in
172 require (directory_exists repodir);
179 echo %s > localconfigure
180 chmod +x localconfigure
188 (quote (libguestfs_localconfigure `Git))
189 (quote libguestfs_localenv);
193 (* Helper function to make a full 'info' object from a version
196 let vernames version =
197 Scanf.sscanf version "%d.%d.%d" (
198 fun major minor release ->
199 let is_stable = minor mod 2 = 0 in
202 sprintf "stable-%d.%d" major minor
205 let package_version = sprintf "%s-%d.%d.%d" package major minor release in
206 let tarball = sprintf "%s.tar.gz" package_version in
209 sprintf "download/%d.%d-stable/%s" major minor tarball
211 sprintf "download/%d.%d-development/%s" major minor tarball in
212 let url = "http://libguestfs.org/" ^ urlpath in
214 major = major; minor = minor; release = release;
215 is_stable = is_stable;
217 package_version = package_version;
223 (* Helper function to read the latest version in a repo and return
226 let git_latest_version branch =
229 git describe --tags --abbrev=0
230 " buildtmp package (quote branch) in
233 (* Get the latest commit. *)
234 let git_latest_commit branch =
238 " buildtmp package (quote branch)
240 (* Clone or update a repo to the latest version on a branch, by force.
241 * It is cached in name = $buildtmp/repos/<package>-<branch>
243 let git_force url branch =
246 if [ ! -d %s-%s ]; then git clone %s %s-%s; fi
248 git checkout --force %s
250 # Copy or update gnulib
254 package (quote branch) (quote url) package (quote branch)
255 package (quote branch)
259 (* Add a periodic job to check for new git commits and test them. *)
260 every libguestfs_query_mins minutes ~name:"new libguestfs commit" (
262 git_force "https://github.com/libguestfs/libguestfs.git" "master";
264 let commit = git_latest_commit "master" in
265 require (commit_tested "master" commit);
268 (* Periodic job to build new tarballs. *)
269 every libguestfs_query_mins minutes ~name:"new libguestfs version" (
271 git_force "https://github.com/libguestfs/libguestfs.git" "master";
273 let version = git_latest_version "master" in
274 require (website_updated version)