1 (* Perform a complete Fedora OCaml rebuild, in build order. *)
12 let koji_target = "rawhide"
14 (* The name of the rebuild, and also the magic substring that must
15 * appear in the %changelog when the package has been rebuilt.
17 let rebuild_name = "OCaml 4.02.0 beta"
19 (* Packages that have problems or we just don't want to build. *)
21 "ocaml-lwt"; "ocaml-react"; (* loganjerry is handling *)
24 (* List of OCaml-related source package names. *)
26 let dirs = shlines "cd %s && ls -1d ocaml*" fedora_dir in
27 dirs @ [ "alt-ergo"; "apron"; "brltty"; "coccinelle"; "coq";
28 "cduce"; "frama-c"; "gappalib-coq"; "graphviz"; "hivex";
29 "js-of-ocaml"; "llvm"; "plplot"; "whenjobs"; "why3"; "xen" ]
32 List.filter (fun pkg -> not (List.mem pkg blocked)) source_packages
34 (* Dependencies of each package. (pkg, [deps ...]) *)
35 let pkg_deps = dependencies branch source_packages
37 (* Goal: rebuild all packages. *)
39 List.iter (fun pkg -> require (rebuild_started pkg)) source_packages
41 (* Goal: That 'package' has been rebuilt and exists in Koji. *)
43 let specfile = fedora_specfile pkg branch in
45 (* Note: verrel may change as we go along, so don't assign it to
49 (* Note the target must be both of these because the old verrel
50 * could exist as a koji build without it having been part of the
53 target (file_contains_string specfile rebuild_name &&
54 koji_build_state (fedora_verrel pkg branch) == `Complete);
56 (* Start the rebuild. *)
57 require (rebuild_started pkg);
59 (* Wait for the build state to reach a conclusion. *)
61 match koji_build_state (fedora_verrel pkg branch) with
63 failwith (sprintf "rebuild of package %s: no build found" pkg)
70 failwith (sprintf "rebuild of package %s: deleted" pkg)
72 failwith (sprintf "rebuild of package %s: failed" pkg)
74 failwith (sprintf "rebuild of package %s: canceled" pkg)
78 (* Wait for the build to appear in Koji repo. *)
79 koji_wait_repo koji_target (fedora_verrel pkg branch)
81 (* Goal: The rebuild of the package has started, but we haven't waited
84 and rebuild_started pkg =
85 let deps = List.assoc pkg pkg_deps in
86 let specfile = fedora_specfile pkg branch in
88 (* Note the target must be both of these because the old verrel
89 * could exist as a koji build without it having been part of the
92 target (file_contains_string specfile rebuild_name &&
93 (match koji_build_state (fedora_verrel pkg branch) with
94 | `Building | `Complete -> true
95 | `Deleted | `Failed | `Canceled | `No_such_build -> false));
97 (* All dependent packages must have been fully rebuilt and in the
100 List.iter (fun dep -> require (rebuilt dep)) deps;
102 (* A local test build must succeed. *)
103 require (local_build_succeeded pkg);
105 (* Rebuild the package in Koji. Don't wait ... *)
106 koji_build ~wait:false pkg branch;
108 (* ... but the build doesn't appear in Koji (eg. in 'koji
109 * buildinfo') until the SRPM has been built. This can take quite
110 * some time. Loop here until the build appears.
113 match koji_build_state (fedora_verrel pkg branch) with
117 | `Building | `Complete ->
120 failwith (sprintf "rebuild of package %s: deleted" pkg)
122 failwith (sprintf "rebuild of package %s: failed" pkg)
124 failwith (sprintf "rebuild of package %s: canceled" pkg)
128 and local_build_succeeded pkg =
129 (* The specfile must have been updated. *)
130 require (specfile_updated pkg);
133 sprintf "fedora_ocaml_local_build_%s_%s" pkg (fedora_verrel pkg branch) in
135 target (memory_exists key);
137 (* Do a local test build to ensure the Koji build will work. *)
140 sudo yum-builddep -y %s
142 " (fedora_repo pkg branch)
143 (fedora_specfile pkg branch);
147 and specfile_updated pkg =
148 let repodir = fedora_repo pkg branch in
149 let specfile = fedora_specfile pkg branch in
153 rm -rf x86_64 noarch *.src.rpm .build* clog
157 if not (git_has_local_changes repodir) then
163 sh "sudo yum-builddep -y %s" specfile;
165 (* For rationale behind always bumping the spec file, see comment
169 if not (file_contains_string specfile rebuild_name) then
170 rebuild_name ^ " rebuild."
172 "Bump release and rebuild." in
173 sh "rpmdev-bumpspec -c %s %s" (quote title) specfile;
175 (* XXX Automate common specfile fixes. *)
179 echo 'Please make further changes as required to the spec file %s.spec'
180 echo '(Press return key)'
183 echo 'OK to commit this change? (press ^C if not)'
186 echo 'OK to push this change? (press ^C if not)'