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.01.0"
19 (* Packages that have problems or we just don't want to build. *)
21 "ocaml-libvirt"; (* RHBZ#1009701 *)
22 "ocaml-lwt"; "ocaml-react"; (* loganjerry is handling *)
23 "ocaml-xmlrpc-light"; (* temporary, can remove after 2013-09-19 *)
26 (* List of OCaml-related source package names. *)
28 let dirs = shlines "cd %s && ls -1d ocaml*" fedora_dir in
29 dirs @ [ "alt-ergo"; "apron"; "brltty"; "coccinelle"; "coq";
30 "cduce"; "frama-c"; "gappalib-coq"; "graphviz"; "hivex";
31 "js-of-ocaml"; "llvm"; "plplot"; "whenjobs"; "why3"; "xen" ]
34 List.filter (fun pkg -> not (List.mem pkg blocked)) source_packages
36 (* Dependencies of each package. (pkg, [deps ...]) *)
37 let pkg_deps = dependencies branch source_packages
39 (* Goal: rebuild all packages. *)
41 List.iter (fun pkg -> require (rebuild_started pkg)) source_packages
43 (* Goal: That 'package' has been rebuilt and exists in Koji. *)
45 let specfile = fedora_specfile pkg branch in
47 (* Note: verrel may change as we go along, so don't assign it to
51 (* Note the target must be both of these because the old verrel
52 * could exist as a koji build without it having been part of the
55 target (file_contains_string specfile rebuild_name &&
56 koji_build_state (fedora_verrel pkg branch) == `Complete);
58 (* Start the rebuild. *)
59 require (rebuild_started pkg);
61 (* Wait for the build state to reach a conclusion. *)
63 match koji_build_state (fedora_verrel pkg branch) with
65 failwith (sprintf "rebuild of package %s: no build found" pkg)
72 failwith (sprintf "rebuild of package %s: deleted" pkg)
74 failwith (sprintf "rebuild of package %s: failed" pkg)
76 failwith (sprintf "rebuild of package %s: canceled" pkg)
80 (* Wait for the build to appear in Koji repo. *)
81 koji_wait_repo koji_target (fedora_verrel pkg branch)
83 (* Goal: The rebuild of the package has started, but we haven't waited
86 and rebuild_started pkg =
87 let deps = List.assoc pkg pkg_deps in
88 let specfile = fedora_specfile pkg branch in
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 (file_contains_string specfile rebuild_name &&
95 (match koji_build_state (fedora_verrel pkg branch) with
96 | `Building | `Complete -> true
97 | `Deleted | `Failed | `Canceled | `No_such_build -> false));
99 (* All dependent packages must have been fully rebuilt and in the
102 List.iter (fun dep -> require (rebuilt dep)) deps;
104 (* A local test build must succeed. *)
105 require (local_build_succeeded pkg);
107 (* Rebuild the package in Koji. Don't wait ... *)
108 koji_build ~wait:false pkg branch;
110 (* ... but the build doesn't appear in Koji (eg. in 'koji
111 * buildinfo') until the SRPM has been built. This can take quite
112 * some time. Loop here until the build appears.
115 match koji_build_state (fedora_verrel pkg branch) with
119 | `Building | `Complete ->
122 failwith (sprintf "rebuild of package %s: deleted" pkg)
124 failwith (sprintf "rebuild of package %s: failed" pkg)
126 failwith (sprintf "rebuild of package %s: canceled" pkg)
130 and local_build_succeeded pkg =
131 (* The specfile must have been updated. *)
132 require (specfile_updated pkg);
135 sprintf "fedora_ocaml_local_build_%s_%s" pkg (fedora_verrel pkg branch) in
137 target (memory_exists key);
139 (* Do a local test build to ensure the Koji build will work. *)
142 sudo yum-builddep -y %s
144 " (fedora_repo pkg branch)
145 (fedora_specfile pkg branch);
149 and specfile_updated pkg =
150 let repodir = fedora_repo pkg branch in
151 let specfile = fedora_specfile pkg branch in
155 rm -rf x86_64 noarch *.src.rpm .build* clog
159 if not (git_has_local_changes repodir) then
165 sh "sudo yum-builddep -y %s" specfile;
167 (* For rationale behind always bumping the spec file, see comment
171 if not (file_contains_string specfile rebuild_name) then
172 rebuild_name ^ " rebuild."
174 "Bump release and rebuild." in
175 sh "rpmdev-bumpspec -c %s %s" (quote title) specfile;
177 (* XXX Automate common specfile fixes. *)
181 echo 'Please make further changes as required to the spec file %s.spec'
182 echo '(Press return key)'
185 echo 'OK to commit this change? (press ^C if not)'
188 echo 'OK to push this change? (press ^C if not)'