Add libguestfs upstream build rules.
[goaljobs-goals.git] / fedora_ocaml_rebuild.ml
1 (* Perform a complete Fedora OCaml rebuild, in build order. *)
2
3 open Printf
4
5 open Goaljobs
6 open Config
7 open Fedora
8
9 let branch = "master"
10 let koji_target = "rawhide"
11
12 (* The name of the rebuild, and also the magic substring that must
13  * appear in the %changelog when the package has been rebuilt.
14  *)
15 let rebuild_name = "OCaml 4.01.0"
16
17 (* Packages that have problems or we just don't want to build. *)
18 let blocked = [
19   "ocaml-libvirt"; (* RHBZ#1009701 *)
20   "ocaml-lwt"; "ocaml-react"; (* loganjerry is handling *)
21 ]
22
23 (* List of OCaml-related source package names. *)
24 let source_packages =
25   let dirs = shlines "cd %s && ls -1d ocaml*" fedora_dir in
26   dirs @ [ "alt-ergo"; "apron"; "brltty"; "coccinelle"; "coq";
27            "cduce"; "frama-c"; "gappalib-coq"; "graphviz"; "hivex";
28            "js-of-ocaml"; "llvm"; "plplot"; "whenjobs"; "why3"; "xen" ]
29
30 let source_packages =
31   List.filter (fun pkg -> not (List.mem pkg blocked)) source_packages
32
33 (* Dependencies of each package.  (pkg, [deps ...]) *)
34 let pkg_deps = dependencies branch source_packages
35
36 (* Goal: rebuild all packages. *)
37 let rec goal all () =
38   List.iter (fun pkg -> require (rebuilt pkg)) source_packages
39
40 (* Goal: That 'package' has been rebuilt and exists in Koji. *)
41 and rebuilt pkg =
42   let deps = List.assoc pkg pkg_deps in
43   let specfile = fedora_specfile pkg branch in
44
45   (* Note the target must be both of these because the old verrel
46    * could exist as a koji build without it having been part of the
47    * rebuild.
48    *)
49   target (file_contains_string specfile rebuild_name &&
50             koji_build_exists (fedora_verrel pkg branch));
51
52   (* All dependent packages must have been done first. *)
53   List.iter (fun dep -> require (rebuilt dep)) deps;
54
55   (* A local test build must succeed. *)
56   require (local_build_succeeded pkg);
57
58   (* Rebuild the package in Koji. *)
59   koji_build pkg branch;
60
61   (* Wait for the build to appear in Koji repo.  Note verrel may change. *)
62   koji_wait_repo koji_target (fedora_verrel pkg branch)
63
64 and local_build_succeeded pkg =
65   (* The specfile must have been updated. *)
66   require (specfile_updated pkg);
67
68   let key =
69     sprintf "fedora_ocaml_local_build_%s_%s" pkg (fedora_verrel pkg branch) in
70
71   target (memory_exists key);
72
73   (* Do a local test build to ensure the Koji build will work. *)
74   sh "
75     cd %s
76     sudo yum-builddep %s
77     fedpkg local
78   " (fedora_repo pkg branch)
79     (fedora_specfile pkg branch);
80
81   memory_set key "1"
82
83 and specfile_updated pkg =
84   let repodir = fedora_repo pkg branch in
85   let specfile = fedora_specfile pkg branch in
86
87   (* XXX Automate common changes. *)
88   let title = rebuild_name ^ " rebuild." in
89   sh "
90     cd %s
91     git pull --rebase
92     rm -rf x86_64 noarch *.src.rpm
93     rpmdev-bumpspec -c %s %s
94     echo 'Please make further changes as required to the spec file %s.spec'
95     echo '(Press return key)'
96     read
97     emacs -nw %s
98     echo 'OK to commit this change? (press ^C if not)'
99     read
100     fedpkg commit -c
101     echo 'OK to push this change? (press ^C if not)'
102     read
103     fedpkg push
104   " repodir
105     (quote title) specfile
106     pkg
107     specfile