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-0.8.git10e45753.fc22"
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-mikmatch"; (* build failure on 4.02.0 *)
27 "ocaml-omake"; (* build failure on 4.02.0 with hevea *)
28 "ocaml-p3l"; (* build failure on 4.02.0 -warn-error A *)
29 "ocaml-pa-do"; (* build failure, complex *)
30 "ocaml-lwt"; (* build failure on 4.02.0 *)
31 "ocaml-preludeml"; (* build failure *)
32 "cduce"; (* camlp4-related failure, discussed upstream *)
33 "frama-c"; (* build failure *)
35 let blocked pkg = List.mem pkg blocked
37 (* These packages are treated as if they have been rebuilt. *)
39 "ocaml-srpm-macros"; (* don't need to build this *)
40 "ocaml"; (* rebuilt by hand *)
41 "whenjobs"; (* obsolete *)
42 "libguestfs"; (* rebuilt by hand *)
43 "graphviz"; (* rebuilt by hand *)
44 "xen"; (* already done *)
45 "plplot"; (* already done *)
47 let ignored pkg = List.mem pkg ignored
49 (* List of OCaml-related source package names. *)
51 let dirs = shlines "cd %s && ls -1d ocaml*" fedora_dir in
52 dirs @ [ "alt-ergo"; "apron"; "brltty"; "coccinelle"; "coq";
53 "cduce"; "frama-c"; "gappalib-coq"; "graphviz"; "hivex";
54 "js-of-ocaml"; "llvm"; "plplot"; "why3"; "xen" ]
56 (* Dependencies of each package. (pkg, [deps ...]) *)
57 let pkg_deps = dependencies branch source_packages
59 (* Remove blocked packages and packages which have a blocked package
60 * as a dependency (recursively).
63 let rec is_blocked pkg =
64 if blocked pkg then true
66 let deps = List.assoc pkg pkg_deps in
67 List.exists is_blocked deps
70 List.filter (fun pkg -> not (is_blocked pkg)) source_packages
73 printf "final list of source packages = %s\n%!"
74 (String.concat " " source_packages)
76 (* Goal: rebuild all packages. *)
78 List.iter (fun pkg -> require (rebuild_started pkg)) source_packages
80 (* Goal: That 'package' has been rebuilt and exists in Koji. *)
82 let specfile = fedora_specfile pkg branch in
84 (* Note: verrel may change as we go along, so don't assign it to
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 (ignored pkg ||
93 (file_contains_string specfile rebuild_name &&
94 koji_build_state (fedora_verrel pkg branch) == `Complete));
96 (* Ignored packages are treated as if they have been rebuilt. *)
97 if not (ignored pkg) then (
99 (* Start the rebuild. *)
100 require (rebuild_started pkg);
102 (* Wait for the build state to reach a conclusion. *)
104 match koji_build_state (fedora_verrel pkg branch) with
106 failwith (sprintf "rebuild of package %s: no build found" pkg)
113 failwith (sprintf "rebuild of package %s: deleted" pkg)
115 failwith (sprintf "rebuild of package %s: failed" pkg)
117 failwith (sprintf "rebuild of package %s: canceled" pkg)
121 (* Wait for the build to appear in Koji repo. *)
122 koji_wait_repo koji_target (fedora_verrel pkg branch)
125 (* Goal: The rebuild of the package has started, but we haven't waited
128 and rebuild_started pkg =
129 let deps = List.assoc pkg pkg_deps in
130 let specfile = fedora_specfile pkg branch in
132 (* Note the target must be both of these because the old verrel
133 * could exist as a koji build without it having been part of the
136 target (ignored pkg ||
137 (file_contains_string specfile rebuild_name &&
138 (match koji_build_state (fedora_verrel pkg branch) with
139 | `Building | `Complete -> true
140 | `Deleted | `Failed | `Canceled | `No_such_build -> false)));
142 (* All dependent packages must have been fully rebuilt and in the
145 List.iter (fun dep -> require (rebuilt dep)) deps;
147 (* Ignored packages are treated as if they have been rebuilt. *)
148 if not (ignored pkg) then (
149 (* A local test build must succeed. *)
150 require (local_build_succeeded pkg);
152 (* Rebuild the package in Koji. Don't wait ... *)
153 koji_build ~wait:false pkg branch;
155 (* ... but the build doesn't appear in Koji (eg. in 'koji
156 * buildinfo') until the SRPM has been built. This can take quite
157 * some time. Loop here until the build appears.
160 match koji_build_state (fedora_verrel pkg branch) with
164 | `Building | `Complete ->
167 failwith (sprintf "rebuild of package %s: deleted" pkg)
169 failwith (sprintf "rebuild of package %s: failed" pkg)
171 failwith (sprintf "rebuild of package %s: canceled" pkg)
176 and local_build_succeeded pkg =
177 (* The specfile must have been updated. *)
178 require (specfile_updated pkg);
181 sprintf "fedora_ocaml_local_build_%s_%s" pkg (fedora_verrel pkg branch) in
183 target (memory_exists key);
185 (* Do a local test build to ensure the Koji build will work. *)
188 sudo yum-builddep -y --disablerepo=\\* --enablerepo=%s %s
190 " (fedora_repo pkg branch)
192 (fedora_specfile pkg branch);
196 and specfile_updated pkg =
197 let repodir = fedora_repo pkg branch in
198 let specfile = fedora_specfile pkg branch in
202 rm -rf x86_64 noarch *.src.rpm .build* clog
206 if not (git_has_local_changes repodir) then
212 sh "sudo yum-builddep -y --disablerepo=\\* --enablerepo=%s %s"
213 (quote yum_repo) specfile;
215 (* For rationale behind always bumping the spec file, see comment
219 if not (file_contains_string specfile rebuild_name) then
220 rebuild_name ^ " rebuild."
222 "Bump release and rebuild." in
223 sh "rpmdev-bumpspec -c %s %s" (quote title) specfile;
225 (* XXX Automate common specfile fixes. *)
229 echo 'Please make further changes as required to the spec file %s.spec'
230 echo '(Press return key)'
233 echo 'OK to commit this change? (press ^C if not)'
236 echo 'OK to push this change? (press ^C if not)'