Make F22 and F23 follow 1.30
[goaljobs-goals.git] / libguestfs_fedora.ml
1 (* Handle Fedora builds of libguestfs. *)
2
3 open Goaljobs
4
5 open Printf
6
7 open Config
8 open Fedora
9 open Git
10 open Libguestfs
11
12 (* Enable debugging. *)
13 let () =
14   Unix.putenv "LIBGUESTFS_DEBUG" "1";
15   Unix.putenv "LIBGUESTFS_TRACE" "1"
16
17 (* Log program output. *)
18 let from = "rjones@redhat.com"
19 let to_ = "rjones@redhat.com"
20
21 let package = "libguestfs"
22
23 (* How branches in libguestfs upstream map to branches in Fedora. *)
24 let branches = [
25   "1.31-development", "master";    (* Rawhide follows development. *)
26   "1.30-stable", "f23";            (* F23 follows 1.30. *)
27   "1.30-stable", "f22";            (* F22 follows 1.30. *)
28   "1.28-stable", "f21";            (* F21 follows 1.28. *)
29   "1.26-stable", "f20";            (* F20 follows 1.26. *)
30 ]
31
32 (* Goal: Latest website version has been built in every branch. *)
33 let rec goal all () =
34   List.iter (
35     fun (wbranch, fbranch) ->
36       match website_latest_version wbranch with
37       | None -> ()
38       | Some version ->
39         require (fedora_built version fbranch)
40   ) branches
41
42 (* Goal: Fedora has a successful build of 'version' on 'branch'. *)
43 and fedora_built version branch =
44   let specfile = fedora_specfile package branch in
45
46   target (file_contains_string specfile version.version &&
47             match koji_build_state (fedora_verrel package branch) with
48             | `Complete | `Building -> true
49             | _ -> false);
50
51   require (sources_uploaded version branch);
52   require (specfile_pushed version branch);
53
54   koji_build ~wait:true package branch
55
56 and sources_uploaded version branch =
57   let repodir = fedora_repo package branch in
58   let sources = repodir // "sources" in
59   let key = sprintf "libguestfs_fedora_sources_uploaded_%s" version.version in
60
61   target (file_contains_string sources version.version &&
62             memory_exists key);
63   onrun (fun () -> memory_set key "1");
64
65   require (repodir_up_to_date repodir);
66
67   sh "
68     cd %s
69     fedpkg new-sources %s/%s
70   " repodir libguestfs_website_repo version.urlpath
71
72 and specfile_updated version branch =
73   let repodir = fedora_repo package branch in
74   let specfile = fedora_specfile package branch in
75
76   target (file_contains_string specfile version.version);
77
78   require (repodir_up_to_date repodir);
79
80   (* Hairy specfile editing. *)
81   sh "
82     cd %s
83     email=\"Richard W.M. Jones <rjones@redhat.com>\"
84     date=`date +\"%%a %%b %%d %%Y\"`
85     cp libguestfs.spec libguestfs.spec.old
86     sed < libguestfs.spec.old \\
87     -e \"s/^Version:.*/Version:       %s/\" \\
88     -e \"s/^Release:.*/Release:       1%%{?dist}/\" \\
89     -e \"/^%%changelog/a \\
90 * $date $email - 1:%s-1\\\\n\\
91 - New upstream version %s.\\\\n\\
92 \" > libguestfs.spec
93     rm libguestfs.spec.old
94   " repodir version.version version.version version.version
95
96 and specfile_committed version branch =
97   let repodir = fedora_repo package branch in
98   let key = sprintf "libguestfs_fedora_specfile_committed_%s_%s"
99     branch version.version in
100
101   target (memory_exists key);
102   onrun (fun () -> memory_set key "1");
103
104   require (specfile_updated version branch);
105
106   sh "
107     cd %s
108     fedpkg commit -c
109   " repodir
110
111 and specfile_pushed version branch =
112   let repodir = fedora_repo package branch in
113   let key =
114     sprintf "libguestfs_fedora_specfile_pushed_%s_%s" branch version.version in
115
116   target (memory_exists key);
117   onrun (fun () -> memory_set key "1");
118
119   require (repodir_up_to_date repodir);
120   require (specfile_committed version branch);
121
122   sh "
123     cd %s
124     fedpkg push
125   " repodir
126
127 and repodir_up_to_date repodir =
128   sh "
129     cd %s
130     git fetch
131   " repodir;
132   if not (git_has_local_changes repodir) then
133     sh "
134       cd %s
135       git pull --rebase
136     " repodir