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 let blocked pkg = List.mem pkg blocked
38 (* These packages are treated as if they have been rebuilt. *)
40 "ocaml-srpm-macros"; (* don't need to build this *)
41 "ocaml"; (* rebuilt by hand *)
42 "ocaml-findlib"; (* rebuilt by hand *)
43 "ocaml-lwt"; "ocaml-react"; (* loganjerry is handling *)
44 "whenjobs"; (* obsolete *)
46 let ignored pkg = List.mem pkg ignored
48 (* List of OCaml-related source package names. *)
50 let dirs = shlines "cd %s && ls -1d ocaml*" fedora_dir in
51 dirs @ [ "alt-ergo"; "apron"; "brltty"; "coccinelle"; "coq";
52 "cduce"; "frama-c"; "gappalib-coq"; "graphviz"; "hivex";
53 "js-of-ocaml"; "llvm"; "plplot"; "why3"; "xen" ]
55 (* Dependencies of each package. (pkg, [deps ...]) *)
56 let pkg_deps = dependencies branch source_packages
58 (* Remove blocked packages and packages which have a blocked package
59 * as a dependency (recursively).
62 let rec is_blocked pkg =
63 if blocked pkg then true
65 let deps = List.assoc pkg pkg_deps in
66 List.exists is_blocked deps
69 List.filter (fun pkg -> not (is_blocked pkg)) source_packages
72 printf "final list of source packages = %s\n%!"
73 (String.concat " " source_packages)
75 (* Goal: rebuild all packages. *)
77 List.iter (fun pkg -> require (rebuild_started pkg)) source_packages
79 (* Goal: That 'package' has been rebuilt and exists in Koji. *)
81 let specfile = fedora_specfile pkg branch in
83 (* Note: verrel may change as we go along, so don't assign it to
87 (* Note the target must be both of these because the old verrel
88 * could exist as a koji build without it having been part of the
91 target (ignored pkg ||
92 (file_contains_string specfile rebuild_name &&
93 koji_build_state (fedora_verrel pkg branch) == `Complete));
95 (* Ignored packages are treated as if they have been rebuilt. *)
96 if not (ignored pkg) then (
98 (* Start the rebuild. *)
99 require (rebuild_started pkg);
101 (* Wait for the build state to reach a conclusion. *)
103 match koji_build_state (fedora_verrel pkg branch) with
105 failwith (sprintf "rebuild of package %s: no build found" pkg)
112 failwith (sprintf "rebuild of package %s: deleted" pkg)
114 failwith (sprintf "rebuild of package %s: failed" pkg)
116 failwith (sprintf "rebuild of package %s: canceled" pkg)
120 (* Wait for the build to appear in Koji repo. *)
121 koji_wait_repo koji_target (fedora_verrel pkg branch)
124 (* Goal: The rebuild of the package has started, but we haven't waited
127 and rebuild_started pkg =
128 let deps = List.assoc pkg pkg_deps in
129 let specfile = fedora_specfile pkg branch in
131 (* Note the target must be both of these because the old verrel
132 * could exist as a koji build without it having been part of the
135 target (ignored pkg ||
136 (file_contains_string specfile rebuild_name &&
137 (match koji_build_state (fedora_verrel pkg branch) with
138 | `Building | `Complete -> true
139 | `Deleted | `Failed | `Canceled | `No_such_build -> false)));
141 (* All dependent packages must have been fully rebuilt and in the
144 List.iter (fun dep -> require (rebuilt dep)) deps;
146 (* Ignored packages are treated as if they have been rebuilt. *)
147 if not (ignored pkg) then (
148 (* A local test build must succeed. *)
149 require (local_build_succeeded pkg);
151 (* Rebuild the package in Koji. Don't wait ... *)
152 koji_build ~wait:false pkg branch;
154 (* ... but the build doesn't appear in Koji (eg. in 'koji
155 * buildinfo') until the SRPM has been built. This can take quite
156 * some time. Loop here until the build appears.
159 match koji_build_state (fedora_verrel pkg branch) with
163 | `Building | `Complete ->
166 failwith (sprintf "rebuild of package %s: deleted" pkg)
168 failwith (sprintf "rebuild of package %s: failed" pkg)
170 failwith (sprintf "rebuild of package %s: canceled" pkg)
175 and local_build_succeeded pkg =
176 (* The specfile must have been updated. *)
177 require (specfile_updated pkg);
180 sprintf "fedora_ocaml_local_build_%s_%s" pkg (fedora_verrel pkg branch) in
182 target (memory_exists key);
184 (* Do a local test build to ensure the Koji build will work. *)
187 sudo yum-builddep -y --disablerepo=\\* --enablerepo=%s %s
189 " (fedora_repo pkg branch)
191 (fedora_specfile pkg branch);
195 and specfile_updated pkg =
196 let repodir = fedora_repo pkg branch in
197 let specfile = fedora_specfile pkg branch in
201 rm -rf x86_64 noarch *.src.rpm .build* clog
205 if not (git_has_local_changes repodir) then
211 sh "sudo yum-builddep -y --disablerepo=\\* --enablerepo=%s %s"
212 (quote yum_repo) specfile;
214 (* For rationale behind always bumping the spec file, see comment
218 if not (file_contains_string specfile rebuild_name) then
219 rebuild_name ^ " rebuild."
221 "Bump release and rebuild." in
222 sh "rpmdev-bumpspec -c %s %s" (quote title) specfile;
224 (* XXX Automate common specfile fixes. *)
228 echo 'Please make further changes as required to the spec file %s.spec'
229 echo '(Press return key)'
232 echo 'OK to commit this change? (press ^C if not)'
235 echo 'OK to push this change? (press ^C if not)'