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 (* Local repository that contains build dependencies. *)
20 let yum_repo = "koji-rawhide"
22 (* Packages that have problems. These block the packages and all
26 "ocaml-bitstring"; (* needs upstream fix for 4.02.0 *)
28 (* ocaml-labltk needs to be packaged. Unfortunately because there
29 * is no spec file, ocaml-labltk doesn't appear in the list of
30 * source packages, and so is filtered out of all the dependency
31 * checks as if it were a non-OCaml package. Therefore we currently
32 * also have to list all packages that depend on it.
34 "ocaml-labltk"; (* BRed by: *) "ocaml-lablgl"; "ocaml-ocamlnet"; "planets";
36 "ocaml-camlp5"; (* not updated for 4.02.0 *)
38 let blocked pkg = List.mem pkg blocked
40 (* These packages are treated as if they have been rebuilt. *)
42 "ocaml-srpm-macros"; (* don't need to build this *)
43 "ocaml"; (* rebuilt by hand *)
44 "ocaml-findlib"; (* rebuilt by hand *)
45 "ocaml-lwt"; "ocaml-react"; (* loganjerry is handling *)
46 "ocaml-camlidl"; (* rebuilt by orionp *)
47 "whenjobs"; (* obsolete *)
49 let ignored pkg = List.mem pkg ignored
51 (* List of OCaml-related source package names. *)
53 let dirs = shlines "cd %s && ls -1d ocaml*" fedora_dir in
54 dirs @ [ "alt-ergo"; "apron"; "brltty"; "coccinelle"; "coq";
55 "cduce"; "frama-c"; "gappalib-coq"; "graphviz"; "hivex";
56 "js-of-ocaml"; "llvm"; "plplot"; "why3"; "xen" ]
58 (* Dependencies of each package. (pkg, [deps ...]) *)
59 let pkg_deps = dependencies branch source_packages
61 (* Remove blocked packages and packages which have a blocked package
62 * as a dependency (recursively).
65 let rec is_blocked pkg =
66 if blocked pkg then true
68 let deps = List.assoc pkg pkg_deps in
69 List.exists is_blocked deps
72 List.filter (fun pkg -> not (is_blocked pkg)) source_packages
75 printf "final list of source packages = %s\n%!"
76 (String.concat " " source_packages)
78 (* Goal: rebuild all packages. *)
80 List.iter (fun pkg -> require (rebuild_started pkg)) source_packages
82 (* Goal: That 'package' has been rebuilt and exists in Koji. *)
84 let specfile = fedora_specfile pkg branch in
86 (* Note: verrel may change as we go along, so don't assign it to
90 (* Note the target must be both of these because the old verrel
91 * could exist as a koji build without it having been part of the
94 target (ignored pkg ||
95 (file_contains_string specfile rebuild_name &&
96 koji_build_state (fedora_verrel pkg branch) == `Complete));
98 (* Ignored packages are treated as if they have been rebuilt. *)
99 if not (ignored pkg) then (
101 (* Start the rebuild. *)
102 require (rebuild_started pkg);
104 (* Wait for the build state to reach a conclusion. *)
106 match koji_build_state (fedora_verrel pkg branch) with
108 failwith (sprintf "rebuild of package %s: no build found" pkg)
115 failwith (sprintf "rebuild of package %s: deleted" pkg)
117 failwith (sprintf "rebuild of package %s: failed" pkg)
119 failwith (sprintf "rebuild of package %s: canceled" pkg)
123 (* Wait for the build to appear in Koji repo. *)
124 koji_wait_repo koji_target (fedora_verrel pkg branch)
127 (* Goal: The rebuild of the package has started, but we haven't waited
130 and rebuild_started pkg =
131 let deps = List.assoc pkg pkg_deps in
132 let specfile = fedora_specfile pkg branch in
134 (* Note the target must be both of these because the old verrel
135 * could exist as a koji build without it having been part of the
138 target (ignored pkg ||
139 (file_contains_string specfile rebuild_name &&
140 (match koji_build_state (fedora_verrel pkg branch) with
141 | `Building | `Complete -> true
142 | `Deleted | `Failed | `Canceled | `No_such_build -> false)));
144 (* All dependent packages must have been fully rebuilt and in the
147 List.iter (fun dep -> require (rebuilt dep)) deps;
149 (* Ignored packages are treated as if they have been rebuilt. *)
150 if not (ignored pkg) then (
151 (* A local test build must succeed. *)
152 require (local_build_succeeded pkg);
154 (* Rebuild the package in Koji. Don't wait ... *)
155 koji_build ~wait:false pkg branch;
157 (* ... but the build doesn't appear in Koji (eg. in 'koji
158 * buildinfo') until the SRPM has been built. This can take quite
159 * some time. Loop here until the build appears.
162 match koji_build_state (fedora_verrel pkg branch) with
166 | `Building | `Complete ->
169 failwith (sprintf "rebuild of package %s: deleted" pkg)
171 failwith (sprintf "rebuild of package %s: failed" pkg)
173 failwith (sprintf "rebuild of package %s: canceled" pkg)
178 and local_build_succeeded pkg =
179 (* The specfile must have been updated. *)
180 require (specfile_updated pkg);
183 sprintf "fedora_ocaml_local_build_%s_%s" pkg (fedora_verrel pkg branch) in
185 target (memory_exists key);
187 (* Do a local test build to ensure the Koji build will work. *)
190 sudo yum-builddep -y --disablerepo=\\* --enablerepo=%s %s
192 " (fedora_repo pkg branch)
194 (fedora_specfile pkg branch);
198 and specfile_updated pkg =
199 let repodir = fedora_repo pkg branch in
200 let specfile = fedora_specfile pkg branch in
204 rm -rf x86_64 noarch *.src.rpm .build* clog
208 if not (git_has_local_changes repodir) then
214 sh "sudo yum-builddep -y --disablerepo=\\* --enablerepo=%s %s"
215 (quote yum_repo) specfile;
217 (* For rationale behind always bumping the spec file, see comment
221 if not (file_contains_string specfile rebuild_name) then
222 rebuild_name ^ " rebuild."
224 "Bump release and rebuild." in
225 sh "rpmdev-bumpspec -c %s %s" (quote title) specfile;
227 (* XXX Automate common specfile fixes. *)
231 echo 'Please make further changes as required to the spec file %s.spec'
232 echo '(Press return key)'
235 echo 'OK to commit this change? (press ^C if not)'
238 echo 'OK to push this change? (press ^C if not)'